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

CRYPT_CSP_PROVIDER

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

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

フィールド

フィールドサイズx64x86説明
dwKeySpecDWORD4+0+0鍵指定(AT_KEYEXCHANGE/AT_SIGNATURE)を示す値。
pwszProviderNameLPWSTR8/4+8+4CSPプロバイダー名を示すワイド文字列。
SignatureCRYPT_BIT_BLOB24/12+16+8プロバイダー情報に対する署名を保持するビットBLOB。

各言語での定義

#include <windows.h>

// CRYPT_BIT_BLOB  (x64 24 / x86 12 バイト)
typedef struct CRYPT_BIT_BLOB {
    DWORD cbData;
    BYTE* pbData;
    DWORD cUnusedBits;
} CRYPT_BIT_BLOB;

// CRYPT_CSP_PROVIDER  (x64 40 / x86 20 バイト)
typedef struct CRYPT_CSP_PROVIDER {
    DWORD dwKeySpec;
    LPWSTR pwszProviderName;
    CRYPT_BIT_BLOB Signature;
} CRYPT_CSP_PROVIDER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_BIT_BLOB
{
    public uint cbData;
    public IntPtr pbData;
    public uint cUnusedBits;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_CSP_PROVIDER
{
    public uint dwKeySpec;
    public IntPtr pwszProviderName;
    public CRYPT_BIT_BLOB Signature;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_BIT_BLOB
    Public cbData As UInteger
    Public pbData As IntPtr
    Public cUnusedBits As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_CSP_PROVIDER
    Public dwKeySpec As UInteger
    Public pwszProviderName As IntPtr
    Public Signature As CRYPT_BIT_BLOB
End Structure
import ctypes
from ctypes import wintypes

class CRYPT_BIT_BLOB(ctypes.Structure):
    _fields_ = [
        ("cbData", wintypes.DWORD),
        ("pbData", ctypes.c_void_p),
        ("cUnusedBits", wintypes.DWORD),
    ]

class CRYPT_CSP_PROVIDER(ctypes.Structure):
    _fields_ = [
        ("dwKeySpec", wintypes.DWORD),
        ("pwszProviderName", ctypes.c_void_p),
        ("Signature", CRYPT_BIT_BLOB),
    ]
#[repr(C)]
pub struct CRYPT_BIT_BLOB {
    pub cbData: u32,
    pub pbData: *mut core::ffi::c_void,
    pub cUnusedBits: u32,
}

#[repr(C)]
pub struct CRYPT_CSP_PROVIDER {
    pub dwKeySpec: u32,
    pub pwszProviderName: *mut core::ffi::c_void,
    pub Signature: CRYPT_BIT_BLOB,
}
import "golang.org/x/sys/windows"

type CRYPT_BIT_BLOB struct {
	cbData uint32
	pbData uintptr
	cUnusedBits uint32
}

type CRYPT_CSP_PROVIDER struct {
	dwKeySpec uint32
	pwszProviderName uintptr
	Signature CRYPT_BIT_BLOB
}
type
  CRYPT_BIT_BLOB = record
    cbData: DWORD;
    pbData: Pointer;
    cUnusedBits: DWORD;
  end;

  CRYPT_CSP_PROVIDER = record
    dwKeySpec: DWORD;
    pwszProviderName: Pointer;
    Signature: CRYPT_BIT_BLOB;
  end;
const CRYPT_BIT_BLOB = extern struct {
    cbData: u32,
    pbData: ?*anyopaque,
    cUnusedBits: u32,
};

const CRYPT_CSP_PROVIDER = extern struct {
    dwKeySpec: u32,
    pwszProviderName: ?*anyopaque,
    Signature: CRYPT_BIT_BLOB,
};
type
  CRYPT_BIT_BLOB {.bycopy.} = object
    cbData: uint32
    pbData: pointer
    cUnusedBits: uint32

  CRYPT_CSP_PROVIDER {.bycopy.} = object
    dwKeySpec: uint32
    pwszProviderName: pointer
    Signature: CRYPT_BIT_BLOB
struct CRYPT_BIT_BLOB
{
    uint cbData;
    void* pbData;
    uint cUnusedBits;
}

struct CRYPT_CSP_PROVIDER
{
    uint dwKeySpec;
    void* pwszProviderName;
    CRYPT_BIT_BLOB Signature;
}

HSP用 定義

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

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

#defstruct global CRYPT_CSP_PROVIDER
    #field int dwKeySpec
    #field intptr pwszProviderName
    #field CRYPT_BIT_BLOB Signature
#endstruct

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