ホーム › Security.Cryptography › CRYPT_KEY_SIGN_MESSAGE_PARA
CRYPT_KEY_SIGN_MESSAGE_PARA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト単位)。 |
| dwMsgAndCertEncodingType | CERT_QUERY_ENCODING_TYPE | 4 | +4 | +4 | メッセージおよび証明書のエンコード種別。 |
| Anonymous | _Anonymous_e__Union | 8/4 | +8 | +8 | 署名に使うレガシーCSPまたはCNG鍵ハンドルを保持する共用体。 |
| dwKeySpec | CERT_KEY_SPEC | 4 | +16 | +12 | 使用する鍵の種別(AT_KEYEXCHANGE/AT_SIGNATURE等)。 |
| HashAlgorithm | CRYPT_ALGORITHM_IDENTIFIER | 24/12 | +24 | +16 | 署名前のハッシュ計算に用いるアルゴリズム識別子。 |
| pvHashAuxInfo | void* | 8/4 | +48 | +28 | ハッシュアルゴリズムの補助情報へのポインタ。NULL可。 |
| PubKeyAlgorithm | CRYPT_ALGORITHM_IDENTIFIER | 24/12 | +56 | +32 | 署名に対応する公開鍵アルゴリズム識別子。 |
共用体: _Anonymous_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| hCryptProv | UINT_PTR | 8/4 | +0 | +0 |
| hNCryptKey | NCRYPT_KEY_HANDLE | 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;
// CRYPT_KEY_SIGN_MESSAGE_PARA (x64 80 / x86 44 バイト)
typedef struct CRYPT_KEY_SIGN_MESSAGE_PARA {
DWORD cbSize;
CERT_QUERY_ENCODING_TYPE dwMsgAndCertEncodingType;
_Anonymous_e__Union Anonymous;
CERT_KEY_SPEC dwKeySpec;
CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
void* pvHashAuxInfo;
CRYPT_ALGORITHM_IDENTIFIER PubKeyAlgorithm;
} CRYPT_KEY_SIGN_MESSAGE_PARA;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 CRYPT_KEY_SIGN_MESSAGE_PARA
{
public uint cbSize;
public uint dwMsgAndCertEncodingType;
public _Anonymous_e__Union Anonymous;
public uint dwKeySpec;
public CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
public IntPtr pvHashAuxInfo;
public CRYPT_ALGORITHM_IDENTIFIER PubKeyAlgorithm;
}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 CRYPT_KEY_SIGN_MESSAGE_PARA
Public cbSize As UInteger
Public dwMsgAndCertEncodingType As UInteger
Public Anonymous As _Anonymous_e__Union
Public dwKeySpec As UInteger
Public HashAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
Public pvHashAuxInfo As IntPtr
Public PubKeyAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
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 CRYPT_KEY_SIGN_MESSAGE_PARA(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("dwMsgAndCertEncodingType", wintypes.DWORD),
("Anonymous", _Anonymous_e__Union),
("dwKeySpec", wintypes.DWORD),
("HashAlgorithm", CRYPT_ALGORITHM_IDENTIFIER),
("pvHashAuxInfo", ctypes.c_void_p),
("PubKeyAlgorithm", CRYPT_ALGORITHM_IDENTIFIER),
]#[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 CRYPT_KEY_SIGN_MESSAGE_PARA {
pub cbSize: u32,
pub dwMsgAndCertEncodingType: u32,
pub Anonymous: _Anonymous_e__Union,
pub dwKeySpec: u32,
pub HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pub pvHashAuxInfo: *mut core::ffi::c_void,
pub PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
}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 CRYPT_KEY_SIGN_MESSAGE_PARA struct {
cbSize uint32
dwMsgAndCertEncodingType uint32
Anonymous _Anonymous_e__Union
dwKeySpec uint32
HashAlgorithm CRYPT_ALGORITHM_IDENTIFIER
pvHashAuxInfo uintptr
PubKeyAlgorithm CRYPT_ALGORITHM_IDENTIFIER
}type
CRYPT_INTEGER_BLOB = record
cbData: DWORD;
pbData: Pointer;
end;
CRYPT_ALGORITHM_IDENTIFIER = record
pszObjId: Pointer;
Parameters: CRYPT_INTEGER_BLOB;
end;
CRYPT_KEY_SIGN_MESSAGE_PARA = record
cbSize: DWORD;
dwMsgAndCertEncodingType: DWORD;
Anonymous: _Anonymous_e__Union;
dwKeySpec: DWORD;
HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
pvHashAuxInfo: Pointer;
PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
end;const CRYPT_INTEGER_BLOB = extern struct {
cbData: u32,
pbData: ?*anyopaque,
};
const CRYPT_ALGORITHM_IDENTIFIER = extern struct {
pszObjId: ?*anyopaque,
Parameters: CRYPT_INTEGER_BLOB,
};
const CRYPT_KEY_SIGN_MESSAGE_PARA = extern struct {
cbSize: u32,
dwMsgAndCertEncodingType: u32,
Anonymous: _Anonymous_e__Union,
dwKeySpec: u32,
HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pvHashAuxInfo: ?*anyopaque,
PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
};type
CRYPT_INTEGER_BLOB {.bycopy.} = object
cbData: uint32
pbData: pointer
CRYPT_ALGORITHM_IDENTIFIER {.bycopy.} = object
pszObjId: pointer
Parameters: CRYPT_INTEGER_BLOB
CRYPT_KEY_SIGN_MESSAGE_PARA {.bycopy.} = object
cbSize: uint32
dwMsgAndCertEncodingType: uint32
Anonymous: _Anonymous_e__Union
dwKeySpec: uint32
HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER
pvHashAuxInfo: pointer
PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIERstruct CRYPT_INTEGER_BLOB
{
uint cbData;
void* pbData;
}
struct CRYPT_ALGORITHM_IDENTIFIER
{
void* pszObjId;
CRYPT_INTEGER_BLOB Parameters;
}
struct CRYPT_KEY_SIGN_MESSAGE_PARA
{
uint cbSize;
uint dwMsgAndCertEncodingType;
_Anonymous_e__Union Anonymous;
uint dwKeySpec;
CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
void* pvHashAuxInfo;
CRYPT_ALGORITHM_IDENTIFIER PubKeyAlgorithm;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CRYPT_KEY_SIGN_MESSAGE_PARA サイズ: 44 バイト(x86)
dim st, 11 ; 4byte整数×11(構造体サイズ 44 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwMsgAndCertEncodingType : CERT_QUERY_ENCODING_TYPE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+8, 4byte) varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; dwKeySpec : CERT_KEY_SPEC (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; HashAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+16, 12byte) varptr(st)+16 を基点に操作(12byte:入れ子/配列)
; pvHashAuxInfo : void* (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; PubKeyAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+32, 12byte) varptr(st)+32 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CRYPT_KEY_SIGN_MESSAGE_PARA サイズ: 80 バイト(x64)
dim st, 20 ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwMsgAndCertEncodingType : CERT_QUERY_ENCODING_TYPE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; dwKeySpec : CERT_KEY_SPEC (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; HashAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+24, 24byte) varptr(st)+24 を基点に操作(24byte:入れ子/配列)
; pvHashAuxInfo : void* (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; PubKeyAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+56, 24byte) varptr(st)+56 を基点に操作(24byte:入れ子/配列)
; ※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 CRYPT_KEY_SIGN_MESSAGE_PARA
#field int cbSize
#field int dwMsgAndCertEncodingType
#field byte Anonymous 8
#field int dwKeySpec
#field CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm
#field intptr pvHashAuxInfo
#field CRYPT_ALGORITHM_IDENTIFIER PubKeyAlgorithm
#endstruct
stdim st, CRYPT_KEY_SIGN_MESSAGE_PARA ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。