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