ホーム › Security.Cryptography › SslComputeEapKeyBlock
SslComputeEapKeyBlock
関数SSLマスター鍵からEAP用の鍵ブロックを計算する。
シグネチャ
// ncrypt.dll
#include <windows.h>
HRESULT SslComputeEapKeyBlock(
NCRYPT_PROV_HANDLE hSslProvider,
NCRYPT_KEY_HANDLE hMasterKey,
BYTE* pbRandoms,
DWORD cbRandoms,
BYTE* pbOutput, // optional
DWORD cbOutput,
DWORD* pcbResult,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSslProvider | NCRYPT_PROV_HANDLE | in |
| hMasterKey | NCRYPT_KEY_HANDLE | in |
| pbRandoms | BYTE* | in |
| cbRandoms | DWORD | in |
| pbOutput | BYTE* | outoptional |
| cbOutput | DWORD | in |
| pcbResult | DWORD* | out |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
HRESULT SslComputeEapKeyBlock(
NCRYPT_PROV_HANDLE hSslProvider,
NCRYPT_KEY_HANDLE hMasterKey,
BYTE* pbRandoms,
DWORD cbRandoms,
BYTE* pbOutput, // optional
DWORD cbOutput,
DWORD* pcbResult,
DWORD dwFlags
);[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int SslComputeEapKeyBlock(
UIntPtr hSslProvider, // NCRYPT_PROV_HANDLE
UIntPtr hMasterKey, // NCRYPT_KEY_HANDLE
IntPtr pbRandoms, // BYTE*
uint cbRandoms, // DWORD
IntPtr pbOutput, // BYTE* optional, out
uint cbOutput, // DWORD
out uint pcbResult, // DWORD* out
uint dwFlags // DWORD
);<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function SslComputeEapKeyBlock(
hSslProvider As UIntPtr, ' NCRYPT_PROV_HANDLE
hMasterKey As UIntPtr, ' NCRYPT_KEY_HANDLE
pbRandoms As IntPtr, ' BYTE*
cbRandoms As UInteger, ' DWORD
pbOutput As IntPtr, ' BYTE* optional, out
cbOutput As UInteger, ' DWORD
<Out> ByRef pcbResult As UInteger, ' DWORD* out
dwFlags As UInteger ' DWORD
) As Integer
End Function' hSslProvider : NCRYPT_PROV_HANDLE
' hMasterKey : NCRYPT_KEY_HANDLE
' pbRandoms : BYTE*
' cbRandoms : DWORD
' pbOutput : BYTE* optional, out
' cbOutput : DWORD
' pcbResult : DWORD* out
' dwFlags : DWORD
Declare PtrSafe Function SslComputeEapKeyBlock Lib "ncrypt" ( _
ByVal hSslProvider As LongPtr, _
ByVal hMasterKey As LongPtr, _
ByVal pbRandoms As LongPtr, _
ByVal cbRandoms As Long, _
ByVal pbOutput As LongPtr, _
ByVal cbOutput As Long, _
ByRef pcbResult As Long, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SslComputeEapKeyBlock = ctypes.windll.ncrypt.SslComputeEapKeyBlock
SslComputeEapKeyBlock.restype = ctypes.c_int
SslComputeEapKeyBlock.argtypes = [
ctypes.c_size_t, # hSslProvider : NCRYPT_PROV_HANDLE
ctypes.c_size_t, # hMasterKey : NCRYPT_KEY_HANDLE
ctypes.POINTER(ctypes.c_ubyte), # pbRandoms : BYTE*
wintypes.DWORD, # cbRandoms : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pbOutput : BYTE* optional, out
wintypes.DWORD, # cbOutput : DWORD
ctypes.POINTER(wintypes.DWORD), # pcbResult : DWORD* out
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ncrypt.dll')
SslComputeEapKeyBlock = Fiddle::Function.new(
lib['SslComputeEapKeyBlock'],
[
Fiddle::TYPE_UINTPTR_T, # hSslProvider : NCRYPT_PROV_HANDLE
Fiddle::TYPE_UINTPTR_T, # hMasterKey : NCRYPT_KEY_HANDLE
Fiddle::TYPE_VOIDP, # pbRandoms : BYTE*
-Fiddle::TYPE_INT, # cbRandoms : DWORD
Fiddle::TYPE_VOIDP, # pbOutput : BYTE* optional, out
-Fiddle::TYPE_INT, # cbOutput : DWORD
Fiddle::TYPE_VOIDP, # pcbResult : DWORD* out
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ncrypt")]
extern "system" {
fn SslComputeEapKeyBlock(
hSslProvider: usize, // NCRYPT_PROV_HANDLE
hMasterKey: usize, // NCRYPT_KEY_HANDLE
pbRandoms: *mut u8, // BYTE*
cbRandoms: u32, // DWORD
pbOutput: *mut u8, // BYTE* optional, out
cbOutput: u32, // DWORD
pcbResult: *mut u32, // DWORD* out
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ncrypt.dll")]
public static extern int SslComputeEapKeyBlock(UIntPtr hSslProvider, UIntPtr hMasterKey, IntPtr pbRandoms, uint cbRandoms, IntPtr pbOutput, uint cbOutput, out uint pcbResult, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_SslComputeEapKeyBlock' -Namespace Win32 -PassThru
# $api::SslComputeEapKeyBlock(hSslProvider, hMasterKey, pbRandoms, cbRandoms, pbOutput, cbOutput, pcbResult, dwFlags)#uselib "ncrypt.dll"
#func global SslComputeEapKeyBlock "SslComputeEapKeyBlock" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SslComputeEapKeyBlock hSslProvider, hMasterKey, varptr(pbRandoms), cbRandoms, varptr(pbOutput), cbOutput, varptr(pcbResult), dwFlags ; 戻り値は stat
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; hMasterKey : NCRYPT_KEY_HANDLE -> "sptr"
; pbRandoms : BYTE* -> "sptr"
; cbRandoms : DWORD -> "sptr"
; pbOutput : BYTE* optional, out -> "sptr"
; cbOutput : DWORD -> "sptr"
; pcbResult : DWORD* out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ncrypt.dll" #cfunc global SslComputeEapKeyBlock "SslComputeEapKeyBlock" sptr, sptr, var, int, var, int, var, int ; res = SslComputeEapKeyBlock(hSslProvider, hMasterKey, pbRandoms, cbRandoms, pbOutput, cbOutput, pcbResult, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr" ; hMasterKey : NCRYPT_KEY_HANDLE -> "sptr" ; pbRandoms : BYTE* -> "var" ; cbRandoms : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "var" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ncrypt.dll" #cfunc global SslComputeEapKeyBlock "SslComputeEapKeyBlock" sptr, sptr, sptr, int, sptr, int, sptr, int ; res = SslComputeEapKeyBlock(hSslProvider, hMasterKey, varptr(pbRandoms), cbRandoms, varptr(pbOutput), cbOutput, varptr(pcbResult), dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr" ; hMasterKey : NCRYPT_KEY_HANDLE -> "sptr" ; pbRandoms : BYTE* -> "sptr" ; cbRandoms : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "sptr" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SslComputeEapKeyBlock(NCRYPT_PROV_HANDLE hSslProvider, NCRYPT_KEY_HANDLE hMasterKey, BYTE* pbRandoms, DWORD cbRandoms, BYTE* pbOutput, DWORD cbOutput, DWORD* pcbResult, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global SslComputeEapKeyBlock "SslComputeEapKeyBlock" intptr, intptr, var, int, var, int, var, int ; res = SslComputeEapKeyBlock(hSslProvider, hMasterKey, pbRandoms, cbRandoms, pbOutput, cbOutput, pcbResult, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr" ; hMasterKey : NCRYPT_KEY_HANDLE -> "intptr" ; pbRandoms : BYTE* -> "var" ; cbRandoms : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "var" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SslComputeEapKeyBlock(NCRYPT_PROV_HANDLE hSslProvider, NCRYPT_KEY_HANDLE hMasterKey, BYTE* pbRandoms, DWORD cbRandoms, BYTE* pbOutput, DWORD cbOutput, DWORD* pcbResult, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global SslComputeEapKeyBlock "SslComputeEapKeyBlock" intptr, intptr, intptr, int, intptr, int, intptr, int ; res = SslComputeEapKeyBlock(hSslProvider, hMasterKey, varptr(pbRandoms), cbRandoms, varptr(pbOutput), cbOutput, varptr(pcbResult), dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr" ; hMasterKey : NCRYPT_KEY_HANDLE -> "intptr" ; pbRandoms : BYTE* -> "intptr" ; cbRandoms : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "intptr" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
procSslComputeEapKeyBlock = ncrypt.NewProc("SslComputeEapKeyBlock")
)
// hSslProvider (NCRYPT_PROV_HANDLE), hMasterKey (NCRYPT_KEY_HANDLE), pbRandoms (BYTE*), cbRandoms (DWORD), pbOutput (BYTE* optional, out), cbOutput (DWORD), pcbResult (DWORD* out), dwFlags (DWORD)
r1, _, err := procSslComputeEapKeyBlock.Call(
uintptr(hSslProvider),
uintptr(hMasterKey),
uintptr(pbRandoms),
uintptr(cbRandoms),
uintptr(pbOutput),
uintptr(cbOutput),
uintptr(pcbResult),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SslComputeEapKeyBlock(
hSslProvider: NativeUInt; // NCRYPT_PROV_HANDLE
hMasterKey: NativeUInt; // NCRYPT_KEY_HANDLE
pbRandoms: Pointer; // BYTE*
cbRandoms: DWORD; // DWORD
pbOutput: Pointer; // BYTE* optional, out
cbOutput: DWORD; // DWORD
pcbResult: Pointer; // DWORD* out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'SslComputeEapKeyBlock';result := DllCall("ncrypt\SslComputeEapKeyBlock"
, "UPtr", hSslProvider ; NCRYPT_PROV_HANDLE
, "UPtr", hMasterKey ; NCRYPT_KEY_HANDLE
, "Ptr", pbRandoms ; BYTE*
, "UInt", cbRandoms ; DWORD
, "Ptr", pbOutput ; BYTE* optional, out
, "UInt", cbOutput ; DWORD
, "Ptr", pcbResult ; DWORD* out
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●SslComputeEapKeyBlock(hSslProvider, hMasterKey, pbRandoms, cbRandoms, pbOutput, cbOutput, pcbResult, dwFlags) = DLL("ncrypt.dll", "int SslComputeEapKeyBlock(int, int, void*, dword, void*, dword, void*, dword)")
# 呼び出し: SslComputeEapKeyBlock(hSslProvider, hMasterKey, pbRandoms, cbRandoms, pbOutput, cbOutput, pcbResult, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> "int"
# hMasterKey : NCRYPT_KEY_HANDLE -> "int"
# pbRandoms : BYTE* -> "void*"
# cbRandoms : DWORD -> "dword"
# pbOutput : BYTE* optional, out -> "void*"
# cbOutput : DWORD -> "dword"
# pcbResult : DWORD* out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。