ホーム › Security.Cryptography › SslComputeSessionHash
SslComputeSessionHash
関数SSLハンドシェイクのセッションハッシュを計算する。
シグネチャ
// ncrypt.dll
#include <windows.h>
HRESULT SslComputeSessionHash(
NCRYPT_PROV_HANDLE hSslProvider,
NCRYPT_HASH_HANDLE hHandshakeHash,
DWORD dwProtocol,
BYTE* pbOutput, // optional
DWORD cbOutput,
DWORD* pcbResult,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSslProvider | NCRYPT_PROV_HANDLE | in |
| hHandshakeHash | NCRYPT_HASH_HANDLE | in |
| dwProtocol | DWORD | in |
| pbOutput | BYTE* | outoptional |
| cbOutput | DWORD | in |
| pcbResult | DWORD* | out |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
HRESULT SslComputeSessionHash(
NCRYPT_PROV_HANDLE hSslProvider,
NCRYPT_HASH_HANDLE hHandshakeHash,
DWORD dwProtocol,
BYTE* pbOutput, // optional
DWORD cbOutput,
DWORD* pcbResult,
DWORD dwFlags
);[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int SslComputeSessionHash(
UIntPtr hSslProvider, // NCRYPT_PROV_HANDLE
UIntPtr hHandshakeHash, // NCRYPT_HASH_HANDLE
uint dwProtocol, // 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 SslComputeSessionHash(
hSslProvider As UIntPtr, ' NCRYPT_PROV_HANDLE
hHandshakeHash As UIntPtr, ' NCRYPT_HASH_HANDLE
dwProtocol 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
' hHandshakeHash : NCRYPT_HASH_HANDLE
' dwProtocol : DWORD
' pbOutput : BYTE* optional, out
' cbOutput : DWORD
' pcbResult : DWORD* out
' dwFlags : DWORD
Declare PtrSafe Function SslComputeSessionHash Lib "ncrypt" ( _
ByVal hSslProvider As LongPtr, _
ByVal hHandshakeHash As LongPtr, _
ByVal dwProtocol 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
SslComputeSessionHash = ctypes.windll.ncrypt.SslComputeSessionHash
SslComputeSessionHash.restype = ctypes.c_int
SslComputeSessionHash.argtypes = [
ctypes.c_size_t, # hSslProvider : NCRYPT_PROV_HANDLE
ctypes.c_size_t, # hHandshakeHash : NCRYPT_HASH_HANDLE
wintypes.DWORD, # dwProtocol : 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')
SslComputeSessionHash = Fiddle::Function.new(
lib['SslComputeSessionHash'],
[
Fiddle::TYPE_UINTPTR_T, # hSslProvider : NCRYPT_PROV_HANDLE
Fiddle::TYPE_UINTPTR_T, # hHandshakeHash : NCRYPT_HASH_HANDLE
-Fiddle::TYPE_INT, # dwProtocol : 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 SslComputeSessionHash(
hSslProvider: usize, // NCRYPT_PROV_HANDLE
hHandshakeHash: usize, // NCRYPT_HASH_HANDLE
dwProtocol: 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 SslComputeSessionHash(UIntPtr hSslProvider, UIntPtr hHandshakeHash, uint dwProtocol, IntPtr pbOutput, uint cbOutput, out uint pcbResult, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_SslComputeSessionHash' -Namespace Win32 -PassThru
# $api::SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags)#uselib "ncrypt.dll"
#func global SslComputeSessionHash "SslComputeSessionHash" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SslComputeSessionHash hSslProvider, hHandshakeHash, dwProtocol, varptr(pbOutput), cbOutput, varptr(pcbResult), dwFlags ; 戻り値は stat
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; hHandshakeHash : NCRYPT_HASH_HANDLE -> "sptr"
; dwProtocol : 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 SslComputeSessionHash "SslComputeSessionHash" sptr, sptr, int, var, int, var, int ; res = SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr" ; hHandshakeHash : NCRYPT_HASH_HANDLE -> "sptr" ; dwProtocol : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "var" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ncrypt.dll" #cfunc global SslComputeSessionHash "SslComputeSessionHash" sptr, sptr, int, sptr, int, sptr, int ; res = SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, varptr(pbOutput), cbOutput, varptr(pcbResult), dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr" ; hHandshakeHash : NCRYPT_HASH_HANDLE -> "sptr" ; dwProtocol : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "sptr" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SslComputeSessionHash(NCRYPT_PROV_HANDLE hSslProvider, NCRYPT_HASH_HANDLE hHandshakeHash, DWORD dwProtocol, BYTE* pbOutput, DWORD cbOutput, DWORD* pcbResult, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global SslComputeSessionHash "SslComputeSessionHash" intptr, intptr, int, var, int, var, int ; res = SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr" ; hHandshakeHash : NCRYPT_HASH_HANDLE -> "intptr" ; dwProtocol : DWORD -> "int" ; pbOutput : BYTE* optional, out -> "var" ; cbOutput : DWORD -> "int" ; pcbResult : DWORD* out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SslComputeSessionHash(NCRYPT_PROV_HANDLE hSslProvider, NCRYPT_HASH_HANDLE hHandshakeHash, DWORD dwProtocol, BYTE* pbOutput, DWORD cbOutput, DWORD* pcbResult, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global SslComputeSessionHash "SslComputeSessionHash" intptr, intptr, int, intptr, int, intptr, int ; res = SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, varptr(pbOutput), cbOutput, varptr(pcbResult), dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr" ; hHandshakeHash : NCRYPT_HASH_HANDLE -> "intptr" ; dwProtocol : 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")
procSslComputeSessionHash = ncrypt.NewProc("SslComputeSessionHash")
)
// hSslProvider (NCRYPT_PROV_HANDLE), hHandshakeHash (NCRYPT_HASH_HANDLE), dwProtocol (DWORD), pbOutput (BYTE* optional, out), cbOutput (DWORD), pcbResult (DWORD* out), dwFlags (DWORD)
r1, _, err := procSslComputeSessionHash.Call(
uintptr(hSslProvider),
uintptr(hHandshakeHash),
uintptr(dwProtocol),
uintptr(pbOutput),
uintptr(cbOutput),
uintptr(pcbResult),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SslComputeSessionHash(
hSslProvider: NativeUInt; // NCRYPT_PROV_HANDLE
hHandshakeHash: NativeUInt; // NCRYPT_HASH_HANDLE
dwProtocol: DWORD; // DWORD
pbOutput: Pointer; // BYTE* optional, out
cbOutput: DWORD; // DWORD
pcbResult: Pointer; // DWORD* out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'SslComputeSessionHash';result := DllCall("ncrypt\SslComputeSessionHash"
, "UPtr", hSslProvider ; NCRYPT_PROV_HANDLE
, "UPtr", hHandshakeHash ; NCRYPT_HASH_HANDLE
, "UInt", dwProtocol ; DWORD
, "Ptr", pbOutput ; BYTE* optional, out
, "UInt", cbOutput ; DWORD
, "Ptr", pcbResult ; DWORD* out
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags) = DLL("ncrypt.dll", "int SslComputeSessionHash(int, int, dword, void*, dword, void*, dword)")
# 呼び出し: SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> "int"
# hHandshakeHash : NCRYPT_HASH_HANDLE -> "int"
# dwProtocol : 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)。