Win32 API 日本語リファレンス
ホームSecurity.Cryptography › BCRYPT_PKCS11_RSA_AES_WRAP_BLOB

BCRYPT_PKCS11_RSA_AES_WRAP_BLOB

構造体
サイズx64: 16 バイト / x86: 16 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwMagicDWORD4+0+0BLOB種別を示すマジック値。
cbKeyDWORD4+4+4ラップされた鍵のバイト長。
cbPaddingAlgIdDWORD4+8+8パディングアルゴリズムID部分のバイト長。
cbPaddingLabelDWORD4+12+12パディングラベル部分のバイト長。

各言語での定義

#include <windows.h>

// BCRYPT_PKCS11_RSA_AES_WRAP_BLOB  (x64 16 / x86 16 バイト)
typedef struct BCRYPT_PKCS11_RSA_AES_WRAP_BLOB {
    DWORD dwMagic;
    DWORD cbKey;
    DWORD cbPaddingAlgId;
    DWORD cbPaddingLabel;
} BCRYPT_PKCS11_RSA_AES_WRAP_BLOB;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BCRYPT_PKCS11_RSA_AES_WRAP_BLOB
{
    public uint dwMagic;
    public uint cbKey;
    public uint cbPaddingAlgId;
    public uint cbPaddingLabel;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BCRYPT_PKCS11_RSA_AES_WRAP_BLOB
    Public dwMagic As UInteger
    Public cbKey As UInteger
    Public cbPaddingAlgId As UInteger
    Public cbPaddingLabel As UInteger
End Structure
import ctypes
from ctypes import wintypes

class BCRYPT_PKCS11_RSA_AES_WRAP_BLOB(ctypes.Structure):
    _fields_ = [
        ("dwMagic", wintypes.DWORD),
        ("cbKey", wintypes.DWORD),
        ("cbPaddingAlgId", wintypes.DWORD),
        ("cbPaddingLabel", wintypes.DWORD),
    ]
#[repr(C)]
pub struct BCRYPT_PKCS11_RSA_AES_WRAP_BLOB {
    pub dwMagic: u32,
    pub cbKey: u32,
    pub cbPaddingAlgId: u32,
    pub cbPaddingLabel: u32,
}
import "golang.org/x/sys/windows"

type BCRYPT_PKCS11_RSA_AES_WRAP_BLOB struct {
	dwMagic uint32
	cbKey uint32
	cbPaddingAlgId uint32
	cbPaddingLabel uint32
}
type
  BCRYPT_PKCS11_RSA_AES_WRAP_BLOB = record
    dwMagic: DWORD;
    cbKey: DWORD;
    cbPaddingAlgId: DWORD;
    cbPaddingLabel: DWORD;
  end;
const BCRYPT_PKCS11_RSA_AES_WRAP_BLOB = extern struct {
    dwMagic: u32,
    cbKey: u32,
    cbPaddingAlgId: u32,
    cbPaddingLabel: u32,
};
type
  BCRYPT_PKCS11_RSA_AES_WRAP_BLOB {.bycopy.} = object
    dwMagic: uint32
    cbKey: uint32
    cbPaddingAlgId: uint32
    cbPaddingLabel: uint32
struct BCRYPT_PKCS11_RSA_AES_WRAP_BLOB
{
    uint dwMagic;
    uint cbKey;
    uint cbPaddingAlgId;
    uint cbPaddingLabel;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BCRYPT_PKCS11_RSA_AES_WRAP_BLOB サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; dwMagic : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; cbKey : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; cbPaddingAlgId : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; cbPaddingLabel : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BCRYPT_PKCS11_RSA_AES_WRAP_BLOB
    #field int dwMagic
    #field int cbKey
    #field int cbPaddingAlgId
    #field int cbPaddingLabel
#endstruct

stdim st, BCRYPT_PKCS11_RSA_AES_WRAP_BLOB        ; NSTRUCT 変数を確保
st->dwMagic = 100
mes "dwMagic=" + st->dwMagic