Win32 API 日本語リファレンス
ホームSystem.Ioctl › STORAGE_CRYPTO_DESCRIPTOR

STORAGE_CRYPTO_DESCRIPTOR

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

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号。
SizeDWORD4+4+4この構造体全体のサイズをバイト単位で示す。
NumKeysSupportedDWORD4+8+8デバイスがサポートする暗号鍵の総数。
NumCryptoCapabilitiesDWORD4+12+12CryptoCapabilities配列に含まれる暗号機能エントリ数。
CryptoCapabilitiesSTORAGE_CRYPTO_CAPABILITY24+16+16STORAGE_CRYPTO_CAPABILITY構造体の可変長配列。各暗号機能を保持する。

各言語での定義

#include <windows.h>

// STORAGE_CRYPTO_CAPABILITY  (x64 24 / x86 24 バイト)
typedef struct STORAGE_CRYPTO_CAPABILITY {
    DWORD Version;
    DWORD Size;
    DWORD CryptoCapabilityIndex;
    STORAGE_CRYPTO_ALGORITHM_ID AlgorithmId;
    STORAGE_CRYPTO_KEY_SIZE KeySize;
    DWORD DataUnitSizeBitmask;
} STORAGE_CRYPTO_CAPABILITY;

// STORAGE_CRYPTO_DESCRIPTOR  (x64 40 / x86 40 バイト)
typedef struct STORAGE_CRYPTO_DESCRIPTOR {
    DWORD Version;
    DWORD Size;
    DWORD NumKeysSupported;
    DWORD NumCryptoCapabilities;
    STORAGE_CRYPTO_CAPABILITY CryptoCapabilities[1];
} STORAGE_CRYPTO_DESCRIPTOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_CRYPTO_CAPABILITY
{
    public uint Version;
    public uint Size;
    public uint CryptoCapabilityIndex;
    public int AlgorithmId;
    public int KeySize;
    public uint DataUnitSizeBitmask;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_CRYPTO_DESCRIPTOR
{
    public uint Version;
    public uint Size;
    public uint NumKeysSupported;
    public uint NumCryptoCapabilities;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public STORAGE_CRYPTO_CAPABILITY[] CryptoCapabilities;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_CRYPTO_CAPABILITY
    Public Version As UInteger
    Public Size As UInteger
    Public CryptoCapabilityIndex As UInteger
    Public AlgorithmId As Integer
    Public KeySize As Integer
    Public DataUnitSizeBitmask As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_CRYPTO_DESCRIPTOR
    Public Version As UInteger
    Public Size As UInteger
    Public NumKeysSupported As UInteger
    Public NumCryptoCapabilities As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public CryptoCapabilities() As STORAGE_CRYPTO_CAPABILITY
End Structure
import ctypes
from ctypes import wintypes

class STORAGE_CRYPTO_CAPABILITY(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("CryptoCapabilityIndex", wintypes.DWORD),
        ("AlgorithmId", ctypes.c_int),
        ("KeySize", ctypes.c_int),
        ("DataUnitSizeBitmask", wintypes.DWORD),
    ]

class STORAGE_CRYPTO_DESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("NumKeysSupported", wintypes.DWORD),
        ("NumCryptoCapabilities", wintypes.DWORD),
        ("CryptoCapabilities", STORAGE_CRYPTO_CAPABILITY * 1),
    ]
#[repr(C)]
pub struct STORAGE_CRYPTO_CAPABILITY {
    pub Version: u32,
    pub Size: u32,
    pub CryptoCapabilityIndex: u32,
    pub AlgorithmId: i32,
    pub KeySize: i32,
    pub DataUnitSizeBitmask: u32,
}

#[repr(C)]
pub struct STORAGE_CRYPTO_DESCRIPTOR {
    pub Version: u32,
    pub Size: u32,
    pub NumKeysSupported: u32,
    pub NumCryptoCapabilities: u32,
    pub CryptoCapabilities: [STORAGE_CRYPTO_CAPABILITY; 1],
}
import "golang.org/x/sys/windows"

type STORAGE_CRYPTO_CAPABILITY struct {
	Version uint32
	Size uint32
	CryptoCapabilityIndex uint32
	AlgorithmId int32
	KeySize int32
	DataUnitSizeBitmask uint32
}

type STORAGE_CRYPTO_DESCRIPTOR struct {
	Version uint32
	Size uint32
	NumKeysSupported uint32
	NumCryptoCapabilities uint32
	CryptoCapabilities [1]STORAGE_CRYPTO_CAPABILITY
}
type
  STORAGE_CRYPTO_CAPABILITY = record
    Version: DWORD;
    Size: DWORD;
    CryptoCapabilityIndex: DWORD;
    AlgorithmId: Integer;
    KeySize: Integer;
    DataUnitSizeBitmask: DWORD;
  end;

  STORAGE_CRYPTO_DESCRIPTOR = record
    Version: DWORD;
    Size: DWORD;
    NumKeysSupported: DWORD;
    NumCryptoCapabilities: DWORD;
    CryptoCapabilities: array[0..0] of STORAGE_CRYPTO_CAPABILITY;
  end;
const STORAGE_CRYPTO_CAPABILITY = extern struct {
    Version: u32,
    Size: u32,
    CryptoCapabilityIndex: u32,
    AlgorithmId: i32,
    KeySize: i32,
    DataUnitSizeBitmask: u32,
};

const STORAGE_CRYPTO_DESCRIPTOR = extern struct {
    Version: u32,
    Size: u32,
    NumKeysSupported: u32,
    NumCryptoCapabilities: u32,
    CryptoCapabilities: [1]STORAGE_CRYPTO_CAPABILITY,
};
type
  STORAGE_CRYPTO_CAPABILITY {.bycopy.} = object
    Version: uint32
    Size: uint32
    CryptoCapabilityIndex: uint32
    AlgorithmId: int32
    KeySize: int32
    DataUnitSizeBitmask: uint32

  STORAGE_CRYPTO_DESCRIPTOR {.bycopy.} = object
    Version: uint32
    Size: uint32
    NumKeysSupported: uint32
    NumCryptoCapabilities: uint32
    CryptoCapabilities: array[1, STORAGE_CRYPTO_CAPABILITY]
struct STORAGE_CRYPTO_CAPABILITY
{
    uint Version;
    uint Size;
    uint CryptoCapabilityIndex;
    int AlgorithmId;
    int KeySize;
    uint DataUnitSizeBitmask;
}

struct STORAGE_CRYPTO_DESCRIPTOR
{
    uint Version;
    uint Size;
    uint NumKeysSupported;
    uint NumCryptoCapabilities;
    STORAGE_CRYPTO_CAPABILITY[1] CryptoCapabilities;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_CRYPTO_DESCRIPTOR サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; NumKeysSupported : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; NumCryptoCapabilities : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; CryptoCapabilities : STORAGE_CRYPTO_CAPABILITY (+16, 24byte)  varptr(st)+16 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global STORAGE_CRYPTO_CAPABILITY
    #field int Version
    #field int Size
    #field int CryptoCapabilityIndex
    #field int AlgorithmId
    #field int KeySize
    #field int DataUnitSizeBitmask
#endstruct

#defstruct global STORAGE_CRYPTO_DESCRIPTOR
    #field int Version
    #field int Size
    #field int NumKeysSupported
    #field int NumCryptoCapabilities
    #field STORAGE_CRYPTO_CAPABILITY CryptoCapabilities 1
#endstruct

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