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_HANDLEinSchannel SSLプロバイダのハンドル。
dwProtocolDWORDin対象のSSL/TLSプロトコルバージョンを示す値。
dwCipherSuiteDWORDin対象の暗号スイートを示す値。
dwKeyTypeDWORDin鍵の種類を示す値。
szPRFHashLPWSTRout暗号スイートのPRFで使うハッシュアルゴリズム名を受け取る出力バッファ。
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)。
const std = @import("std");

extern "ncrypt" fn SslGetCipherSuitePRFHashAlgorithm(
    hSslProvider: usize, // NCRYPT_PROV_HANDLE
    dwProtocol: u32, // DWORD
    dwCipherSuite: u32, // DWORD
    dwKeyType: u32, // DWORD
    szPRFHash: [*c]u16, // LPWSTR out
    dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc SslGetCipherSuitePRFHashAlgorithm(
    hSslProvider: uint,  # NCRYPT_PROV_HANDLE
    dwProtocol: uint32,  # DWORD
    dwCipherSuite: uint32,  # DWORD
    dwKeyType: uint32,  # DWORD
    szPRFHash: ptr uint16,  # LPWSTR out
    dwFlags: uint32  # DWORD
): int32 {.importc: "SslGetCipherSuitePRFHashAlgorithm", stdcall, dynlib: "ncrypt.dll".}
pragma(lib, "ncrypt");
extern(Windows)
int SslGetCipherSuitePRFHashAlgorithm(
    size_t hSslProvider,   // NCRYPT_PROV_HANDLE
    uint dwProtocol,   // DWORD
    uint dwCipherSuite,   // DWORD
    uint dwKeyType,   // DWORD
    wchar* szPRFHash,   // LPWSTR out
    uint dwFlags   // DWORD
);
ccall((:SslGetCipherSuitePRFHashAlgorithm, "ncrypt.dll"), stdcall, Int32,
      (Csize_t, UInt32, UInt32, UInt32, Ptr{UInt16}, UInt32),
      hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> Csize_t
# dwProtocol : DWORD -> UInt32
# dwCipherSuite : DWORD -> UInt32
# dwKeyType : DWORD -> UInt32
# szPRFHash : LPWSTR out -> Ptr{UInt16}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SslGetCipherSuitePRFHashAlgorithm(
    uintptr_t hSslProvider,
    uint32_t dwProtocol,
    uint32_t dwCipherSuite,
    uint32_t dwKeyType,
    uint16_t* szPRFHash,
    uint32_t dwFlags);
]]
local ncrypt = ffi.load("ncrypt")
-- ncrypt.SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
-- hSslProvider : NCRYPT_PROV_HANDLE
-- dwProtocol : DWORD
-- dwCipherSuite : DWORD
-- dwKeyType : DWORD
-- szPRFHash : LPWSTR out
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ncrypt.dll');
const SslGetCipherSuitePRFHashAlgorithm = lib.func('__stdcall', 'SslGetCipherSuitePRFHashAlgorithm', 'int32_t', ['uintptr_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint16_t *', 'uint32_t']);
// SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
// hSslProvider : NCRYPT_PROV_HANDLE -> 'uintptr_t'
// dwProtocol : DWORD -> 'uint32_t'
// dwCipherSuite : DWORD -> 'uint32_t'
// dwKeyType : DWORD -> 'uint32_t'
// szPRFHash : LPWSTR out -> 'uint16_t *'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ncrypt.dll", {
  SslGetCipherSuitePRFHashAlgorithm: { parameters: ["usize", "u32", "u32", "u32", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags)
// hSslProvider : NCRYPT_PROV_HANDLE -> "usize"
// dwProtocol : DWORD -> "u32"
// dwCipherSuite : DWORD -> "u32"
// dwKeyType : DWORD -> "u32"
// szPRFHash : LPWSTR out -> "buffer"
// dwFlags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SslGetCipherSuitePRFHashAlgorithm(
    size_t hSslProvider,
    uint32_t dwProtocol,
    uint32_t dwCipherSuite,
    uint32_t dwKeyType,
    uint16_t* szPRFHash,
    uint32_t dwFlags);
