Win32 API 日本語リファレンス
ホームSecurity.Cryptography › BCRYPT_DSA_KEY_BLOB_V2

BCRYPT_DSA_KEY_BLOB_V2

構造体
サイズx64: 28 バイト / x86: 28 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwMagicBCRYPT_DSA_MAGIC4+0+0

この構造体が表すキーの種類を決定します。次のいずれかの値を指定できます。

意味
BCRYPT_DSA_PUBLIC_MAGIC_V2
0x32425044
この構造体は DSA 公開キーを表します。
BCRYPT_DSA_PRIVATE_MAGIC_V2
0x32565044
この構造体は DSA 秘密キーを表します。
cbKeyDWORD4+4+4キーの長さ (バイト単位)。
hashAlgorithmHASHALGORITHM_ENUM4+8+8使用するハッシュアルゴリズムを指定する HASHALGORITHM_ENUM 列挙型の値。
standardVersionDSAFIPSVERSION_ENUM4+12+12適用する連邦情報処理標準 (FIPS) を指定する DSAFIPSVERSION_ENUM 列挙型の値。
cbSeedLengthDWORD4+16+16素数 q の生成に使用されたシードの長さ (バイト単位)。
cbGroupSizeDWORD4+20+20素数 q のサイズ (バイト単位)。現在、キーの長さが 1024 ビットを超える場合、q の長さは 32 バイトです。
CountBYTE4+24+24シードから素数 q を生成するために実行された反復回数。詳細については、NIST 標準 FIPS186-3 を参照してください。

公式ドキュメント

BCRYPT_DSA_KEY_BLOB_V2 構造体は、メモリー内の デジタル署名アルゴリズム (DSA) 公開キー または 秘密キー BLOB のヘッダーとして使用されます。

解説(Remarks)

この構造体は、長さが 1024 ビットを超え 3072 ビット以下の DSA キーに適用されます。

この構造体は、より大きなバッファーのヘッダーとして使用されます。DSA 公開キー BLOB (BCRYPT_DSA_PUBLIC_BLOB) は、連続したメモリー内で次の形式になります。Seed、q、Modulus、Generator、Public の各数値はビッグエンディアン形式です。


BCRYPT_DSA_KEY_BLOB_V2
Seed[cbSeedLength]  // Big-endian.
q[cbGroupSize]      // Big-endian.
Modulus[cbKey]      // Big-endian.
Generator[cbKey]    // Big-endian.
Public[cbKey]       // Big-endian.

DSA 秘密キー BLOB (BCRYPT_DSA_PRIVATE_BLOB) は、連続したメモリー内で次の形式になります。Seed、q、Modulus、Generator、Public、PrivateExponent の各数値はビッグエンディアン形式です。


BCRYPT_DSA_KEY_BLOB_V2
Seed[cbSeedLength]              // Big-endian.
q[cbGroupSize]                  // Big-endian.
Modulus[cbKey]                  // Big-endian.
Generator[cbKey]                // Big-endian.
Public[cbKey]                   // Big-endian.
PrivateExponent[cbGroupSize]    // Big-endian.
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#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 Structure
import 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