ホーム › Security.Cryptography › CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト単位)。 |
| SignedInfo | CMSG_SIGNED_ENCODE_INFO | 48/28 | +8 | +4 | 署名処理に関するエンコード情報。 |
| EnvelopedInfo | CMSG_ENVELOPED_ENCODE_INFO | 64/32 | +56 | +32 | エンベロープ(暗号化)処理に関するエンコード情報。 |
各言語での定義
#include <windows.h>
// CMSG_SIGNED_ENCODE_INFO (x64 48 / x86 28 バイト)
typedef struct CMSG_SIGNED_ENCODE_INFO {
DWORD cbSize;
DWORD cSigners;
CMSG_SIGNER_ENCODE_INFO* rgSigners;
DWORD cCertEncoded;
CRYPT_INTEGER_BLOB* rgCertEncoded;
DWORD cCrlEncoded;
CRYPT_INTEGER_BLOB* rgCrlEncoded;
} CMSG_SIGNED_ENCODE_INFO;
// 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_ENVELOPED_ENCODE_INFO (x64 64 / x86 32 バイト)
typedef struct CMSG_ENVELOPED_ENCODE_INFO {
DWORD cbSize;
HCRYPTPROV_LEGACY hCryptProv;
CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm;
void* pvEncryptionAuxInfo;
DWORD cRecipients;
CERT_INFO** rgpRecipients;
} CMSG_ENVELOPED_ENCODE_INFO;
// CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO (x64 120 / x86 64 バイト)
typedef struct CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO {
DWORD cbSize;
CMSG_SIGNED_ENCODE_INFO SignedInfo;
CMSG_ENVELOPED_ENCODE_INFO EnvelopedInfo;
} CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CMSG_SIGNED_ENCODE_INFO
{
public uint cbSize;
public uint cSigners;
public IntPtr rgSigners;
public uint cCertEncoded;
public IntPtr rgCertEncoded;
public uint cCrlEncoded;
public IntPtr rgCrlEncoded;
}
[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_ENVELOPED_ENCODE_INFO
{
public uint cbSize;
public UIntPtr hCryptProv;
public CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm;
public IntPtr pvEncryptionAuxInfo;
public uint cRecipients;
public IntPtr rgpRecipients;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
{
public uint cbSize;
public CMSG_SIGNED_ENCODE_INFO SignedInfo;
public CMSG_ENVELOPED_ENCODE_INFO EnvelopedInfo;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CMSG_SIGNED_ENCODE_INFO
Public cbSize As UInteger
Public cSigners As UInteger
Public rgSigners As IntPtr
Public cCertEncoded As UInteger
Public rgCertEncoded As IntPtr
Public cCrlEncoded As UInteger
Public rgCrlEncoded As IntPtr
End Structure
<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_ENVELOPED_ENCODE_INFO
Public cbSize As UInteger
Public hCryptProv As UIntPtr
Public ContentEncryptionAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
Public pvEncryptionAuxInfo As IntPtr
Public cRecipients As UInteger
Public rgpRecipients As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
Public cbSize As UInteger
Public SignedInfo As CMSG_SIGNED_ENCODE_INFO
Public EnvelopedInfo As CMSG_ENVELOPED_ENCODE_INFO
End Structureimport ctypes
from ctypes import wintypes
class CMSG_SIGNED_ENCODE_INFO(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("cSigners", wintypes.DWORD),
("rgSigners", ctypes.c_void_p),
("cCertEncoded", wintypes.DWORD),
("rgCertEncoded", ctypes.c_void_p),
("cCrlEncoded", wintypes.DWORD),
("rgCrlEncoded", ctypes.c_void_p),
]
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_ENVELOPED_ENCODE_INFO(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("hCryptProv", ctypes.c_size_t),
("ContentEncryptionAlgorithm", CRYPT_ALGORITHM_IDENTIFIER),
("pvEncryptionAuxInfo", ctypes.c_void_p),
("cRecipients", wintypes.DWORD),
("rgpRecipients", ctypes.c_void_p),
]
class CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("SignedInfo", CMSG_SIGNED_ENCODE_INFO),
("EnvelopedInfo", CMSG_ENVELOPED_ENCODE_INFO),
]#[repr(C)]
pub struct CMSG_SIGNED_ENCODE_INFO {
pub cbSize: u32,
pub cSigners: u32,
pub rgSigners: *mut core::ffi::c_void,
pub cCertEncoded: u32,
pub rgCertEncoded: *mut core::ffi::c_void,
pub cCrlEncoded: u32,
pub rgCrlEncoded: *mut core::ffi::c_void,
}
#[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_ENVELOPED_ENCODE_INFO {
pub cbSize: u32,
pub hCryptProv: usize,
pub ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pub pvEncryptionAuxInfo: *mut core::ffi::c_void,
pub cRecipients: u32,
pub rgpRecipients: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO {
pub cbSize: u32,
pub SignedInfo: CMSG_SIGNED_ENCODE_INFO,
pub EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFO,
}import "golang.org/x/sys/windows"
type CMSG_SIGNED_ENCODE_INFO struct {
cbSize uint32
cSigners uint32
rgSigners uintptr
cCertEncoded uint32
rgCertEncoded uintptr
cCrlEncoded uint32
rgCrlEncoded uintptr
}
type CRYPT_INTEGER_BLOB struct {
cbData uint32
pbData uintptr
}
type CRYPT_ALGORITHM_IDENTIFIER struct {
pszObjId uintptr
Parameters CRYPT_INTEGER_BLOB
}
type CMSG_ENVELOPED_ENCODE_INFO struct {
cbSize uint32
hCryptProv uintptr
ContentEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER
pvEncryptionAuxInfo uintptr
cRecipients uint32
rgpRecipients uintptr
}
type CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO struct {
cbSize uint32
SignedInfo CMSG_SIGNED_ENCODE_INFO
EnvelopedInfo CMSG_ENVELOPED_ENCODE_INFO
}type
CMSG_SIGNED_ENCODE_INFO = record
cbSize: DWORD;
cSigners: DWORD;
rgSigners: Pointer;
cCertEncoded: DWORD;
rgCertEncoded: Pointer;
cCrlEncoded: DWORD;
rgCrlEncoded: Pointer;
end;
CRYPT_INTEGER_BLOB = record
cbData: DWORD;
pbData: Pointer;
end;
CRYPT_ALGORITHM_IDENTIFIER = record
pszObjId: Pointer;
Parameters: CRYPT_INTEGER_BLOB;
end;
CMSG_ENVELOPED_ENCODE_INFO = record
cbSize: DWORD;
hCryptProv: NativeUInt;
ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
pvEncryptionAuxInfo: Pointer;
cRecipients: DWORD;
rgpRecipients: Pointer;
end;
CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = record
cbSize: DWORD;
SignedInfo: CMSG_SIGNED_ENCODE_INFO;
EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFO;
end;const CMSG_SIGNED_ENCODE_INFO = extern struct {
cbSize: u32,
cSigners: u32,
rgSigners: ?*anyopaque,
cCertEncoded: u32,
rgCertEncoded: ?*anyopaque,
cCrlEncoded: u32,
rgCrlEncoded: ?*anyopaque,
};
const CRYPT_INTEGER_BLOB = extern struct {
cbData: u32,
pbData: ?*anyopaque,
};
const CRYPT_ALGORITHM_IDENTIFIER = extern struct {
pszObjId: ?*anyopaque,
Parameters: CRYPT_INTEGER_BLOB,
};
const CMSG_ENVELOPED_ENCODE_INFO = extern struct {
cbSize: u32,
hCryptProv: usize,
ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
pvEncryptionAuxInfo: ?*anyopaque,
cRecipients: u32,
rgpRecipients: ?*anyopaque,
};
const CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = extern struct {
cbSize: u32,
SignedInfo: CMSG_SIGNED_ENCODE_INFO,
EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFO,
};type
CMSG_SIGNED_ENCODE_INFO {.bycopy.} = object
cbSize: uint32
cSigners: uint32
rgSigners: pointer
cCertEncoded: uint32
rgCertEncoded: pointer
cCrlEncoded: uint32
rgCrlEncoded: pointer
CRYPT_INTEGER_BLOB {.bycopy.} = object
cbData: uint32
pbData: pointer
CRYPT_ALGORITHM_IDENTIFIER {.bycopy.} = object
pszObjId: pointer
Parameters: CRYPT_INTEGER_BLOB
CMSG_ENVELOPED_ENCODE_INFO {.bycopy.} = object
cbSize: uint32
hCryptProv: uint
ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER
pvEncryptionAuxInfo: pointer
cRecipients: uint32
rgpRecipients: pointer
CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO {.bycopy.} = object
cbSize: uint32
SignedInfo: CMSG_SIGNED_ENCODE_INFO
EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFOstruct CMSG_SIGNED_ENCODE_INFO
{
uint cbSize;
uint cSigners;
void* rgSigners;
uint cCertEncoded;
void* rgCertEncoded;
uint cCrlEncoded;
void* rgCrlEncoded;
}
struct CRYPT_INTEGER_BLOB
{
uint cbData;
void* pbData;
}
struct CRYPT_ALGORITHM_IDENTIFIER
{
void* pszObjId;
CRYPT_INTEGER_BLOB Parameters;
}
struct CMSG_ENVELOPED_ENCODE_INFO
{
uint cbSize;
size_t hCryptProv;
CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm;
void* pvEncryptionAuxInfo;
uint cRecipients;
void* rgpRecipients;
}
struct CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
{
uint cbSize;
CMSG_SIGNED_ENCODE_INFO SignedInfo;
CMSG_ENVELOPED_ENCODE_INFO EnvelopedInfo;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO サイズ: 64 バイト(x86)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; SignedInfo : CMSG_SIGNED_ENCODE_INFO (+4, 28byte) varptr(st)+4 を基点に操作(28byte:入れ子/配列)
; EnvelopedInfo : CMSG_ENVELOPED_ENCODE_INFO (+32, 32byte) varptr(st)+32 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO サイズ: 120 バイト(x64)
dim st, 30 ; 4byte整数×30(構造体サイズ 120 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; SignedInfo : CMSG_SIGNED_ENCODE_INFO (+8, 48byte) varptr(st)+8 を基点に操作(48byte:入れ子/配列)
; EnvelopedInfo : CMSG_ENVELOPED_ENCODE_INFO (+56, 64byte) varptr(st)+56 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CMSG_SIGNED_ENCODE_INFO
#field int cbSize
#field int cSigners
#field intptr rgSigners
#field int cCertEncoded
#field intptr rgCertEncoded
#field int cCrlEncoded
#field intptr rgCrlEncoded
#endstruct
#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_ENVELOPED_ENCODE_INFO
#field int cbSize
#field intptr hCryptProv
#field CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm
#field intptr pvEncryptionAuxInfo
#field int cRecipients
#field intptr rgpRecipients
#endstruct
#defstruct global CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
#field int cbSize
#field CMSG_SIGNED_ENCODE_INFO SignedInfo
#field CMSG_ENVELOPED_ENCODE_INFO EnvelopedInfo
#endstruct
stdim st, CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize