ホーム › Security.Cryptography › GetCipherInterface
GetCipherInterface
関数暗号化プロバイダーの共通暗号関数テーブルを取得する。
シグネチャ
// bcryptprimitives.dll
#include <windows.h>
NTSTATUS GetCipherInterface(
LPCWSTR pszProviderName,
LPCWSTR pszAlgId,
BCRYPT_CIPHER_FUNCTION_TABLE** ppFunctionTable,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszProviderName | LPCWSTR | in |
| pszAlgId | LPCWSTR | in |
| ppFunctionTable | BCRYPT_CIPHER_FUNCTION_TABLE** | out |
| dwFlags | DWORD | in |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// bcryptprimitives.dll
#include <windows.h>
NTSTATUS GetCipherInterface(
LPCWSTR pszProviderName,
LPCWSTR pszAlgId,
BCRYPT_CIPHER_FUNCTION_TABLE** ppFunctionTable,
DWORD dwFlags
);[DllImport("bcryptprimitives.dll", ExactSpelling = true)]
static extern int GetCipherInterface(
[MarshalAs(UnmanagedType.LPWStr)] string pszProviderName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, // LPCWSTR
IntPtr ppFunctionTable, // BCRYPT_CIPHER_FUNCTION_TABLE** out
uint dwFlags // DWORD
);<DllImport("bcryptprimitives.dll", ExactSpelling:=True)>
Public Shared Function GetCipherInterface(
<MarshalAs(UnmanagedType.LPWStr)> pszProviderName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszAlgId As String, ' LPCWSTR
ppFunctionTable As IntPtr, ' BCRYPT_CIPHER_FUNCTION_TABLE** out
dwFlags As UInteger ' DWORD
) As Integer
End Function' pszProviderName : LPCWSTR
' pszAlgId : LPCWSTR
' ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out
' dwFlags : DWORD
Declare PtrSafe Function GetCipherInterface Lib "bcryptprimitives" ( _
ByVal pszProviderName As LongPtr, _
ByVal pszAlgId As LongPtr, _
ByVal ppFunctionTable As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCipherInterface = ctypes.windll.bcryptprimitives.GetCipherInterface
GetCipherInterface.restype = ctypes.c_int
GetCipherInterface.argtypes = [
wintypes.LPCWSTR, # pszProviderName : LPCWSTR
wintypes.LPCWSTR, # pszAlgId : LPCWSTR
ctypes.c_void_p, # ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcryptprimitives.dll')
GetCipherInterface = Fiddle::Function.new(
lib['GetCipherInterface'],
[
Fiddle::TYPE_VOIDP, # pszProviderName : LPCWSTR
Fiddle::TYPE_VOIDP, # pszAlgId : LPCWSTR
Fiddle::TYPE_VOIDP, # ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "bcryptprimitives")]
extern "system" {
fn GetCipherInterface(
pszProviderName: *const u16, // LPCWSTR
pszAlgId: *const u16, // LPCWSTR
ppFunctionTable: *mut *mut BCRYPT_CIPHER_FUNCTION_TABLE, // BCRYPT_CIPHER_FUNCTION_TABLE** out
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcryptprimitives.dll")]
public static extern int GetCipherInterface([MarshalAs(UnmanagedType.LPWStr)] string pszProviderName, [MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, IntPtr ppFunctionTable, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcryptprimitives_GetCipherInterface' -Namespace Win32 -PassThru
# $api::GetCipherInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags)#uselib "bcryptprimitives.dll"
#func global GetCipherInterface "GetCipherInterface" sptr, sptr, sptr, sptr
; GetCipherInterface pszProviderName, pszAlgId, varptr(ppFunctionTable), dwFlags ; 戻り値は stat
; pszProviderName : LPCWSTR -> "sptr"
; pszAlgId : LPCWSTR -> "sptr"
; ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "bcryptprimitives.dll" #cfunc global GetCipherInterface "GetCipherInterface" wstr, wstr, var, int ; res = GetCipherInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; pszAlgId : LPCWSTR -> "wstr" ; ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "bcryptprimitives.dll" #cfunc global GetCipherInterface "GetCipherInterface" wstr, wstr, sptr, int ; res = GetCipherInterface(pszProviderName, pszAlgId, varptr(ppFunctionTable), dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; pszAlgId : LPCWSTR -> "wstr" ; ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS GetCipherInterface(LPCWSTR pszProviderName, LPCWSTR pszAlgId, BCRYPT_CIPHER_FUNCTION_TABLE** ppFunctionTable, DWORD dwFlags) #uselib "bcryptprimitives.dll" #cfunc global GetCipherInterface "GetCipherInterface" wstr, wstr, var, int ; res = GetCipherInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; pszAlgId : LPCWSTR -> "wstr" ; ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS GetCipherInterface(LPCWSTR pszProviderName, LPCWSTR pszAlgId, BCRYPT_CIPHER_FUNCTION_TABLE** ppFunctionTable, DWORD dwFlags) #uselib "bcryptprimitives.dll" #cfunc global GetCipherInterface "GetCipherInterface" wstr, wstr, intptr, int ; res = GetCipherInterface(pszProviderName, pszAlgId, varptr(ppFunctionTable), dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; pszAlgId : LPCWSTR -> "wstr" ; ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcryptprimitives = windows.NewLazySystemDLL("bcryptprimitives.dll")
procGetCipherInterface = bcryptprimitives.NewProc("GetCipherInterface")
)
// pszProviderName (LPCWSTR), pszAlgId (LPCWSTR), ppFunctionTable (BCRYPT_CIPHER_FUNCTION_TABLE** out), dwFlags (DWORD)
r1, _, err := procGetCipherInterface.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszProviderName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszAlgId))),
uintptr(ppFunctionTable),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction GetCipherInterface(
pszProviderName: PWideChar; // LPCWSTR
pszAlgId: PWideChar; // LPCWSTR
ppFunctionTable: Pointer; // BCRYPT_CIPHER_FUNCTION_TABLE** out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'bcryptprimitives.dll' name 'GetCipherInterface';result := DllCall("bcryptprimitives\GetCipherInterface"
, "WStr", pszProviderName ; LPCWSTR
, "WStr", pszAlgId ; LPCWSTR
, "Ptr", ppFunctionTable ; BCRYPT_CIPHER_FUNCTION_TABLE** out
, "UInt", dwFlags ; DWORD
, "Int") ; return: NTSTATUS●GetCipherInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags) = DLL("bcryptprimitives.dll", "int GetCipherInterface(char*, char*, void*, dword)")
# 呼び出し: GetCipherInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags)
# pszProviderName : LPCWSTR -> "char*"
# pszAlgId : LPCWSTR -> "char*"
# ppFunctionTable : BCRYPT_CIPHER_FUNCTION_TABLE** out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。