ホーム › Security.Cryptography › BCRYPT_DSA_KEY_BLOB_V2
BCRYPT_DSA_KEY_BLOB_V2
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwMagic | BCRYPT_DSA_MAGIC | 4 | +0 | +0 | BLOB種別を示すマジック値。公開鍵はBCRYPT_DSA_PUBLIC_MAGIC_V2、秘密鍵はBCRYPT_DSA_PRIVATE_MAGIC_V2を取る。 |
| cbKey | DWORD | 4 | +4 | +4 | 鍵のモジュラスpのバイト長。1024超の鍵長に対応したV2形式で用いられる。 |
| hashAlgorithm | HASHALGORITHM_ENUM | 4 | +8 | +8 | 鍵生成に用いるハッシュアルゴリズムの種別。SHA-1/SHA-256/SHA-512のいずれかを示す列挙値。 |
| standardVersion | DSAFIPSVERSION_ENUM | 4 | +12 | +12 | 準拠するDSA FIPS標準の版を示す列挙値。FIPS 186-2または186-3を表す。 |
| cbSeedLength | DWORD | 4 | +16 | +16 | 鍵生成シードのバイト長。BLOB末尾のSeedデータの長さを示す。 |
| cbGroupSize | DWORD | 4 | +20 | +20 | 群位数qのバイト長。素数qの大きさを表す。 |
| Count | BYTE | 4 | +24 | +24 | 鍵生成カウンタ(4バイト、ビッグエンディアン)。素数生成時の試行回数を保持する。 |
各言語での定義
#include <windows.h>
// BCRYPT_DSA_KEY_BLOB_V2 (x64 28 / x86 28 バイト)
typedef struct BCRYPT_DSA_KEY_BLOB_V2 {
BCRYPT_DSA_MAGIC dwMagic;
DWORD cbKey;
HASHALGORITHM_ENUM hashAlgorithm;
DSAFIPSVERSION_ENUM standardVersion;
DWORD cbSeedLength;
DWORD cbGroupSize;
BYTE Count[4];
} BCRYPT_DSA_KEY_BLOB_V2;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BCRYPT_DSA_KEY_BLOB_V2
{
public uint dwMagic;
public uint cbKey;
public int hashAlgorithm;
public int standardVersion;
public uint cbSeedLength;
public uint cbGroupSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] Count;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BCRYPT_DSA_KEY_BLOB_V2
Public dwMagic As UInteger
Public cbKey As UInteger
Public hashAlgorithm As Integer
Public standardVersion As Integer
Public cbSeedLength As UInteger
Public cbGroupSize As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public Count() As Byte
End Structureimport ctypes
from ctypes import wintypes
class BCRYPT_DSA_KEY_BLOB_V2(ctypes.Structure):
_fields_ = [
("dwMagic", wintypes.DWORD),
("cbKey", wintypes.DWORD),
("hashAlgorithm", ctypes.c_int),
("standardVersion", ctypes.c_int),
("cbSeedLength", wintypes.DWORD),
("cbGroupSize", wintypes.DWORD),
("Count", ctypes.c_ubyte * 4),
]#[repr(C)]
pub struct BCRYPT_DSA_KEY_BLOB_V2 {
pub dwMagic: u32,
pub cbKey: u32,
pub hashAlgorithm: i32,
pub standardVersion: i32,
pub cbSeedLength: u32,
pub cbGroupSize: u32,
pub Count: [u8; 4],
}import "golang.org/x/sys/windows"
type BCRYPT_DSA_KEY_BLOB_V2 struct {
dwMagic uint32
cbKey uint32
hashAlgorithm int32
standardVersion int32
cbSeedLength uint32
cbGroupSize uint32
Count [4]byte
}type
BCRYPT_DSA_KEY_BLOB_V2 = record
dwMagic: DWORD;
cbKey: DWORD;
hashAlgorithm: Integer;
standardVersion: Integer;
cbSeedLength: DWORD;
cbGroupSize: DWORD;
Count: array[0..3] of Byte;
end;const BCRYPT_DSA_KEY_BLOB_V2 = extern struct {
dwMagic: u32,
cbKey: u32,
hashAlgorithm: i32,
standardVersion: i32,
cbSeedLength: u32,
cbGroupSize: u32,
Count: [4]u8,
};type
BCRYPT_DSA_KEY_BLOB_V2 {.bycopy.} = object
dwMagic: uint32
cbKey: uint32
hashAlgorithm: int32
standardVersion: int32
cbSeedLength: uint32
cbGroupSize: uint32
Count: array[4, uint8]struct BCRYPT_DSA_KEY_BLOB_V2
{
uint dwMagic;
uint cbKey;
int hashAlgorithm;
int standardVersion;
uint cbSeedLength;
uint cbGroupSize;
ubyte[4] Count;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BCRYPT_DSA_KEY_BLOB_V2 サイズ: 28 バイト(x64)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; dwMagic : BCRYPT_DSA_MAGIC (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; cbKey : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; hashAlgorithm : HASHALGORITHM_ENUM (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; standardVersion : DSAFIPSVERSION_ENUM (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cbSeedLength : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cbGroupSize : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; Count : BYTE (+24, 4byte) varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BCRYPT_DSA_KEY_BLOB_V2
#field int dwMagic
#field int cbKey
#field int hashAlgorithm
#field int standardVersion
#field int cbSeedLength
#field int cbGroupSize
#field byte Count 4
#endstruct
stdim st, BCRYPT_DSA_KEY_BLOB_V2 ; NSTRUCT 変数を確保
st->dwMagic = 100
mes "dwMagic=" + st->dwMagic