C, "ncrypt.dll");
// $ffi->SslGetCipherSuitePRFHashAlgorithm(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, szPRFHash, dwFlags);
// hSslProvider : NCRYPT_PROV_HANDLE
// dwProtocol : DWORD
// dwCipherSuite : DWORD
// dwKeyType : DWORD
// szPRFHash : LPWSTR 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 SslGetCipherSuitePRFHashAlgorithm(
        long hSslProvider,   // NCRYPT_PROV_HANDLE
        int dwProtocol,   // DWORD
        int dwCipherSuite,   // DWORD
        int dwKeyType,   // DWORD
        char[] szPRFHash,   // LPWSTR out
        int dwFlags   // DWORD
    );
}
@[Link("ncrypt")]
lib Libncrypt
  fun SslGetCipherSuitePRFHashAlgorithm = SslGetCipherSuitePRFHashAlgorithm(
    hSslProvider : LibC::SizeT,   # NCRYPT_PROV_HANDLE
    dwProtocol : UInt32,   # DWORD
    dwCipherSuite : UInt32,   # DWORD
    dwKeyType : UInt32,   # DWORD
    szPRFHash : UInt16*,   # LPWSTR 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 SslGetCipherSuitePRFHashAlgorithmNative = Int32 Function(UintPtr, Uint32, Uint32, Uint32, Pointer<Utf16>, Uint32);
typedef SslGetCipherSuitePRFHashAlgorithmDart = int Function(int, int, int, int, Pointer<Utf16>, int);
final SslGetCipherSuitePRFHashAlgorithm = DynamicLibrary.open('ncrypt.dll')
    .lookupFunction<SslGetCipherSuitePRFHashAlgorithmNative, SslGetCipherSuitePRFHashAlgorithmDart>('SslGetCipherSuitePRFHashAlgorithm');
// hSslProvider : NCRYPT_PROV_HANDLE -> UintPtr
// dwProtocol : DWORD -> Uint32
// dwCipherSuite : DWORD -> Uint32
// dwKeyType : DWORD -> Uint32
// szPRFHash : LPWSTR out -> Pointer<Utf16>
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SslGetCipherSuitePRFHashAlgorithm"
  c_SslGetCipherSuitePRFHashAlgorithm :: CUIntPtr -> Word32 -> Word32 -> Word32 -> CWString -> Word32 -> IO Int32
-- hSslProvider : NCRYPT_PROV_HANDLE -> CUIntPtr
-- dwProtocol : DWORD -> Word32
-- dwCipherSuite : DWORD -> Word32
-- dwKeyType : DWORD -> Word32
-- szPRFHash : LPWSTR out -> CWString
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sslgetciphersuiteprfhashalgorithm =
  foreign "SslGetCipherSuitePRFHashAlgorithm"
    (size_t @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hSslProvider : NCRYPT_PROV_HANDLE -> size_t *)
(* dwProtocol : DWORD -> uint32_t *)
(* dwCipherSuite : DWORD -> uint32_t *)
(* dwKeyType : DWORD -> uint32_t *)
(* szPRFHash : LPWSTR out -> (ptr uint16_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 ("SslGetCipherSuitePRFHashAlgorithm" ssl-get-cipher-suite-prfhash-algorithm :convention :stdcall) :int32
  (h-ssl-provider :uint64)   ; NCRYPT_PROV_HANDLE
  (dw-protocol :uint32)   ; DWORD
  (dw-cipher-suite :uint32)   ; DWORD
  (dw-key-type :uint32)   ; DWORD
  (sz-prfhash :pointer)   ; LPWSTR out
  (dw-flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SslGetCipherSuitePRFHashAlgorithm = Win32::API::More->new('ncrypt',
    'int SslGetCipherSuitePRFHashAlgorithm(WPARAM hSslProvider, DWORD dwProtocol, DWORD dwCipherSuite, DWORD dwKeyType, LPWSTR szPRFHash, DWORD dwFlags)');
# my $ret = $SslGetCipherSuitePRFHashAlgorithm->Call($hSslProvider, $dwProtocol, $dwCipherSuite, $dwKeyType, $szPRFHash, $dwFlags);
# hSslProvider : NCRYPT_PROV_HANDLE -> WPARAM
# dwProtocol : DWORD -> DWORD
# dwCipherSuite : DWORD -> DWORD
# dwKeyType : DWORD -> DWORD
# szPRFHash : LPWSTR out -> LPWSTR
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。