ホーム › Security.Cryptography › CARD_IMPORT_KEYPAIR
CARD_IMPORT_KEYPAIR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwVersion | DWORD | 4 | +0 | +0 | 鍵ペアインポート構造体のバージョン番号。 |
| bContainerIndex | BYTE | 1 | +4 | +4 | インポート先鍵コンテナのインデックス。 |
| PinId | DWORD | 4 | +8 | +8 | 操作に用いるPINの識別子。 |
| dwKeySpec | DWORD | 4 | +12 | +12 | 鍵の種別(署名用/交換用)を示す値。 |
| dwKeySize | DWORD | 4 | +16 | +16 | インポートする鍵の鍵長(ビット)。 |
| cbInput | DWORD | 4 | +20 | +20 | 入力鍵データのバイト長。 |
| pbInput | BYTE | 1 | +24 | +24 | 入力鍵データの先頭バイト(可変長配列の起点)。 |
各言語での定義
#include <windows.h>
// CARD_IMPORT_KEYPAIR (x64 28 / x86 28 バイト)
typedef struct CARD_IMPORT_KEYPAIR {
DWORD dwVersion;
BYTE bContainerIndex;
DWORD PinId;
DWORD dwKeySpec;
DWORD dwKeySize;
DWORD cbInput;
BYTE pbInput[1];
} CARD_IMPORT_KEYPAIR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CARD_IMPORT_KEYPAIR
{
public uint dwVersion;
public byte bContainerIndex;
public uint PinId;
public uint dwKeySpec;
public uint dwKeySize;
public uint cbInput;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] pbInput;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CARD_IMPORT_KEYPAIR
Public dwVersion As UInteger
Public bContainerIndex As Byte
Public PinId As UInteger
Public dwKeySpec As UInteger
Public dwKeySize As UInteger
Public cbInput As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public pbInput() As Byte
End Structureimport ctypes
from ctypes import wintypes
class CARD_IMPORT_KEYPAIR(ctypes.Structure):
_fields_ = [
("dwVersion", wintypes.DWORD),
("bContainerIndex", ctypes.c_ubyte),
("PinId", wintypes.DWORD),
("dwKeySpec", wintypes.DWORD),
("dwKeySize", wintypes.DWORD),
("cbInput", wintypes.DWORD),
("pbInput", ctypes.c_ubyte * 1),
]#[repr(C)]
pub struct CARD_IMPORT_KEYPAIR {
pub dwVersion: u32,
pub bContainerIndex: u8,
pub PinId: u32,
pub dwKeySpec: u32,
pub dwKeySize: u32,
pub cbInput: u32,
pub pbInput: [u8; 1],
}import "golang.org/x/sys/windows"
type CARD_IMPORT_KEYPAIR struct {
dwVersion uint32
bContainerIndex byte
PinId uint32
dwKeySpec uint32
dwKeySize uint32
cbInput uint32
pbInput [1]byte
}type
CARD_IMPORT_KEYPAIR = record
dwVersion: DWORD;
bContainerIndex: Byte;
PinId: DWORD;
dwKeySpec: DWORD;
dwKeySize: DWORD;
cbInput: DWORD;
pbInput: array[0..0] of Byte;
end;const CARD_IMPORT_KEYPAIR = extern struct {
dwVersion: u32,
bContainerIndex: u8,
PinId: u32,
dwKeySpec: u32,
dwKeySize: u32,
cbInput: u32,
pbInput: [1]u8,
};type
CARD_IMPORT_KEYPAIR {.bycopy.} = object
dwVersion: uint32
bContainerIndex: uint8
PinId: uint32
dwKeySpec: uint32
dwKeySize: uint32
cbInput: uint32
pbInput: array[1, uint8]struct CARD_IMPORT_KEYPAIR
{
uint dwVersion;
ubyte bContainerIndex;
uint PinId;
uint dwKeySpec;
uint dwKeySize;
uint cbInput;
ubyte[1] pbInput;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CARD_IMPORT_KEYPAIR サイズ: 28 バイト(x64)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; bContainerIndex : BYTE (+4, 1byte) poke st,4,値 / 値 = peek(st,4)
; PinId : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwKeySpec : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; dwKeySize : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cbInput : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; pbInput : BYTE (+24, 1byte) varptr(st)+24 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CARD_IMPORT_KEYPAIR
#field int dwVersion
#field byte bContainerIndex
#field int PinId
#field int dwKeySpec
#field int dwKeySize
#field int cbInput
#field byte pbInput 1
#endstruct
stdim st, CARD_IMPORT_KEYPAIR ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion