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

SslGetCipherSuitePRFHashAlgorithm

関数
暗号スイートのPRFハッシュアルゴリズム名を取得する。
DLLncrypt.dll呼出規約winapi

シグネチャ

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

HRESULT SslGetCipherSuitePRFHashAlgorithm(
    NCRYPT_PROV_HANDLE hSslProvider,
    DWORD dwProtocol,
    DWORD dwCipherSuite,
    DWORD dwKeyType,
    LPWSTR szPRFHash,
    DWORD dwFlags
);

パラメーター

名前方向
hSslProviderNCRYPT_PROV_HANDLEin
dwProtocolDWORDin
dwCipherSuiteDWORDin
dwKeyTypeDWORDin
szPRFHashLPWSTRout
dwFlagsDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SslGetCipherSuitePRFHashAlgorithm(
    NCRYPT_PROV_HANDLE hSslProvider,
    DWORD dwProtocol,
    DWORD dwCipherSuite,
    DWORD dwKeyType,
    LPWSTR szPRFHash,
    DWORD dwFlags
);
[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int SslGetCipherSuitePRFHashAlgorithm(
    UIntPtr hSslProvider,   // NCRYPT_PROV_HANDLE
    uint dwProtocol,   // DWORD
    uint dwCipherSuite,   // DWORD
    uint dwKeyType,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szPRFHash,   // LPWSTR out
    uint dwFlags   // DWORD
);
<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function SslGetCipherSuitePRFHashAlgorithm(
    hSslProvider As UIntPtr,   ' NCRYPT_PROV_HANDLE
    dwProtocol As UInteger,   ' DWORD
    dwCipherSuite As UInteger,   ' DWORD
    dwKeyType As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> szPRFHash As System.Text.StringBuilder,   ' LPWSTR out
    dwFlags As UInteger   ' DWORD
) As Integer
End Function
' hSslProvider : NCRYPT_PROV_HANDLE
' dwProtocol : DWORD
' dwCipherSuite : DWORD
' dwKeyType : DWORD
' szPRFHash : LPWSTR out
' dwFlags : DWORD
Declare PtrSafe Function SslGetCipherSuitePRFHashAlgorithm Lib "ncrypt" ( _
    ByVal hSslProvider As LongPtr, _
    ByVal dwProtocol As Long, _
    ByVal dwCipherSuite As Long, _
    ByVal dwKeyType As Long, _
    ByVal szPRFHash 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

SslGetCipherSuitePRFHashAlgorithm = ctypes.windll.ncrypt.SslGetCipherSuitePRFHashAlgorithm
SslGetCipherSuitePRFHashAlgorithm.restype = ctypes.c_int
SslGetCipherSuitePRFHashAlgorithm.argtypes = [
    ctypes.c_size_t,  # hSslProvider : NCRYPT_PROV_HANDLE
    wintypes.DWORD,  # dwProtocol : DWORD
    wintypes.DWORD,  # dwCipherSuite : DWORD
    wintypes.DWORD,  # dwKeyType : DWORD
    wintypes.LPWSTR,  # szPRFHash : LPWSTR out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ncrypt.dll')
SslGetCipherSuitePRFHashAlgorithm = Fiddle::Function.new(
  lib['SslGetCipherSuitePRFHashAlgorithm'],
  [
    Fiddle::TYPE_UINTPTR_T,  # hSslProvider : NCRYPT_PROV_HANDLE
    -Fiddle::TYPE_INT,  # dwProtocol : DWORD
    -Fiddle::TYPE_INT,  # dwCipherSuite : DWORD
    -Fiddle::TYPE_INT,  # dwKeyType : DWORD
    Fiddle::TYPE_VOIDP,  # szPRFHash : LPWSTR out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "ncrypt")]
extern "system" {
    fn SslGetCipherSuitePRFHashAlgorithm(
        hSslProvider: usize,  // NCRYPT_PROV_HANDLE
        dwProtocol: u32,  // DWORD
        dwCipherSuite: u32,  // DWORD
        dwKeyType: u32,  // DWORD
        szPRFHash: *mut u16,  // LPWSTR out
        dwFlags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ncrypt.dll")]
public static extern int SslGetCipherSuitePRFHashAlgorithm(UIntPtr hSslProvider, uint dwProtocol, uint dwCipherSuite, uint dwKeyType, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szPRFHash, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_SslGetCipherSuitePRFHashAlgorithm' -Namespace Win32 -PassThru
# $api::SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
#uselib "ncrypt.dll"
#func global SslGetCipherSuitePRFHashAlgorithm "SslGetCipherSuitePRFHashAlgorithm" sptr, sptr, sptr, sptr, sptr, sptr
; SslGetCipherSuitePRFHashAlgorithm hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, varptr(szPRFHash), dwFlags   ; 戻り値は stat
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; dwProtocol : DWORD -> "sptr"
; dwCipherSuite : DWORD -> "sptr"
; dwKeyType : DWORD -> "sptr"
; szPRFHash : LPWSTR out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ncrypt.dll"
#cfunc global SslGetCipherSuitePRFHashAlgorithm "SslGetCipherSuitePRFHashAlgorithm" sptr, int, int, int, var, int
; res = SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; dwProtocol : DWORD -> "int"
; dwCipherSuite : DWORD -> "int"
; dwKeyType : DWORD -> "int"
; szPRFHash : LPWSTR out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SslGetCipherSuitePRFHashAlgorithm(NCRYPT_PROV_HANDLE hSslProvider, DWORD dwProtocol, DWORD dwCipherSuite, DWORD dwKeyType, LPWSTR szPRFHash, DWORD dwFlags)
#uselib "ncrypt.dll"
#cfunc global SslGetCipherSuitePRFHashAlgorithm "SslGetCipherSuitePRFHashAlgorithm" intptr, int, int, int, var, int
; res = SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr"
; dwProtocol : DWORD -> "int"
; dwCipherSuite : DWORD -> "int"
; dwKeyType : DWORD -> "int"
; szPRFHash : LPWSTR out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
	procSslGetCipherSuitePRFHashAlgorithm = ncrypt.NewProc("SslGetCipherSuitePRFHashAlgorithm")
)

// hSslProvider (NCRYPT_PROV_HANDLE), dwProtocol (DWORD), dwCipherSuite (DWORD), dwKeyType (DWORD), szPRFHash (LPWSTR out), dwFlags (DWORD)
r1, _, err := procSslGetCipherSuitePRFHashAlgorithm.Call(
	uintptr(hSslProvider),
	uintptr(dwProtocol),
	uintptr(dwCipherSuite),
	uintptr(dwKeyType),
	uintptr(szPRFHash),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SslGetCipherSuitePRFHashAlgorithm(
  hSslProvider: NativeUInt;   // NCRYPT_PROV_HANDLE
  dwProtocol: DWORD;   // DWORD
  dwCipherSuite: DWORD;   // DWORD
  dwKeyType: DWORD;   // DWORD
  szPRFHash: PWideChar;   // LPWSTR out
  dwFlags: DWORD   // DWORD
): Integer; stdcall;
  external 'ncrypt.dll' name 'SslGetCipherSuitePRFHashAlgorithm';
result := DllCall("ncrypt\SslGetCipherSuitePRFHashAlgorithm"
    , "UPtr", hSslProvider   ; NCRYPT_PROV_HANDLE
    , "UInt", dwProtocol   ; DWORD
    , "UInt", dwCipherSuite   ; DWORD
    , "UInt", dwKeyType   ; DWORD
    , "Ptr", szPRFHash   ; LPWSTR out
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: HRESULT
●SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags) = DLL("ncrypt.dll", "int SslGetCipherSuitePRFHashAlgorithm(int, dword, dword, dword, char*, dword)")
# 呼び出し: SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> "int"
# dwProtocol : DWORD -> "dword"
# dwCipherSuite : DWORD -> "dword"
# dwKeyType : DWORD -> "dword"
# szPRFHash : LPWSTR out -> "char*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。