ホーム › 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 | Schannel SSLプロバイダのハンドル。 |
| hHandshakeHash | NCRYPT_HASH_HANDLE | in | ハンドシェイクハッシュのハンドル。 |
| dwProtocol | DWORD | in | 対象のSSL/TLSプロトコルバージョンを示す値。 |
| pbOutput | BYTE* | outoptional | 計算したセッションハッシュを書き込む出力バッファ。 |
| cbOutput | DWORD | in | pbOutputのバイト数。 |
| 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)。const std = @import("std");
extern "ncrypt" fn SslComputeSessionHash(
hSslProvider: usize, // NCRYPT_PROV_HANDLE
hHandshakeHash: usize, // NCRYPT_HASH_HANDLE
dwProtocol: u32, // DWORD
pbOutput: [*c]u8, // BYTE* optional, out
cbOutput: u32, // DWORD
pcbResult: [*c]u32, // DWORD* out
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc SslComputeSessionHash(
hSslProvider: uint, # NCRYPT_PROV_HANDLE
hHandshakeHash: uint, # NCRYPT_HASH_HANDLE
dwProtocol: uint32, # DWORD
pbOutput: ptr uint8, # BYTE* optional, out
cbOutput: uint32, # DWORD
pcbResult: ptr uint32, # DWORD* out
dwFlags: uint32 # DWORD
): int32 {.importc: "SslComputeSessionHash", stdcall, dynlib: "ncrypt.dll".}pragma(lib, "ncrypt");
extern(Windows)
int SslComputeSessionHash(
size_t hSslProvider, // NCRYPT_PROV_HANDLE
size_t hHandshakeHash, // NCRYPT_HASH_HANDLE
uint dwProtocol, // DWORD
ubyte* pbOutput, // BYTE* optional, out
uint cbOutput, // DWORD
uint* pcbResult, // DWORD* out
uint dwFlags // DWORD
);ccall((:SslComputeSessionHash, "ncrypt.dll"), stdcall, Int32,
(Csize_t, Csize_t, UInt32, Ptr{UInt8}, UInt32, Ptr{UInt32}, UInt32),
hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> Csize_t
# hHandshakeHash : NCRYPT_HASH_HANDLE -> Csize_t
# dwProtocol : DWORD -> UInt32
# pbOutput : BYTE* optional, out -> Ptr{UInt8}
# cbOutput : DWORD -> UInt32
# pcbResult : DWORD* out -> Ptr{UInt32}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SslComputeSessionHash(
uintptr_t hSslProvider,
uintptr_t hHandshakeHash,
uint32_t dwProtocol,
uint8_t* pbOutput,
uint32_t cbOutput,
uint32_t* pcbResult,
uint32_t dwFlags);
]]
local ncrypt = ffi.load("ncrypt")
-- ncrypt.SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags)
-- hSslProvider : NCRYPT_PROV_HANDLE
-- hHandshakeHash : NCRYPT_HASH_HANDLE
-- dwProtocol : DWORD
-- pbOutput : BYTE* optional, out
-- cbOutput : DWORD
-- pcbResult : DWORD* out
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ncrypt.dll');
const SslComputeSessionHash = lib.func('__stdcall', 'SslComputeSessionHash', 'int32_t', ['uintptr_t', 'uintptr_t', 'uint32_t', 'uint8_t *', 'uint32_t', 'uint32_t *', 'uint32_t']);
// SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags)
// hSslProvider : NCRYPT_PROV_HANDLE -> 'uintptr_t'
// hHandshakeHash : NCRYPT_HASH_HANDLE -> 'uintptr_t'
// dwProtocol : DWORD -> 'uint32_t'
// pbOutput : BYTE* optional, out -> 'uint8_t *'
// cbOutput : DWORD -> 'uint32_t'
// pcbResult : DWORD* out -> 'uint32_t *'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ncrypt.dll", {
SslComputeSessionHash: { parameters: ["usize", "usize", "u32", "pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags)
// hSslProvider : NCRYPT_PROV_HANDLE -> "usize"
// hHandshakeHash : NCRYPT_HASH_HANDLE -> "usize"
// dwProtocol : DWORD -> "u32"
// pbOutput : BYTE* optional, out -> "pointer"
// cbOutput : DWORD -> "u32"
// pcbResult : DWORD* out -> "pointer"
// dwFlags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SslComputeSessionHash(
size_t hSslProvider,
size_t hHandshakeHash,
uint32_t dwProtocol,
uint8_t* pbOutput,
uint32_t cbOutput,
uint32_t* pcbResult,
uint32_t dwFlags);
C, "ncrypt.dll");
// $ffi->SslComputeSessionHash(hSslProvider, hHandshakeHash, dwProtocol, pbOutput, cbOutput, pcbResult, dwFlags);
// hSslProvider : NCRYPT_PROV_HANDLE
// hHandshakeHash : NCRYPT_HASH_HANDLE
// dwProtocol : DWORD
// pbOutput : BYTE* optional, out
// cbOutput : DWORD
// pcbResult : DWORD* out
// dwFlags : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Ncrypt extends StdCallLibrary {
Ncrypt INSTANCE = Native.load("ncrypt", Ncrypt.class);
int SslComputeSessionHash(
long hSslProvider, // NCRYPT_PROV_HANDLE
long hHandshakeHash, // NCRYPT_HASH_HANDLE
int dwProtocol, // DWORD
byte[] pbOutput, // BYTE* optional, out
int cbOutput, // DWORD
IntByReference pcbResult, // DWORD* out
int dwFlags // DWORD
);
}@[Link("ncrypt")]
lib Libncrypt
fun SslComputeSessionHash = SslComputeSessionHash(
hSslProvider : LibC::SizeT, # NCRYPT_PROV_HANDLE
hHandshakeHash : LibC::SizeT, # NCRYPT_HASH_HANDLE
dwProtocol : UInt32, # DWORD
pbOutput : UInt8*, # BYTE* optional, out
cbOutput : UInt32, # DWORD
pcbResult : UInt32*, # DWORD* out
dwFlags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SslComputeSessionHashNative = Int32 Function(UintPtr, UintPtr, Uint32, Pointer<Uint8>, Uint32, Pointer<Uint32>, Uint32);
typedef SslComputeSessionHashDart = int Function(int, int, int, Pointer<Uint8>, int, Pointer<Uint32>, int);
final SslComputeSessionHash = DynamicLibrary.open('ncrypt.dll')
.lookupFunction<SslComputeSessionHashNative, SslComputeSessionHashDart>('SslComputeSessionHash');
// hSslProvider : NCRYPT_PROV_HANDLE -> UintPtr
// hHandshakeHash : NCRYPT_HASH_HANDLE -> UintPtr
// dwProtocol : DWORD -> Uint32
// pbOutput : BYTE* optional, out -> Pointer<Uint8>
// cbOutput : DWORD -> Uint32
// pcbResult : DWORD* out -> Pointer<Uint32>
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SslComputeSessionHash"
c_SslComputeSessionHash :: CUIntPtr -> CUIntPtr -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word32 -> Word32 -> IO Int32
-- hSslProvider : NCRYPT_PROV_HANDLE -> CUIntPtr
-- hHandshakeHash : NCRYPT_HASH_HANDLE -> CUIntPtr
-- dwProtocol : DWORD -> Word32
-- pbOutput : BYTE* optional, out -> Ptr Word8
-- cbOutput : DWORD -> Word32
-- pcbResult : DWORD* out -> Ptr Word32
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sslcomputesessionhash =
foreign "SslComputeSessionHash"
(size_t @-> size_t @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> returning int32_t)
(* hSslProvider : NCRYPT_PROV_HANDLE -> size_t *)
(* hHandshakeHash : NCRYPT_HASH_HANDLE -> size_t *)
(* dwProtocol : DWORD -> uint32_t *)
(* pbOutput : BYTE* optional, out -> (ptr uint8_t) *)
(* cbOutput : DWORD -> uint32_t *)
(* pcbResult : DWORD* out -> (ptr uint32_t) *)
(* dwFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ncrypt (t "ncrypt.dll"))
(cffi:use-foreign-library ncrypt)
(cffi:defcfun ("SslComputeSessionHash" ssl-compute-session-hash :convention :stdcall) :int32
(h-ssl-provider :uint64) ; NCRYPT_PROV_HANDLE
(h-handshake-hash :uint64) ; NCRYPT_HASH_HANDLE
(dw-protocol :uint32) ; DWORD
(pb-output :pointer) ; BYTE* optional, out
(cb-output :uint32) ; DWORD
(pcb-result :pointer) ; DWORD* out
(dw-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SslComputeSessionHash = Win32::API::More->new('ncrypt',
'int SslComputeSessionHash(WPARAM hSslProvider, WPARAM hHandshakeHash, DWORD dwProtocol, LPVOID pbOutput, DWORD cbOutput, LPVOID pcbResult, DWORD dwFlags)');
# my $ret = $SslComputeSessionHash->Call($hSslProvider, $hHandshakeHash, $dwProtocol, $pbOutput, $cbOutput, $pcbResult, $dwFlags);
# hSslProvider : NCRYPT_PROV_HANDLE -> WPARAM
# hHandshakeHash : NCRYPT_HASH_HANDLE -> WPARAM
# dwProtocol : DWORD -> DWORD
# pbOutput : BYTE* optional, out -> LPVOID
# cbOutput : DWORD -> DWORD
# pcbResult : DWORD* out -> LPVOID
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。