ホーム › Security.Cryptography › SslCreateHandshakeHash
SslCreateHandshakeHash
関数SSLハンドシェイク用のハッシュオブジェクトを作成する。
シグネチャ
// ncrypt.dll
#include <windows.h>
HRESULT SslCreateHandshakeHash(
NCRYPT_PROV_HANDLE hSslProvider,
NCRYPT_HASH_HANDLE* phHandshakeHash,
DWORD dwProtocol,
DWORD dwCipherSuite,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSslProvider | NCRYPT_PROV_HANDLE | in |
| phHandshakeHash | NCRYPT_HASH_HANDLE* | out |
| dwProtocol | DWORD | in |
| dwCipherSuite | DWORD | in |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
HRESULT SslCreateHandshakeHash(
NCRYPT_PROV_HANDLE hSslProvider,
NCRYPT_HASH_HANDLE* phHandshakeHash,
DWORD dwProtocol,
DWORD dwCipherSuite,
DWORD dwFlags
);[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int SslCreateHandshakeHash(
UIntPtr hSslProvider, // NCRYPT_PROV_HANDLE
out UIntPtr phHandshakeHash, // NCRYPT_HASH_HANDLE* out
uint dwProtocol, // DWORD
uint dwCipherSuite, // DWORD
uint dwFlags // DWORD
);<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function SslCreateHandshakeHash(
hSslProvider As UIntPtr, ' NCRYPT_PROV_HANDLE
<Out> ByRef phHandshakeHash As UIntPtr, ' NCRYPT_HASH_HANDLE* out
dwProtocol As UInteger, ' DWORD
dwCipherSuite As UInteger, ' DWORD
dwFlags As UInteger ' DWORD
) As Integer
End Function' hSslProvider : NCRYPT_PROV_HANDLE
' phHandshakeHash : NCRYPT_HASH_HANDLE* out
' dwProtocol : DWORD
' dwCipherSuite : DWORD
' dwFlags : DWORD
Declare PtrSafe Function SslCreateHandshakeHash Lib "ncrypt" ( _
ByVal hSslProvider As LongPtr, _
ByRef phHandshakeHash As LongPtr, _
ByVal dwProtocol As Long, _
ByVal dwCipherSuite 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
SslCreateHandshakeHash = ctypes.windll.ncrypt.SslCreateHandshakeHash
SslCreateHandshakeHash.restype = ctypes.c_int
SslCreateHandshakeHash.argtypes = [
ctypes.c_size_t, # hSslProvider : NCRYPT_PROV_HANDLE
ctypes.c_void_p, # phHandshakeHash : NCRYPT_HASH_HANDLE* out
wintypes.DWORD, # dwProtocol : DWORD
wintypes.DWORD, # dwCipherSuite : DWORD
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ncrypt.dll')
SslCreateHandshakeHash = Fiddle::Function.new(
lib['SslCreateHandshakeHash'],
[
Fiddle::TYPE_UINTPTR_T, # hSslProvider : NCRYPT_PROV_HANDLE
Fiddle::TYPE_VOIDP, # phHandshakeHash : NCRYPT_HASH_HANDLE* out
-Fiddle::TYPE_INT, # dwProtocol : DWORD
-Fiddle::TYPE_INT, # dwCipherSuite : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ncrypt")]
extern "system" {
fn SslCreateHandshakeHash(
hSslProvider: usize, // NCRYPT_PROV_HANDLE
phHandshakeHash: *mut usize, // NCRYPT_HASH_HANDLE* out
dwProtocol: u32, // DWORD
dwCipherSuite: u32, // DWORD
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ncrypt.dll")]
public static extern int SslCreateHandshakeHash(UIntPtr hSslProvider, out UIntPtr phHandshakeHash, uint dwProtocol, uint dwCipherSuite, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_SslCreateHandshakeHash' -Namespace Win32 -PassThru
# $api::SslCreateHandshakeHash(hSslProvider, phHandshakeHash, dwProtocol, dwCipherSuite, dwFlags)#uselib "ncrypt.dll"
#func global SslCreateHandshakeHash "SslCreateHandshakeHash" sptr, sptr, sptr, sptr, sptr
; SslCreateHandshakeHash hSslProvider, phHandshakeHash, dwProtocol, dwCipherSuite, dwFlags ; 戻り値は stat
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; phHandshakeHash : NCRYPT_HASH_HANDLE* out -> "sptr"
; dwProtocol : DWORD -> "sptr"
; dwCipherSuite : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ncrypt.dll"
#cfunc global SslCreateHandshakeHash "SslCreateHandshakeHash" sptr, int, int, int, int
; res = SslCreateHandshakeHash(hSslProvider, phHandshakeHash, dwProtocol, dwCipherSuite, dwFlags)
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; phHandshakeHash : NCRYPT_HASH_HANDLE* out -> "int"
; dwProtocol : DWORD -> "int"
; dwCipherSuite : DWORD -> "int"
; dwFlags : DWORD -> "int"; HRESULT SslCreateHandshakeHash(NCRYPT_PROV_HANDLE hSslProvider, NCRYPT_HASH_HANDLE* phHandshakeHash, DWORD dwProtocol, DWORD dwCipherSuite, DWORD dwFlags)
#uselib "ncrypt.dll"
#cfunc global SslCreateHandshakeHash "SslCreateHandshakeHash" intptr, int, int, int, int
; res = SslCreateHandshakeHash(hSslProvider, phHandshakeHash, dwProtocol, dwCipherSuite, dwFlags)
; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr"
; phHandshakeHash : NCRYPT_HASH_HANDLE* out -> "int"
; dwProtocol : DWORD -> "int"
; dwCipherSuite : DWORD -> "int"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
procSslCreateHandshakeHash = ncrypt.NewProc("SslCreateHandshakeHash")
)
// hSslProvider (NCRYPT_PROV_HANDLE), phHandshakeHash (NCRYPT_HASH_HANDLE* out), dwProtocol (DWORD), dwCipherSuite (DWORD), dwFlags (DWORD)
r1, _, err := procSslCreateHandshakeHash.Call(
uintptr(hSslProvider),
uintptr(phHandshakeHash),
uintptr(dwProtocol),
uintptr(dwCipherSuite),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SslCreateHandshakeHash(
hSslProvider: NativeUInt; // NCRYPT_PROV_HANDLE
phHandshakeHash: Pointer; // NCRYPT_HASH_HANDLE* out
dwProtocol: DWORD; // DWORD
dwCipherSuite: DWORD; // DWORD
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'SslCreateHandshakeHash';result := DllCall("ncrypt\SslCreateHandshakeHash"
, "UPtr", hSslProvider ; NCRYPT_PROV_HANDLE
, "Ptr", phHandshakeHash ; NCRYPT_HASH_HANDLE* out
, "UInt", dwProtocol ; DWORD
, "UInt", dwCipherSuite ; DWORD
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●SslCreateHandshakeHash(hSslProvider, phHandshakeHash, dwProtocol, dwCipherSuite, dwFlags) = DLL("ncrypt.dll", "int SslCreateHandshakeHash(int, void*, dword, dword, dword)")
# 呼び出し: SslCreateHandshakeHash(hSslProvider, phHandshakeHash, dwProtocol, dwCipherSuite, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> "int"
# phHandshakeHash : NCRYPT_HASH_HANDLE* out -> "void*"
# dwProtocol : DWORD -> "dword"
# dwCipherSuite : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。