ホーム › Security.Cryptography › BCRYPT_DSA_PARAMETER_HEADER
BCRYPT_DSA_PARAMETER_HEADER
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbLength | DWORD | 4 | +0 | +0 | この構造体と、メモリ上でこの構造体の直後に続くバッファーとの合計サイズ (バイト単位) です。 |
| dwMagic | DWORD | 4 | +4 | +4 | キーのマジック値です。 このメンバーは次の値でなければなりません。 BCRYPT_DSA_PARAMETERS_MAGIC (0x4d505344) |
| cbKeyLength | DWORD | 4 | +8 | +8 | この構造体が適用されるキーのサイズ (バイト単位) です。 |
| Count | BYTE | 4 | +12 | +12 | シードから素数 q を生成するために実行された反復回数です。 |
| Seed | BYTE | 20 | +16 | +16 | q の生成に使用された、ビッグエンディアン形式のシード値です。 |
| q | BYTE | 20 | +36 | +36 | 160 ビットの素因数です (ビッグエンディアン形式)。 |
公式ドキュメント
BCRYPT_DSA_PARAMETER_HEADER 構造体は、DSA キーを生成するための情報を格納した デジタル署名アルゴリズム (DSA) パラメーター BLOB のヘッダーとして使用されます。この構造体は、BCryptSetProperty 関数の BCRYPT_DSA_PARAMETERS プロパティとともに使用されます。
解説(Remarks)
BCryptGenerateKeyPair の呼び出しで作成された DSA キーのパラメーターを設定するために、この構造体を BCryptSetProperty の呼び出しで使用する場合、(cbKeyLength*8) は事前に設定された dwLength と等しくなければなりません。
この構造体は、長さが 512 ビット以上 1024 ビット以下の DSA キーに適用されます。
この構造体は、より大きなバッファーのヘッダーとして使用されます。DSA パラメーター BLOB は、連続したメモリ上で次の形式になります。Modulus と Generator はビッグエンディアン形式です。
BCRYPT_DSA_PARAMETER_HEADER
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)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// BCRYPT_DSA_PARAMETER_HEADER (x64 56 / x86 56 バイト)
typedef struct BCRYPT_DSA_PARAMETER_HEADER {
DWORD cbLength;
DWORD dwMagic;
DWORD cbKeyLength;
BYTE Count[4];
BYTE Seed[20];
BYTE q[20];
} BCRYPT_DSA_PARAMETER_HEADER;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BCRYPT_DSA_PARAMETER_HEADER
{
public uint cbLength;
public uint dwMagic;
public uint cbKeyLength;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] Count;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public byte[] Seed;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public byte[] q;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BCRYPT_DSA_PARAMETER_HEADER
Public cbLength As UInteger
Public dwMagic As UInteger
Public cbKeyLength As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public Count() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> Public Seed() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> Public q() As Byte
End Structureimport ctypes
from ctypes import wintypes
class BCRYPT_DSA_PARAMETER_HEADER(ctypes.Structure):
_fields_ = [
("cbLength", wintypes.DWORD),
("dwMagic", wintypes.DWORD),
("cbKeyLength", wintypes.DWORD),
("Count", ctypes.c_ubyte * 4),
("Seed", ctypes.c_ubyte * 20),
("q", ctypes.c_ubyte * 20),
]#[repr(C)]
pub struct BCRYPT_DSA_PARAMETER_HEADER {
pub cbLength: u32,
pub dwMagic: u32,
pub cbKeyLength: u32,
pub Count: [u8; 4],
pub Seed: [u8; 20],
pub q: [u8; 20],
}import "golang.org/x/sys/windows"
type BCRYPT_DSA_PARAMETER_HEADER struct {
cbLength uint32
dwMagic uint32
cbKeyLength uint32
Count [4]byte
Seed [20]byte
q [20]byte
}type
BCRYPT_DSA_PARAMETER_HEADER = record
cbLength: DWORD;
dwMagic: DWORD;
cbKeyLength: DWORD;
Count: array[0..3] of Byte;
Seed: array[0..19] of Byte;
q: array[0..19] of Byte;
end;const BCRYPT_DSA_PARAMETER_HEADER = extern struct {
cbLength: u32,
dwMagic: u32,
cbKeyLength: u32,
Count: [4]u8,
Seed: [20]u8,
q: [20]u8,
};type
BCRYPT_DSA_PARAMETER_HEADER {.bycopy.} = object
cbLength: uint32
dwMagic: uint32
cbKeyLength: uint32
Count: array[4, uint8]
Seed: array[20, uint8]
q: array[20, uint8]struct BCRYPT_DSA_PARAMETER_HEADER
{
uint cbLength;
uint dwMagic;
uint cbKeyLength;
ubyte[4] Count;
ubyte[20] Seed;
ubyte[20] q;
}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 サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 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 も可)
; Count : BYTE (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; Seed : BYTE (+16, 20byte) varptr(st)+16 を基点に操作(20byte:入れ子/配列)
; q : BYTE (+36, 20byte) varptr(st)+36 を基点に操作(20byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BCRYPT_DSA_PARAMETER_HEADER
#field int cbLength
#field int dwMagic
#field int cbKeyLength
#field byte Count 4
#field byte Seed 20
#field byte q 20
#endstruct
stdim st, BCRYPT_DSA_PARAMETER_HEADER ; NSTRUCT 変数を確保
st->cbLength = 100
mes "cbLength=" + st->cbLength