ホーム › Security.Cryptography › CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト単位)。 |
| KeyEncryptionAlgorithm | CRYPT_ALGORITHM_IDENTIFIER | 24/12 | +8 | +4 | 鍵共有による鍵暗号化アルゴリズム識別子。 |
| pvKeyEncryptionAuxInfo | void* | 8/4 | +32 | +16 | 鍵暗号化アルゴリズムの補助情報へのポインタ。NULL可。 |
| KeyWrapAlgorithm | CRYPT_ALGORITHM_IDENTIFIER | 24/12 | +40 | +20 | コンテンツ暗号鍵をラップするアルゴリズム識別子。 |
| pvKeyWrapAuxInfo | void* | 8/4 | +64 | +32 | 鍵ラップアルゴリズムの補助情報へのポインタ。NULL可。 |
| hCryptProv | HCRYPTPROV_LEGACY | 8/4 | +72 | +36 | 暗号化に使うレガシーCSPハンドル。0でも可。 |
| dwKeySpec | DWORD | 4 | +80 | +40 | 送信者鍵の種別(AT_KEYEXCHANGE等)。 |
| dwKeyChoice | CMSG_KEY_AGREE_OPTION | 4 | +84 | +44 | 鍵共有方式(静的/一時的)を示す列挙値。 |
| Anonymous | _Anonymous_e__Union | 8/4 | +88 | +48 | 鍵共有方式に応じた送信者鍵情報を保持する共用体。 |
| UserKeyingMaterial | CRYPT_INTEGER_BLOB | 16/8 | +96 | +52 | 鍵導出に使うユーザ鍵素材を格納するBLOB。 |
| cRecipientEncryptedKeys | DWORD | 4 | +112 | +60 | rgpRecipientEncryptedKeys配列の要素数。 |
| rgpRecipientEncryptedKeys | CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO** | 8/4 | +120 | +64 | 受信者ごとの暗号化鍵エンコード情報ポインタの配列へのポインタ。 |
共用体: _Anonymous_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| pEphemeralAlgorithm | CRYPT_ALGORITHM_IDENTIFIER* | 8/4 | +0 | +0 |
| pSenderId | CERT_ID* | 8/4 | +0 | +0 |
各言語での定義
#include <windows.h>
// CRYPT_INTEGER_BLOB (x64 16 / x86 8 バイト)
typedef struct CRYPT_INTEGER_BLOB {
DWORD cbData;
BYTE* pbData;
} CRYPT_INTEGER_BLOB;
// CRYPT_ALGORITHM_IDENTIFIER (x64 24 / x86 12 バイト)
typedef struct CRYPT_ALGORITHM_IDENTIFIER {
LPSTR pszObjId;
CRYPT_INTEGER_BLOB Parameters;
} CRYPT_ALGORITHM_IDENTIFIER;
// CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO (x64 128 / x86 68 バイト)
typedef struct CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO {
DWORD cbSize;
CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm;
void* pvKeyEncryptionAuxInfo;
CRYPT_ALGORITHM_IDENTIFIER KeyWrapAlgorithm;
void* pvKeyWrapAuxInfo;
HCRYPTPROV_LEGACY hCryptProv;
DWORD dwKeySpec;
CMSG_KEY_AGREE_OPTION dwKeyChoice;
_Anonymous_e__Union Anonymous;
CRYPT_INTEGER_BLOB UserKeyingMaterial;
DWORD cRecipientEncryptedKeys;
CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO** rgpRecipientEncryptedKeys;
} CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_INTEGER_BLOB
{
public uint cbData;
public IntPtr pbData;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_ALGORITHM_IDENTIFIER
{
public IntPtr pszObjId;
public CRYPT_INTEGER_BLOB Parameters;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
{
public uint cbSize;
public CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm;
public IntPtr pvKeyEncryptionAuxInfo;
public CRYPT_ALGORITHM_IDENTIFIER KeyWrapAlgorithm;
public IntPtr pvKeyWrapAuxInfo;
public UIntPtr hCryptProv;
public uint dwKeySpec;
public uint dwKeyChoice;
public _Anonymous_e__Union Anonymous;
public CRYPT_INTEGER_BLOB UserKeyingMaterial;
public uint cRecipientEncryptedKeys;
public IntPtr rgpRecipientEncryptedKeys;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_INTEGER_BLOB
Public cbData As UInteger
Public pbData As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_ALGORITHM_IDENTIFIER
Public pszObjId As IntPtr
Public Parameters As CRYPT_INTEGER_BLOB
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
Public cbSize As UInteger
Public KeyEncryptionAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
Public pvKeyEncryptionAuxInfo As IntPtr
Public KeyWrapAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
Public pvKeyWrapAuxInfo As IntPtr
Public hCryptProv As UIntPtr
Public dwKeySpec As UInteger
Public dwKeyChoice As UInteger
Public Anonymous As _Anonymous_e__Union
Public UserKeyingMaterial As CRYPT_INTEGER_BLOB
Public cRecipientEncryptedKeys As UInteger
Public rgpRecipientEncryptedKeys As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class CRYPT_INTEGER_BLOB(ctypes.Structure):
_fields_ = [
("cbData", wintypes.DWORD),
("pbData", ctypes.c_void_p),
]
class CRYPT_ALGORITHM_IDENTIFIER(ctypes.Structure):
_fields_ = [
("pszObjId", ctypes.c_void_p),
("Parameters", CRYPT_INTEGER_BLOB),
]
class CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("KeyEncryptionAlgorithm", CRYPT_ALGORITHM_IDENTIFIER),
("pvKeyEncryptionAuxInfo", ctypes.c_void_p),
("KeyWrapAlgorithm", CRYPT_ALGORITHM_IDENTIFIER),
("pvKeyWrapAuxInfo", ctypes.c_void_p),
("hCryptProv", ctypes.c_size_t),
("dwKeySpec", wintypes.DWORD),
("dwKeyChoice", wintypes.DWORD),
("Anonymous", _Anonymous_e__Union),
("UserKeyingMaterial", CRYPT_INTEGER_BLOB),
("cRecipientEncryptedKeys", wintypes.DWORD),
("rgpRecipientEncryptedKeys", ctypes.c_void_p),
]#[repr(C)]
pub struct CRYPT_INTEGER_BLOB {
pub cbData: u32,
pub pbData: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct CRYPT_ALGORITHM_IDENTIFIER {
pub pszObjId: *mut core::ffi::c_void,
pub Parameters: CRYPT_INTEGER_BLOB,
}
#[repr(C)]
pub struct CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO {
pub cbSize: u32,
pub KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pub pvKeyEncryptionAuxInfo: *mut core::ffi::c_void,
pub KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pub pvKeyWrapAuxInfo: *mut core::ffi::c_void,
pub hCryptProv: usize,
pub dwKeySpec: u32,
pub dwKeyChoice: u32,
pub Anonymous: _Anonymous_e__Union,
pub UserKeyingMaterial: CRYPT_INTEGER_BLOB,
pub cRecipientEncryptedKeys: u32,
pub rgpRecipientEncryptedKeys: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type CRYPT_INTEGER_BLOB struct {
cbData uint32
pbData uintptr
}
type CRYPT_ALGORITHM_IDENTIFIER struct {
pszObjId uintptr
Parameters CRYPT_INTEGER_BLOB
}
type CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO struct {
cbSize uint32
KeyEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER
pvKeyEncryptionAuxInfo uintptr
KeyWrapAlgorithm CRYPT_ALGORITHM_IDENTIFIER
pvKeyWrapAuxInfo uintptr
hCryptProv uintptr
dwKeySpec uint32
dwKeyChoice uint32
Anonymous _Anonymous_e__Union
UserKeyingMaterial CRYPT_INTEGER_BLOB
cRecipientEncryptedKeys uint32
rgpRecipientEncryptedKeys uintptr
}type
CRYPT_INTEGER_BLOB = record
cbData: DWORD;
pbData: Pointer;
end;
CRYPT_ALGORITHM_IDENTIFIER = record
pszObjId: Pointer;
Parameters: CRYPT_INTEGER_BLOB;
end;
CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = record
cbSize: DWORD;
KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
pvKeyEncryptionAuxInfo: Pointer;
KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
pvKeyWrapAuxInfo: Pointer;
hCryptProv: NativeUInt;
dwKeySpec: DWORD;
dwKeyChoice: DWORD;
Anonymous: _Anonymous_e__Union;
UserKeyingMaterial: CRYPT_INTEGER_BLOB;
cRecipientEncryptedKeys: DWORD;
rgpRecipientEncryptedKeys: Pointer;
end;const CRYPT_INTEGER_BLOB = extern struct {
cbData: u32,
pbData: ?*anyopaque,
};
const CRYPT_ALGORITHM_IDENTIFIER = extern struct {
pszObjId: ?*anyopaque,
Parameters: CRYPT_INTEGER_BLOB,
};
const CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = extern struct {
cbSize: u32,
KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pvKeyEncryptionAuxInfo: ?*anyopaque,
KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pvKeyWrapAuxInfo: ?*anyopaque,
hCryptProv: usize,
dwKeySpec: u32,
dwKeyChoice: u32,
Anonymous: _Anonymous_e__Union,
UserKeyingMaterial: CRYPT_INTEGER_BLOB,
cRecipientEncryptedKeys: u32,
rgpRecipientEncryptedKeys: ?*anyopaque,
};type
CRYPT_INTEGER_BLOB {.bycopy.} = object
cbData: uint32
pbData: pointer
CRYPT_ALGORITHM_IDENTIFIER {.bycopy.} = object
pszObjId: pointer
Parameters: CRYPT_INTEGER_BLOB
CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO {.bycopy.} = object
cbSize: uint32
KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER
pvKeyEncryptionAuxInfo: pointer
KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER
pvKeyWrapAuxInfo: pointer
hCryptProv: uint
dwKeySpec: uint32
dwKeyChoice: uint32
Anonymous: _Anonymous_e__Union
UserKeyingMaterial: CRYPT_INTEGER_BLOB
cRecipientEncryptedKeys: uint32
rgpRecipientEncryptedKeys: pointerstruct CRYPT_INTEGER_BLOB
{
uint cbData;
void* pbData;
}
struct CRYPT_ALGORITHM_IDENTIFIER
{
void* pszObjId;
CRYPT_INTEGER_BLOB Parameters;
}
struct CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
{
uint cbSize;
CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm;
void* pvKeyEncryptionAuxInfo;
CRYPT_ALGORITHM_IDENTIFIER KeyWrapAlgorithm;
void* pvKeyWrapAuxInfo;
size_t hCryptProv;
uint dwKeySpec;
uint dwKeyChoice;
_Anonymous_e__Union Anonymous;
CRYPT_INTEGER_BLOB UserKeyingMaterial;
uint cRecipientEncryptedKeys;
void* rgpRecipientEncryptedKeys;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO サイズ: 68 バイト(x86)
dim st, 17 ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; KeyEncryptionAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+4, 12byte) varptr(st)+4 を基点に操作(12byte:入れ子/配列)
; pvKeyEncryptionAuxInfo : void* (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; KeyWrapAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+20, 12byte) varptr(st)+20 を基点に操作(12byte:入れ子/配列)
; pvKeyWrapAuxInfo : void* (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; hCryptProv : HCRYPTPROV_LEGACY (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dwKeySpec : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; dwKeyChoice : CMSG_KEY_AGREE_OPTION (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+48, 4byte) varptr(st)+48 を基点に操作(4byte:入れ子/配列)
; UserKeyingMaterial : CRYPT_INTEGER_BLOB (+52, 8byte) varptr(st)+52 を基点に操作(8byte:入れ子/配列)
; cRecipientEncryptedKeys : DWORD (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; rgpRecipientEncryptedKeys : CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO** (+64, 4byte) varptr(st)+64 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO サイズ: 128 バイト(x64)
dim st, 32 ; 4byte整数×32(構造体サイズ 128 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; KeyEncryptionAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+8, 24byte) varptr(st)+8 を基点に操作(24byte:入れ子/配列)
; pvKeyEncryptionAuxInfo : void* (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; KeyWrapAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+40, 24byte) varptr(st)+40 を基点に操作(24byte:入れ子/配列)
; pvKeyWrapAuxInfo : void* (+64, 8byte) qpoke st,64,値 / qpeek(st,64) ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; hCryptProv : HCRYPTPROV_LEGACY (+72, 8byte) qpoke st,72,値 / qpeek(st,72) ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; dwKeySpec : DWORD (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; dwKeyChoice : CMSG_KEY_AGREE_OPTION (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+88, 8byte) varptr(st)+88 を基点に操作(8byte:入れ子/配列)
; UserKeyingMaterial : CRYPT_INTEGER_BLOB (+96, 16byte) varptr(st)+96 を基点に操作(16byte:入れ子/配列)
; cRecipientEncryptedKeys : DWORD (+112, 4byte) st.28 = 値 / 値 = st.28 (lpoke/lpeek も可)
; rgpRecipientEncryptedKeys : CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO** (+120, 8byte) varptr(st)+120 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CRYPT_INTEGER_BLOB
#field int cbData
#field intptr pbData
#endstruct
#defstruct global CRYPT_ALGORITHM_IDENTIFIER
#field intptr pszObjId
#field CRYPT_INTEGER_BLOB Parameters
#endstruct
#defstruct global CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
#field int cbSize
#field CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm
#field intptr pvKeyEncryptionAuxInfo
#field CRYPT_ALGORITHM_IDENTIFIER KeyWrapAlgorithm
#field intptr pvKeyWrapAuxInfo
#field intptr hCryptProv
#field int dwKeySpec
#field int dwKeyChoice
#field byte Anonymous 8
#field CRYPT_INTEGER_BLOB UserKeyingMaterial
#field int cRecipientEncryptedKeys
#field intptr rgpRecipientEncryptedKeys
#endstruct
stdim st, CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。