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

BCRYPT_DSA_PARAMETER_HEADER_V2

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

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

フィールド

フィールドサイズx64x86説明
cbLengthDWORD4+0+0この構造体と、メモリ上でこの構造体の直後に続くバッファーとの合計サイズ (バイト単位)。
dwMagicDWORD4+4+4

キーのマジック値。

このメンバーは次の値でなければなりません。

BCRYPT_DSA_PARAMETERS_MAGIC_V2 (0x324d5044)

cbKeyLengthDWORD4+8+8この構造体が適用されるキーのサイズ (バイト単位)。
hashAlgorithmHASHALGORITHM_ENUM4+12+12使用するハッシュアルゴリズムを指定する HASHALGORITHM_ENUM 列挙型の値。
standardVersionDSAFIPSVERSION_ENUM4+16+16適用する Federal Information Processing Standard (FIPS) を指定する DSAFIPSVERSION_ENUM 列挙型の値。
cbSeedLengthDWORD4+20+20素数 q の生成に使用されたシードの長さ (バイト単位)。
cbGroupSizeDWORD4+24+24素数 q のサイズ。現在、キーの長さが 1024 ビットを超える場合、q は 32 バイト長です。
CountBYTE4+28+28シードから素数 q を生成するために実行された反復回数。詳細については、NIST 標準 FIPS186-3 を参照してください。

公式ドキュメント

BCRYPT_DSA_PARAMETER_HEADER_V2 構造体は、DSA キーを生成するための情報を格納する Digital Signature Algorithm (DSA) パラメーター BLOB のヘッダーとして使用されます。この構造体は、BCryptSetProperty 関数の BCRYPT_DSA_PARAMETERS プロパティと共に使用されます。

解説(Remarks)

BCryptGenerateKeyPair 呼び出しで作成された DSA キーのパラメーターを設定するために、この構造体を BCryptSetProperty 呼び出しで使用する場合、(cbKeyLength*8) は事前に設定された dwLength と等しくなければなりません。

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

この構造体は、より大きなバッファーのヘッダーとして使用されます。DSA パラメーター BLOB は、連続したメモリ上で次の形式になります。Seed、q、Modulus、Generator はビッグエンディアン形式です。


BCRYPT_DSA_PARAMETER_HEADER_V2
Seed[cbSeedLength]      // Big-endian.
q[cbGroupSize]          // Big-endian.
Modulus[cbKeyLength]    // Big-endian.
Generator[cbKeyLength]  // 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_PARAMETER_HEADER_V2  (x64 32 / x86 32 バイト)
typedef struct BCRYPT_DSA_PARAMETER_HEADER_V2 {
    DWORD cbLength;
    DWORD dwMagic;
    DWORD cbKeyLength;
    HASHALGORITHM_ENUM hashAlgorithm;
    DSAFIPSVERSION_ENUM standardVersion;
    DWORD cbSeedLength;
    DWORD cbGroupSize;
    BYTE Count[4];
} BCRYPT_DSA_PARAMETER_HEADER_V2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BCRYPT_DSA_PARAMETER_HEADER_V2
{
    public uint cbLength;
    public uint dwMagic;
    public uint cbKeyLength;
    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_PARAMETER_HEADER_V2
    Public cbLength As UInteger
    Public dwMagic As UInteger
    Public cbKeyLength 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_PARAMETER_HEADER_V2(ctypes.Structure):
    _fields_ = [
        ("cbLength", wintypes.DWORD),
        ("dwMagic", wintypes.DWORD),
        ("cbKeyLength", 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_PARAMETER_HEADER_V2 {
    pub cbLength: u32,
    pub dwMagic: u32,
    pub cbKeyLength: 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_PARAMETER_HEADER_V2 struct {
	cbLength uint32
	dwMagic uint32
	cbKeyLength uint32
	hashAlgorithm int32
	standardVersion int32
	cbSeedLength uint32
	cbGroupSize uint32
	Count [4]byte
}
type
  BCRYPT_DSA_PARAMETER_HEADER_V2 = record
    cbLength: DWORD;
    dwMagic: DWORD;
    cbKeyLength: DWORD;
    hashAlgorithm: Integer;
    standardVersion: Integer;
    cbSeedLength: DWORD;
    cbGroupSize: DWORD;
    Count: array[0..3] of Byte;
  end;
const BCRYPT_DSA_PARAMETER_HEADER_V2 = extern struct {
    cbLength: u32,
    dwMagic: u32,
    cbKeyLength: u32,
    hashAlgorithm: i32,
    standardVersion: i32,
    cbSeedLength: u32,
    cbGroupSize: u32,
    Count: [4]u8,
};
type
  BCRYPT_DSA_PARAMETER_HEADER_V2 {.bycopy.} = object
    cbLength: uint32
    dwMagic: uint32
    cbKeyLength: uint32
    hashAlgorithm: int32
    standardVersion: int32
    cbSeedLength: uint32
    cbGroupSize: uint32
    Count: array[4, uint8]
struct BCRYPT_DSA_PARAMETER_HEADER_V2
{
    uint cbLength;
    uint dwMagic;
    uint cbKeyLength;
    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_PARAMETER_HEADER_V2 サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; cbLength : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwMagic : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; cbKeyLength : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; hashAlgorithm : HASHALGORITHM_ENUM (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; standardVersion : DSAFIPSVERSION_ENUM (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; cbSeedLength : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; cbGroupSize : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; Count : BYTE (+28, 4byte)  varptr(st)+28 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BCRYPT_DSA_PARAMETER_HEADER_V2
    #field int cbLength
    #field int dwMagic
    #field int cbKeyLength
    #field int hashAlgorithm
    #field int standardVersion
    #field int cbSeedLength
    #field int cbGroupSize
    #field byte Count 4
#endstruct

stdim st, BCRYPT_DSA_PARAMETER_HEADER_V2        ; NSTRUCT 変数を確保
st->cbLength = 100
mes "cbLength=" + st->cbLength