ホーム › Security.Cryptography › SslLookupCipherLengths
SslLookupCipherLengths
関数指定暗号スイートの鍵やMACなどの長さ情報を取得する。
シグネチャ
// ncrypt.dll
#include <windows.h>
HRESULT SslLookupCipherLengths(
NCRYPT_PROV_HANDLE hSslProvider,
DWORD dwProtocol,
DWORD dwCipherSuite,
DWORD dwKeyType,
NCRYPT_SSL_CIPHER_LENGTHS* pCipherLengths,
DWORD cbCipherLengths,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSslProvider | NCRYPT_PROV_HANDLE | in |
| dwProtocol | DWORD | in |
| dwCipherSuite | DWORD | in |
| dwKeyType | DWORD | in |
| pCipherLengths | NCRYPT_SSL_CIPHER_LENGTHS* | out |
| cbCipherLengths | DWORD | in |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
HRESULT SslLookupCipherLengths(
NCRYPT_PROV_HANDLE hSslProvider,
DWORD dwProtocol,
DWORD dwCipherSuite,
DWORD dwKeyType,
NCRYPT_SSL_CIPHER_LENGTHS* pCipherLengths,
DWORD cbCipherLengths,
DWORD dwFlags
);[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int SslLookupCipherLengths(
UIntPtr hSslProvider, // NCRYPT_PROV_HANDLE
uint dwProtocol, // DWORD
uint dwCipherSuite, // DWORD
uint dwKeyType, // DWORD
IntPtr pCipherLengths, // NCRYPT_SSL_CIPHER_LENGTHS* out
uint cbCipherLengths, // DWORD
uint dwFlags // DWORD
);<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function SslLookupCipherLengths(
hSslProvider As UIntPtr, ' NCRYPT_PROV_HANDLE
dwProtocol As UInteger, ' DWORD
dwCipherSuite As UInteger, ' DWORD
dwKeyType As UInteger, ' DWORD
pCipherLengths As IntPtr, ' NCRYPT_SSL_CIPHER_LENGTHS* out
cbCipherLengths As UInteger, ' DWORD
dwFlags As UInteger ' DWORD
) As Integer
End Function' hSslProvider : NCRYPT_PROV_HANDLE
' dwProtocol : DWORD
' dwCipherSuite : DWORD
' dwKeyType : DWORD
' pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out
' cbCipherLengths : DWORD
' dwFlags : DWORD
Declare PtrSafe Function SslLookupCipherLengths Lib "ncrypt" ( _
ByVal hSslProvider As LongPtr, _
ByVal dwProtocol As Long, _
ByVal dwCipherSuite As Long, _
ByVal dwKeyType As Long, _
ByVal pCipherLengths As LongPtr, _
ByVal cbCipherLengths 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
SslLookupCipherLengths = ctypes.windll.ncrypt.SslLookupCipherLengths
SslLookupCipherLengths.restype = ctypes.c_int
SslLookupCipherLengths.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, # pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out
wintypes.DWORD, # cbCipherLengths : DWORD
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ncrypt.dll')
SslLookupCipherLengths = Fiddle::Function.new(
lib['SslLookupCipherLengths'],
[
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, # pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out
-Fiddle::TYPE_INT, # cbCipherLengths : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ncrypt")]
extern "system" {
fn SslLookupCipherLengths(
hSslProvider: usize, // NCRYPT_PROV_HANDLE
dwProtocol: u32, // DWORD
dwCipherSuite: u32, // DWORD
dwKeyType: u32, // DWORD
pCipherLengths: *mut NCRYPT_SSL_CIPHER_LENGTHS, // NCRYPT_SSL_CIPHER_LENGTHS* out
cbCipherLengths: u32, // DWORD
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ncrypt.dll")]
public static extern int SslLookupCipherLengths(UIntPtr hSslProvider, uint dwProtocol, uint dwCipherSuite, uint dwKeyType, IntPtr pCipherLengths, uint cbCipherLengths, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_SslLookupCipherLengths' -Namespace Win32 -PassThru
# $api::SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, pCipherLengths, cbCipherLengths, dwFlags)#uselib "ncrypt.dll"
#func global SslLookupCipherLengths "SslLookupCipherLengths" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SslLookupCipherLengths hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, varptr(pCipherLengths), cbCipherLengths, dwFlags ; 戻り値は stat
; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr"
; dwProtocol : DWORD -> "sptr"
; dwCipherSuite : DWORD -> "sptr"
; dwKeyType : DWORD -> "sptr"
; pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out -> "sptr"
; cbCipherLengths : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ncrypt.dll" #cfunc global SslLookupCipherLengths "SslLookupCipherLengths" sptr, int, int, int, var, int, int ; res = SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, pCipherLengths, cbCipherLengths, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr" ; dwProtocol : DWORD -> "int" ; dwCipherSuite : DWORD -> "int" ; dwKeyType : DWORD -> "int" ; pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out -> "var" ; cbCipherLengths : DWORD -> "int" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ncrypt.dll" #cfunc global SslLookupCipherLengths "SslLookupCipherLengths" sptr, int, int, int, sptr, int, int ; res = SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, varptr(pCipherLengths), cbCipherLengths, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "sptr" ; dwProtocol : DWORD -> "int" ; dwCipherSuite : DWORD -> "int" ; dwKeyType : DWORD -> "int" ; pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out -> "sptr" ; cbCipherLengths : DWORD -> "int" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SslLookupCipherLengths(NCRYPT_PROV_HANDLE hSslProvider, DWORD dwProtocol, DWORD dwCipherSuite, DWORD dwKeyType, NCRYPT_SSL_CIPHER_LENGTHS* pCipherLengths, DWORD cbCipherLengths, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global SslLookupCipherLengths "SslLookupCipherLengths" intptr, int, int, int, var, int, int ; res = SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, pCipherLengths, cbCipherLengths, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr" ; dwProtocol : DWORD -> "int" ; dwCipherSuite : DWORD -> "int" ; dwKeyType : DWORD -> "int" ; pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out -> "var" ; cbCipherLengths : DWORD -> "int" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SslLookupCipherLengths(NCRYPT_PROV_HANDLE hSslProvider, DWORD dwProtocol, DWORD dwCipherSuite, DWORD dwKeyType, NCRYPT_SSL_CIPHER_LENGTHS* pCipherLengths, DWORD cbCipherLengths, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global SslLookupCipherLengths "SslLookupCipherLengths" intptr, int, int, int, intptr, int, int ; res = SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, varptr(pCipherLengths), cbCipherLengths, dwFlags) ; hSslProvider : NCRYPT_PROV_HANDLE -> "intptr" ; dwProtocol : DWORD -> "int" ; dwCipherSuite : DWORD -> "int" ; dwKeyType : DWORD -> "int" ; pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out -> "intptr" ; cbCipherLengths : DWORD -> "int" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
procSslLookupCipherLengths = ncrypt.NewProc("SslLookupCipherLengths")
)
// hSslProvider (NCRYPT_PROV_HANDLE), dwProtocol (DWORD), dwCipherSuite (DWORD), dwKeyType (DWORD), pCipherLengths (NCRYPT_SSL_CIPHER_LENGTHS* out), cbCipherLengths (DWORD), dwFlags (DWORD)
r1, _, err := procSslLookupCipherLengths.Call(
uintptr(hSslProvider),
uintptr(dwProtocol),
uintptr(dwCipherSuite),
uintptr(dwKeyType),
uintptr(pCipherLengths),
uintptr(cbCipherLengths),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SslLookupCipherLengths(
hSslProvider: NativeUInt; // NCRYPT_PROV_HANDLE
dwProtocol: DWORD; // DWORD
dwCipherSuite: DWORD; // DWORD
dwKeyType: DWORD; // DWORD
pCipherLengths: Pointer; // NCRYPT_SSL_CIPHER_LENGTHS* out
cbCipherLengths: DWORD; // DWORD
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'SslLookupCipherLengths';result := DllCall("ncrypt\SslLookupCipherLengths"
, "UPtr", hSslProvider ; NCRYPT_PROV_HANDLE
, "UInt", dwProtocol ; DWORD
, "UInt", dwCipherSuite ; DWORD
, "UInt", dwKeyType ; DWORD
, "Ptr", pCipherLengths ; NCRYPT_SSL_CIPHER_LENGTHS* out
, "UInt", cbCipherLengths ; DWORD
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, pCipherLengths, cbCipherLengths, dwFlags) = DLL("ncrypt.dll", "int SslLookupCipherLengths(int, dword, dword, dword, void*, dword, dword)")
# 呼び出し: SslLookupCipherLengths(hSslProvider, dwProtocol, dwCipherSuite, dwKeyType, pCipherLengths, cbCipherLengths, dwFlags)
# hSslProvider : NCRYPT_PROV_HANDLE -> "int"
# dwProtocol : DWORD -> "dword"
# dwCipherSuite : DWORD -> "dword"
# dwKeyType : DWORD -> "dword"
# pCipherLengths : NCRYPT_SSL_CIPHER_LENGTHS* out -> "void*"
# cbCipherLengths : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。