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

SslLookupCipherSuiteInfo

関数
指定した暗号スイートの情報を取得する。
DLLncrypt.dll呼出規約winapi

シグネチャ

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

HRESULT SslLookupCipherSuiteInfo(
    NCRYPT_PROV_HANDLE hSslProvider,
    DWORD dwProtocol,
    DWORD dwCipherSuite,
    DWORD dwKeyType,
    NCRYPT_SSL_CIPHER_SUITE* pCipherSuite,
    DWORD dwFlags
);

パラメーター

名前方向説明
hSslProviderNCRYPT_PROV_HANDLEinSchannel SSLプロバイダのハンドル。
dwProtocolDWORDin対象のSSL/TLSプロトコルバージョンを示す値。
dwCipherSuiteDWORDin情報を取得する暗号スイートを示す値。
dwKeyTypeDWORDin鍵の種類を示す値。
pCipherSuiteNCRYPT_SSL_CIPHER_SUITE*out取得した暗号スイート情報を格納するNCRYPT_SSL_CIPHER_SUITE。
dwFlagsDWORDin動作を制御するフラグ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SslLookupCipherSuiteInfo(
    NCRYPT_PROV_HANDLE hSslProvider,
    DWORD dwProtocol,
    DWORD dwCipherSuite,
    DWORD dwKeyType,
    NCRYPT_SSL_CIPHER_SUITE* pCipherSuite,
    DWORD dwFlags
);
[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int SslLookupCipherSuiteInfo(
    UIntPtr hSslProvider,   // NCRYPT_PROV_HANDLE
    uint dwProtocol,   // DWORD
    uint dwCipherSuite,   // DWORD
    uint dwKeyType,   // DWORD
    IntPtr pCipherSuite,   // NCRYPT_SSL_CIPHER_SUITE* out
    uint dwFlags   // DWORD
);
<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function SslLookupCipherSuiteInfo(
    hSslProvider As UIntPtr,   ' NCRYPT_PROV_HANDLE
    dwProtocol As UInteger,   ' DWORD
    dwCipherSuite As UInteger,   ' DWORD
    dwKeyType As UInteger,   ' DWORD
    pCipherSuite As IntPtr,   ' NCRYPT_SSL_CIPHER_SUITE* out
    dwFlags As UInteger   ' DWORD
) As Integer
End Function
' hSslProvider : NCRYPT_PROV_HANDLE
' dwProtocol : DWORD
' dwCipherSuite : DWORD
' dwKeyType : DWORD
' pCipherSuite : NCRYPT_SSL_CIPHER_SUITE* out
' dwFlags : DWORD
Declare PtrSafe Function SslLookupCipherSuiteInfo Lib "ncrypt" ( _
    ByVal hSslProvider As LongPtr, _
    ByVal dwProtocol As Long, _
    ByVal dwCipherSuite As Long, _
    ByVal dwKeyType As Long, _
    ByVal pCipherSuite 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

SslLookupCipherSuiteInfo = ctypes.windll.ncrypt.SslLookupCipherSuiteInfo
SslLookupCipherSuiteInfo.restype = ctypes.c_int
SslLookupCipherSuiteInfo.argtypes = [
    ctypes.c_size_t,  # hSslProvider : NCRYPT_PROV_HANDLE
    wintypes.DWORD,  # dwProtocol : DWORD
    wintypes.DWORD,  # dwCipherSuite : DWORD
    wintypes.DWORD,  # dwKeyType : DWORD
    ctypes.c_void_p,  # pCipherSuite : NCRYPT_SSL_CIPHER_SUITE* out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
	procSslLookupCipherSuiteInfo = ncrypt.NewProc("SslLookupCipherSuiteInfo")
)

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

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

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

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

関連項目

使用する型