ホーム › Security.Cryptography › BCRYPT_RSAKEY_BLOB
BCRYPT_RSAKEY_BLOB
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Magic | BCRYPT_RSAKEY_BLOB_MAGIC | 4 | +0 | +0 | RSA鍵BLOBの種別を示すマジック値(公開/秘密/フル)。 |
| BitLength | DWORD | 4 | +4 | +4 | RSAモジュラスのビット長。 |
| cbPublicExp | DWORD | 4 | +8 | +8 | 公開指数のバイト長。 |
| cbModulus | DWORD | 4 | +12 | +12 | モジュラスのバイト長。 |
| cbPrime1 | DWORD | 4 | +16 | +16 | 第1素数Pのバイト長。秘密鍵で有効。 |
| cbPrime2 | DWORD | 4 | +20 | +20 | 第2素数Qのバイト長。秘密鍵で有効。 |
各言語での定義
#include <windows.h>
// BCRYPT_RSAKEY_BLOB (x64 24 / x86 24 バイト)
typedef struct BCRYPT_RSAKEY_BLOB {
BCRYPT_RSAKEY_BLOB_MAGIC Magic;
DWORD BitLength;
DWORD cbPublicExp;
DWORD cbModulus;
DWORD cbPrime1;
DWORD cbPrime2;
} BCRYPT_RSAKEY_BLOB;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BCRYPT_RSAKEY_BLOB
{
public uint Magic;
public uint BitLength;
public uint cbPublicExp;
public uint cbModulus;
public uint cbPrime1;
public uint cbPrime2;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BCRYPT_RSAKEY_BLOB
Public Magic As UInteger
Public BitLength As UInteger
Public cbPublicExp As UInteger
Public cbModulus As UInteger
Public cbPrime1 As UInteger
Public cbPrime2 As UInteger
End Structureimport ctypes
from ctypes import wintypes
class BCRYPT_RSAKEY_BLOB(ctypes.Structure):
_fields_ = [
("Magic", wintypes.DWORD),
("BitLength", wintypes.DWORD),
("cbPublicExp", wintypes.DWORD),
("cbModulus", wintypes.DWORD),
("cbPrime1", wintypes.DWORD),
("cbPrime2", wintypes.DWORD),
]#[repr(C)]
pub struct BCRYPT_RSAKEY_BLOB {
pub Magic: u32,
pub BitLength: u32,
pub cbPublicExp: u32,
pub cbModulus: u32,
pub cbPrime1: u32,
pub cbPrime2: u32,
}import "golang.org/x/sys/windows"
type BCRYPT_RSAKEY_BLOB struct {
Magic uint32
BitLength uint32
cbPublicExp uint32
cbModulus uint32
cbPrime1 uint32
cbPrime2 uint32
}type
BCRYPT_RSAKEY_BLOB = record
Magic: DWORD;
BitLength: DWORD;
cbPublicExp: DWORD;
cbModulus: DWORD;
cbPrime1: DWORD;
cbPrime2: DWORD;
end;const BCRYPT_RSAKEY_BLOB = extern struct {
Magic: u32,
BitLength: u32,
cbPublicExp: u32,
cbModulus: u32,
cbPrime1: u32,
cbPrime2: u32,
};type
BCRYPT_RSAKEY_BLOB {.bycopy.} = object
Magic: uint32
BitLength: uint32
cbPublicExp: uint32
cbModulus: uint32
cbPrime1: uint32
cbPrime2: uint32struct BCRYPT_RSAKEY_BLOB
{
uint Magic;
uint BitLength;
uint cbPublicExp;
uint cbModulus;
uint cbPrime1;
uint cbPrime2;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BCRYPT_RSAKEY_BLOB サイズ: 24 バイト(x64)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Magic : BCRYPT_RSAKEY_BLOB_MAGIC (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; BitLength : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; cbPublicExp : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; cbModulus : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cbPrime1 : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cbPrime2 : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BCRYPT_RSAKEY_BLOB
#field int Magic
#field int BitLength
#field int cbPublicExp
#field int cbModulus
#field int cbPrime1
#field int cbPrime2
#endstruct
stdim st, BCRYPT_RSAKEY_BLOB ; NSTRUCT 変数を確保
st->Magic = 100
mes "Magic=" + st->Magic