Win32 API 日本語リファレンス
ホームSecurity.Authentication.WebAuthn › WebAuthNAuthenticatorGetAssertion

WebAuthNAuthenticatorGetAssertion

関数
認証器を用いてWebAuthnのアサーション(認証)を取得する。
DLLwebauthn.dll呼出規約winapi

シグネチャ

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

HRESULT WebAuthNAuthenticatorGetAssertion(
    HWND hWnd,
    LPCWSTR pwszRpId,
    WEBAUTHN_CLIENT_DATA* pWebAuthNClientData,
    WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* pWebAuthNGetAssertionOptions,   // optional
    WEBAUTHN_ASSERTION** ppWebAuthNAssertion
);

パラメーター

名前方向
hWndHWNDin
pwszRpIdLPCWSTRin
pWebAuthNClientDataWEBAUTHN_CLIENT_DATA*in
pWebAuthNGetAssertionOptionsWEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS*inoptional
ppWebAuthNAssertionWEBAUTHN_ASSERTION**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WebAuthNAuthenticatorGetAssertion(
    HWND hWnd,
    LPCWSTR pwszRpId,
    WEBAUTHN_CLIENT_DATA* pWebAuthNClientData,
    WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* pWebAuthNGetAssertionOptions,   // optional
    WEBAUTHN_ASSERTION** ppWebAuthNAssertion
);
[DllImport("webauthn.dll", ExactSpelling = true)]
static extern int WebAuthNAuthenticatorGetAssertion(
    IntPtr hWnd,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] string pwszRpId,   // LPCWSTR
    IntPtr pWebAuthNClientData,   // WEBAUTHN_CLIENT_DATA*
    IntPtr pWebAuthNGetAssertionOptions,   // WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
    IntPtr ppWebAuthNAssertion   // WEBAUTHN_ASSERTION** out
);
<DllImport("webauthn.dll", ExactSpelling:=True)>
Public Shared Function WebAuthNAuthenticatorGetAssertion(
    hWnd As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> pwszRpId As String,   ' LPCWSTR
    pWebAuthNClientData As IntPtr,   ' WEBAUTHN_CLIENT_DATA*
    pWebAuthNGetAssertionOptions As IntPtr,   ' WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
    ppWebAuthNAssertion As IntPtr   ' WEBAUTHN_ASSERTION** out
) As Integer
End Function
' hWnd : HWND
' pwszRpId : LPCWSTR
' pWebAuthNClientData : WEBAUTHN_CLIENT_DATA*
' pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
' ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out
Declare PtrSafe Function WebAuthNAuthenticatorGetAssertion Lib "webauthn" ( _
    ByVal hWnd As LongPtr, _
    ByVal pwszRpId As LongPtr, _
    ByVal pWebAuthNClientData As LongPtr, _
    ByVal pWebAuthNGetAssertionOptions As LongPtr, _
    ByVal ppWebAuthNAssertion As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WebAuthNAuthenticatorGetAssertion = ctypes.windll.webauthn.WebAuthNAuthenticatorGetAssertion
WebAuthNAuthenticatorGetAssertion.restype = ctypes.c_int
WebAuthNAuthenticatorGetAssertion.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND
    wintypes.LPCWSTR,  # pwszRpId : LPCWSTR
    ctypes.c_void_p,  # pWebAuthNClientData : WEBAUTHN_CLIENT_DATA*
    ctypes.c_void_p,  # pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
    ctypes.c_void_p,  # ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webauthn.dll')
WebAuthNAuthenticatorGetAssertion = Fiddle::Function.new(
  lib['WebAuthNAuthenticatorGetAssertion'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND
    Fiddle::TYPE_VOIDP,  # pwszRpId : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pWebAuthNClientData : WEBAUTHN_CLIENT_DATA*
    Fiddle::TYPE_VOIDP,  # pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
    Fiddle::TYPE_VOIDP,  # ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "webauthn")]
extern "system" {
    fn WebAuthNAuthenticatorGetAssertion(
        hWnd: *mut core::ffi::c_void,  // HWND
        pwszRpId: *const u16,  // LPCWSTR
        pWebAuthNClientData: *mut WEBAUTHN_CLIENT_DATA,  // WEBAUTHN_CLIENT_DATA*
        pWebAuthNGetAssertionOptions: *mut WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS,  // WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
        ppWebAuthNAssertion: *mut *mut WEBAUTHN_ASSERTION  // WEBAUTHN_ASSERTION** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webauthn.dll")]
public static extern int WebAuthNAuthenticatorGetAssertion(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string pwszRpId, IntPtr pWebAuthNClientData, IntPtr pWebAuthNGetAssertionOptions, IntPtr ppWebAuthNAssertion);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webauthn_WebAuthNAuthenticatorGetAssertion' -Namespace Win32 -PassThru
# $api::WebAuthNAuthenticatorGetAssertion(hWnd, pwszRpId, pWebAuthNClientData, pWebAuthNGetAssertionOptions, ppWebAuthNAssertion)
#uselib "webauthn.dll"
#func global WebAuthNAuthenticatorGetAssertion "WebAuthNAuthenticatorGetAssertion" sptr, sptr, sptr, sptr, sptr
; WebAuthNAuthenticatorGetAssertion hWnd, pwszRpId, varptr(pWebAuthNClientData), varptr(pWebAuthNGetAssertionOptions), varptr(ppWebAuthNAssertion)   ; 戻り値は stat
; hWnd : HWND -> "sptr"
; pwszRpId : LPCWSTR -> "sptr"
; pWebAuthNClientData : WEBAUTHN_CLIENT_DATA* -> "sptr"
; pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional -> "sptr"
; ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webauthn.dll"
#cfunc global WebAuthNAuthenticatorGetAssertion "WebAuthNAuthenticatorGetAssertion" sptr, wstr, var, var, var
; res = WebAuthNAuthenticatorGetAssertion(hWnd, pwszRpId, pWebAuthNClientData, pWebAuthNGetAssertionOptions, ppWebAuthNAssertion)
; hWnd : HWND -> "sptr"
; pwszRpId : LPCWSTR -> "wstr"
; pWebAuthNClientData : WEBAUTHN_CLIENT_DATA* -> "var"
; pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional -> "var"
; ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WebAuthNAuthenticatorGetAssertion(HWND hWnd, LPCWSTR pwszRpId, WEBAUTHN_CLIENT_DATA* pWebAuthNClientData, WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* pWebAuthNGetAssertionOptions, WEBAUTHN_ASSERTION** ppWebAuthNAssertion)
#uselib "webauthn.dll"
#cfunc global WebAuthNAuthenticatorGetAssertion "WebAuthNAuthenticatorGetAssertion" intptr, wstr, var, var, var
; res = WebAuthNAuthenticatorGetAssertion(hWnd, pwszRpId, pWebAuthNClientData, pWebAuthNGetAssertionOptions, ppWebAuthNAssertion)
; hWnd : HWND -> "intptr"
; pwszRpId : LPCWSTR -> "wstr"
; pWebAuthNClientData : WEBAUTHN_CLIENT_DATA* -> "var"
; pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional -> "var"
; ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webauthn = windows.NewLazySystemDLL("webauthn.dll")
	procWebAuthNAuthenticatorGetAssertion = webauthn.NewProc("WebAuthNAuthenticatorGetAssertion")
)

// hWnd (HWND), pwszRpId (LPCWSTR), pWebAuthNClientData (WEBAUTHN_CLIENT_DATA*), pWebAuthNGetAssertionOptions (WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional), ppWebAuthNAssertion (WEBAUTHN_ASSERTION** out)
r1, _, err := procWebAuthNAuthenticatorGetAssertion.Call(
	uintptr(hWnd),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszRpId))),
	uintptr(pWebAuthNClientData),
	uintptr(pWebAuthNGetAssertionOptions),
	uintptr(ppWebAuthNAssertion),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WebAuthNAuthenticatorGetAssertion(
  hWnd: THandle;   // HWND
  pwszRpId: PWideChar;   // LPCWSTR
  pWebAuthNClientData: Pointer;   // WEBAUTHN_CLIENT_DATA*
  pWebAuthNGetAssertionOptions: Pointer;   // WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
  ppWebAuthNAssertion: Pointer   // WEBAUTHN_ASSERTION** out
): Integer; stdcall;
  external 'webauthn.dll' name 'WebAuthNAuthenticatorGetAssertion';
result := DllCall("webauthn\WebAuthNAuthenticatorGetAssertion"
    , "Ptr", hWnd   ; HWND
    , "WStr", pwszRpId   ; LPCWSTR
    , "Ptr", pWebAuthNClientData   ; WEBAUTHN_CLIENT_DATA*
    , "Ptr", pWebAuthNGetAssertionOptions   ; WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional
    , "Ptr", ppWebAuthNAssertion   ; WEBAUTHN_ASSERTION** out
    , "Int")   ; return: HRESULT
●WebAuthNAuthenticatorGetAssertion(hWnd, pwszRpId, pWebAuthNClientData, pWebAuthNGetAssertionOptions, ppWebAuthNAssertion) = DLL("webauthn.dll", "int WebAuthNAuthenticatorGetAssertion(void*, char*, void*, void*, void*)")
# 呼び出し: WebAuthNAuthenticatorGetAssertion(hWnd, pwszRpId, pWebAuthNClientData, pWebAuthNGetAssertionOptions, ppWebAuthNAssertion)
# hWnd : HWND -> "void*"
# pwszRpId : LPCWSTR -> "char*"
# pWebAuthNClientData : WEBAUTHN_CLIENT_DATA* -> "void*"
# pWebAuthNGetAssertionOptions : WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS* optional -> "void*"
# ppWebAuthNAssertion : WEBAUTHN_ASSERTION** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。