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

GetKeyDerivationInterface

関数
プロバイダーの鍵導出関数テーブルを取得する。
DLLbcryptprimitives.dll呼出規約winapi

シグネチャ

// bcryptprimitives.dll
#include <windows.h>

NTSTATUS GetKeyDerivationInterface(
    LPCWSTR pszProviderName,
    LPCWSTR pszAlgId,
    BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** ppFunctionTable,
    DWORD dwFlags
);

パラメーター

名前方向
pszProviderNameLPCWSTRin
pszAlgIdLPCWSTRin
ppFunctionTableBCRYPT_KEY_DERIVATION_FUNCTION_TABLE**out
dwFlagsDWORDin

戻り値の型: NTSTATUS

各言語での呼び出し定義

// bcryptprimitives.dll
#include <windows.h>

NTSTATUS GetKeyDerivationInterface(
    LPCWSTR pszProviderName,
    LPCWSTR pszAlgId,
    BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** ppFunctionTable,
    DWORD dwFlags
);
[DllImport("bcryptprimitives.dll", ExactSpelling = true)]
static extern int GetKeyDerivationInterface(
    [MarshalAs(UnmanagedType.LPWStr)] string pszProviderName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszAlgId,   // LPCWSTR
    IntPtr ppFunctionTable,   // BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
    uint dwFlags   // DWORD
);
<DllImport("bcryptprimitives.dll", ExactSpelling:=True)>
Public Shared Function GetKeyDerivationInterface(
    <MarshalAs(UnmanagedType.LPWStr)> pszProviderName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszAlgId As String,   ' LPCWSTR
    ppFunctionTable As IntPtr,   ' BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
    dwFlags As UInteger   ' DWORD
) As Integer
End Function
' pszProviderName : LPCWSTR
' pszAlgId : LPCWSTR
' ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
' dwFlags : DWORD
Declare PtrSafe Function GetKeyDerivationInterface 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

GetKeyDerivationInterface = ctypes.windll.bcryptprimitives.GetKeyDerivationInterface
GetKeyDerivationInterface.restype = ctypes.c_int
GetKeyDerivationInterface.argtypes = [
    wintypes.LPCWSTR,  # pszProviderName : LPCWSTR
    wintypes.LPCWSTR,  # pszAlgId : LPCWSTR
    ctypes.c_void_p,  # ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('bcryptprimitives.dll')
GetKeyDerivationInterface = Fiddle::Function.new(
  lib['GetKeyDerivationInterface'],
  [
    Fiddle::TYPE_VOIDP,  # pszProviderName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszAlgId : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "bcryptprimitives")]
extern "system" {
    fn GetKeyDerivationInterface(
        pszProviderName: *const u16,  // LPCWSTR
        pszAlgId: *const u16,  // LPCWSTR
        ppFunctionTable: *mut *mut BCRYPT_KEY_DERIVATION_FUNCTION_TABLE,  // BCRYPT_KEY_DERIVATION_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 GetKeyDerivationInterface([MarshalAs(UnmanagedType.LPWStr)] string pszProviderName, [MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, IntPtr ppFunctionTable, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcryptprimitives_GetKeyDerivationInterface' -Namespace Win32 -PassThru
# $api::GetKeyDerivationInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags)
#uselib "bcryptprimitives.dll"
#func global GetKeyDerivationInterface "GetKeyDerivationInterface" sptr, sptr, sptr, sptr
; GetKeyDerivationInterface pszProviderName, pszAlgId, varptr(ppFunctionTable), dwFlags   ; 戻り値は stat
; pszProviderName : LPCWSTR -> "sptr"
; pszAlgId : LPCWSTR -> "sptr"
; ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "bcryptprimitives.dll"
#cfunc global GetKeyDerivationInterface "GetKeyDerivationInterface" wstr, wstr, var, int
; res = GetKeyDerivationInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags)
; pszProviderName : LPCWSTR -> "wstr"
; pszAlgId : LPCWSTR -> "wstr"
; ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; NTSTATUS GetKeyDerivationInterface(LPCWSTR pszProviderName, LPCWSTR pszAlgId, BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** ppFunctionTable, DWORD dwFlags)
#uselib "bcryptprimitives.dll"
#cfunc global GetKeyDerivationInterface "GetKeyDerivationInterface" wstr, wstr, var, int
; res = GetKeyDerivationInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags)
; pszProviderName : LPCWSTR -> "wstr"
; pszAlgId : LPCWSTR -> "wstr"
; ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bcryptprimitives = windows.NewLazySystemDLL("bcryptprimitives.dll")
	procGetKeyDerivationInterface = bcryptprimitives.NewProc("GetKeyDerivationInterface")
)

// pszProviderName (LPCWSTR), pszAlgId (LPCWSTR), ppFunctionTable (BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out), dwFlags (DWORD)
r1, _, err := procGetKeyDerivationInterface.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   // NTSTATUS
function GetKeyDerivationInterface(
  pszProviderName: PWideChar;   // LPCWSTR
  pszAlgId: PWideChar;   // LPCWSTR
  ppFunctionTable: Pointer;   // BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
  dwFlags: DWORD   // DWORD
): Integer; stdcall;
  external 'bcryptprimitives.dll' name 'GetKeyDerivationInterface';
result := DllCall("bcryptprimitives\GetKeyDerivationInterface"
    , "WStr", pszProviderName   ; LPCWSTR
    , "WStr", pszAlgId   ; LPCWSTR
    , "Ptr", ppFunctionTable   ; BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: NTSTATUS
●GetKeyDerivationInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags) = DLL("bcryptprimitives.dll", "int GetKeyDerivationInterface(char*, char*, void*, dword)")
# 呼び出し: GetKeyDerivationInterface(pszProviderName, pszAlgId, ppFunctionTable, dwFlags)
# pszProviderName : LPCWSTR -> "char*"
# pszAlgId : LPCWSTR -> "char*"
# ppFunctionTable : BCRYPT_KEY_DERIVATION_FUNCTION_TABLE** out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。