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

BCRYPT_KEY_LENGTHS_STRUCT

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

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

フィールド

フィールドサイズx64x86説明
dwMinLengthDWORD4+0+0鍵の最小長 (ビット単位)。
dwMaxLengthDWORD4+4+4鍵の最大長 (ビット単位)。
dwIncrementDWORD4+8+8dwMinLengthdwMaxLength の間で鍵サイズを増分できるビット数。

公式ドキュメント

BCRYPT_KEY_LENGTHS_STRUCT 構造体は、プロバイダーがサポートする鍵サイズの範囲を定義します。この構造体は BCRYPT_KEY_LENGTHS プロパティと共に使用されます。

この構造体は、認証タグの最小サイズ、最大サイズ、および増分サイズを格納するために BCRYPT_AUTH_TAG_LENGTH プロパティと共に使用されることもあります。

解説(Remarks)

鍵サイズは、最小値と最大値を含む範囲として示され、増分値で区切られます。たとえば、最小鍵サイズが 8 ビット、最大鍵サイズが 16 ビット、増分が 2 ビットの場合、プロバイダーは 8、10、12、14、16 ビットの鍵サイズをサポートします。

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

各言語での定義

#include <windows.h>

// BCRYPT_KEY_LENGTHS_STRUCT  (x64 12 / x86 12 バイト)
typedef struct BCRYPT_KEY_LENGTHS_STRUCT {
    DWORD dwMinLength;
    DWORD dwMaxLength;
    DWORD dwIncrement;
} BCRYPT_KEY_LENGTHS_STRUCT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BCRYPT_KEY_LENGTHS_STRUCT
{
    public uint dwMinLength;
    public uint dwMaxLength;
    public uint dwIncrement;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BCRYPT_KEY_LENGTHS_STRUCT
    Public dwMinLength As UInteger
    Public dwMaxLength As UInteger
    Public dwIncrement As UInteger
End Structure
import ctypes
from ctypes import wintypes

class BCRYPT_KEY_LENGTHS_STRUCT(ctypes.Structure):
    _fields_ = [
        ("dwMinLength", wintypes.DWORD),
        ("dwMaxLength", wintypes.DWORD),
        ("dwIncrement", wintypes.DWORD),
    ]
#[repr(C)]
pub struct BCRYPT_KEY_LENGTHS_STRUCT {
    pub dwMinLength: u32,
    pub dwMaxLength: u32,
    pub dwIncrement: u32,
}
import "golang.org/x/sys/windows"

type BCRYPT_KEY_LENGTHS_STRUCT struct {
	dwMinLength uint32
	dwMaxLength uint32
	dwIncrement uint32
}
type
  BCRYPT_KEY_LENGTHS_STRUCT = record
    dwMinLength: DWORD;
    dwMaxLength: DWORD;
    dwIncrement: DWORD;
  end;
const BCRYPT_KEY_LENGTHS_STRUCT = extern struct {
    dwMinLength: u32,
    dwMaxLength: u32,
    dwIncrement: u32,
};
type
  BCRYPT_KEY_LENGTHS_STRUCT {.bycopy.} = object
    dwMinLength: uint32
    dwMaxLength: uint32
    dwIncrement: uint32
struct BCRYPT_KEY_LENGTHS_STRUCT
{
    uint dwMinLength;
    uint dwMaxLength;
    uint dwIncrement;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BCRYPT_KEY_LENGTHS_STRUCT サイズ: 12 バイト(x64)
dim st, 3    ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; dwMinLength : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwMaxLength : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwIncrement : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BCRYPT_KEY_LENGTHS_STRUCT
    #field int dwMinLength
    #field int dwMaxLength
    #field int dwIncrement
#endstruct

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