ホーム › Security.Cryptography › NCryptDecapsulate
NCryptDecapsulate
関数暗号文から共有秘密を取り出すキーデカプセル化を行う。
シグネチャ
// ncrypt.dll
#include <windows.h>
HRESULT NCryptDecapsulate(
NCRYPT_KEY_HANDLE hKey,
BYTE* pbCipherText,
DWORD cbCipherText,
BYTE* pbSecretKey, // optional
DWORD cbSecretKey,
DWORD* pcbSecretKey,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hKey | NCRYPT_KEY_HANDLE | in | カプセル解除に使う秘密鍵ハンドル(KEM)。 |
| pbCipherText | BYTE* | in | 復号する暗号文(カプセル)のバッファへのポインタ。 |
| cbCipherText | DWORD | in | 暗号文のバイト数。 |
| pbSecretKey | BYTE* | outoptional | 復元された共有秘密鍵を受け取るバッファへのポインタ。NULLで必要サイズのみ取得できる。 |
| cbSecretKey | DWORD | in | 共有秘密鍵バッファのバイトサイズ。 |
| pcbSecretKey | DWORD* | out | 実際の、または必要な共有秘密鍵バイト数を受け取るポインタ。 |
| dwFlags | DWORD | in | 動作フラグ。通常は0を指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
HRESULT NCryptDecapsulate(
NCRYPT_KEY_HANDLE hKey,
BYTE* pbCipherText,
DWORD cbCipherText,
BYTE* pbSecretKey, // optional
DWORD cbSecretKey,
DWORD* pcbSecretKey,
DWORD dwFlags
);[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int NCryptDecapsulate(
UIntPtr hKey, // NCRYPT_KEY_HANDLE
IntPtr pbCipherText, // BYTE*
uint cbCipherText, // DWORD
IntPtr pbSecretKey, // BYTE* optional, out
uint cbSecretKey, // DWORD
out uint pcbSecretKey, // DWORD* out
uint dwFlags // DWORD
);<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function NCryptDecapsulate(
hKey As UIntPtr, ' NCRYPT_KEY_HANDLE
pbCipherText As IntPtr, ' BYTE*
cbCipherText As UInteger, ' DWORD
pbSecretKey As IntPtr, ' BYTE* optional, out
cbSecretKey As UInteger, ' DWORD
<Out> ByRef pcbSecretKey As UInteger, ' DWORD* out
dwFlags As UInteger ' DWORD
) As Integer
End Function' hKey : NCRYPT_KEY_HANDLE
' pbCipherText : BYTE*
' cbCipherText : DWORD
' pbSecretKey : BYTE* optional, out
' cbSecretKey : DWORD
' pcbSecretKey : DWORD* out
' dwFlags : DWORD
Declare PtrSafe Function NCryptDecapsulate Lib "ncrypt" ( _
ByVal hKey As LongPtr, _
ByVal pbCipherText As LongPtr, _
ByVal cbCipherText As Long, _
ByVal pbSecretKey As LongPtr, _
ByVal cbSecretKey As Long, _
ByRef pcbSecretKey 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
NCryptDecapsulate = ctypes.windll.ncrypt.NCryptDecapsulate
NCryptDecapsulate.restype = ctypes.c_int
NCryptDecapsulate.argtypes = [
ctypes.c_size_t, # hKey : NCRYPT_KEY_HANDLE
ctypes.POINTER(ctypes.c_ubyte), # pbCipherText : BYTE*
wintypes.DWORD, # cbCipherText : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pbSecretKey : BYTE* optional, out
wintypes.DWORD, # cbSecretKey : DWORD
ctypes.POINTER(wintypes.DWORD), # pcbSecretKey : DWORD* out
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ncrypt.dll')
NCryptDecapsulate = Fiddle::Function.new(
lib['NCryptDecapsulate'],
[
Fiddle::TYPE_UINTPTR_T, # hKey : NCRYPT_KEY_HANDLE
Fiddle::TYPE_VOIDP, # pbCipherText : BYTE*
-Fiddle::TYPE_INT, # cbCipherText : DWORD
Fiddle::TYPE_VOIDP, # pbSecretKey : BYTE* optional, out
-Fiddle::TYPE_INT, # cbSecretKey : DWORD
Fiddle::TYPE_VOIDP, # pcbSecretKey : DWORD* out
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ncrypt")]
extern "system" {
fn NCryptDecapsulate(
hKey: usize, // NCRYPT_KEY_HANDLE
pbCipherText: *mut u8, // BYTE*
cbCipherText: u32, // DWORD
pbSecretKey: *mut u8, // BYTE* optional, out
cbSecretKey: u32, // DWORD
pcbSecretKey: *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 NCryptDecapsulate(UIntPtr hKey, IntPtr pbCipherText, uint cbCipherText, IntPtr pbSecretKey, uint cbSecretKey, out uint pcbSecretKey, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_NCryptDecapsulate' -Namespace Win32 -PassThru
# $api::NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags)#uselib "ncrypt.dll"
#func global NCryptDecapsulate "NCryptDecapsulate" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; NCryptDecapsulate hKey, varptr(pbCipherText), cbCipherText, varptr(pbSecretKey), cbSecretKey, varptr(pcbSecretKey), dwFlags ; 戻り値は stat
; hKey : NCRYPT_KEY_HANDLE -> "sptr"
; pbCipherText : BYTE* -> "sptr"
; cbCipherText : DWORD -> "sptr"
; pbSecretKey : BYTE* optional, out -> "sptr"
; cbSecretKey : DWORD -> "sptr"
; pcbSecretKey : DWORD* out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ncrypt.dll" #cfunc global NCryptDecapsulate "NCryptDecapsulate" sptr, var, int, var, int, var, int ; res = NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags) ; hKey : NCRYPT_KEY_HANDLE -> "sptr" ; pbCipherText : BYTE* -> "var" ; cbCipherText : DWORD -> "int" ; pbSecretKey : BYTE* optional, out -> "var" ; cbSecretKey : DWORD -> "int" ; pcbSecretKey : DWORD* out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ncrypt.dll" #cfunc global NCryptDecapsulate "NCryptDecapsulate" sptr, sptr, int, sptr, int, sptr, int ; res = NCryptDecapsulate(hKey, varptr(pbCipherText), cbCipherText, varptr(pbSecretKey), cbSecretKey, varptr(pcbSecretKey), dwFlags) ; hKey : NCRYPT_KEY_HANDLE -> "sptr" ; pbCipherText : BYTE* -> "sptr" ; cbCipherText : DWORD -> "int" ; pbSecretKey : BYTE* optional, out -> "sptr" ; cbSecretKey : DWORD -> "int" ; pcbSecretKey : DWORD* out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT NCryptDecapsulate(NCRYPT_KEY_HANDLE hKey, BYTE* pbCipherText, DWORD cbCipherText, BYTE* pbSecretKey, DWORD cbSecretKey, DWORD* pcbSecretKey, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global NCryptDecapsulate "NCryptDecapsulate" intptr, var, int, var, int, var, int ; res = NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags) ; hKey : NCRYPT_KEY_HANDLE -> "intptr" ; pbCipherText : BYTE* -> "var" ; cbCipherText : DWORD -> "int" ; pbSecretKey : BYTE* optional, out -> "var" ; cbSecretKey : DWORD -> "int" ; pcbSecretKey : DWORD* out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT NCryptDecapsulate(NCRYPT_KEY_HANDLE hKey, BYTE* pbCipherText, DWORD cbCipherText, BYTE* pbSecretKey, DWORD cbSecretKey, DWORD* pcbSecretKey, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global NCryptDecapsulate "NCryptDecapsulate" intptr, intptr, int, intptr, int, intptr, int ; res = NCryptDecapsulate(hKey, varptr(pbCipherText), cbCipherText, varptr(pbSecretKey), cbSecretKey, varptr(pcbSecretKey), dwFlags) ; hKey : NCRYPT_KEY_HANDLE -> "intptr" ; pbCipherText : BYTE* -> "intptr" ; cbCipherText : DWORD -> "int" ; pbSecretKey : BYTE* optional, out -> "intptr" ; cbSecretKey : DWORD -> "int" ; pcbSecretKey : DWORD* out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
procNCryptDecapsulate = ncrypt.NewProc("NCryptDecapsulate")
)
// hKey (NCRYPT_KEY_HANDLE), pbCipherText (BYTE*), cbCipherText (DWORD), pbSecretKey (BYTE* optional, out), cbSecretKey (DWORD), pcbSecretKey (DWORD* out), dwFlags (DWORD)
r1, _, err := procNCryptDecapsulate.Call(
uintptr(hKey),
uintptr(pbCipherText),
uintptr(cbCipherText),
uintptr(pbSecretKey),
uintptr(cbSecretKey),
uintptr(pcbSecretKey),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction NCryptDecapsulate(
hKey: NativeUInt; // NCRYPT_KEY_HANDLE
pbCipherText: Pointer; // BYTE*
cbCipherText: DWORD; // DWORD
pbSecretKey: Pointer; // BYTE* optional, out
cbSecretKey: DWORD; // DWORD
pcbSecretKey: Pointer; // DWORD* out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'NCryptDecapsulate';result := DllCall("ncrypt\NCryptDecapsulate"
, "UPtr", hKey ; NCRYPT_KEY_HANDLE
, "Ptr", pbCipherText ; BYTE*
, "UInt", cbCipherText ; DWORD
, "Ptr", pbSecretKey ; BYTE* optional, out
, "UInt", cbSecretKey ; DWORD
, "Ptr", pcbSecretKey ; DWORD* out
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags) = DLL("ncrypt.dll", "int NCryptDecapsulate(int, void*, dword, void*, dword, void*, dword)")
# 呼び出し: NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags)
# hKey : NCRYPT_KEY_HANDLE -> "int"
# pbCipherText : BYTE* -> "void*"
# cbCipherText : DWORD -> "dword"
# pbSecretKey : BYTE* optional, out -> "void*"
# cbSecretKey : DWORD -> "dword"
# pcbSecretKey : DWORD* out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ncrypt" fn NCryptDecapsulate(
hKey: usize, // NCRYPT_KEY_HANDLE
pbCipherText: [*c]u8, // BYTE*
cbCipherText: u32, // DWORD
pbSecretKey: [*c]u8, // BYTE* optional, out
cbSecretKey: u32, // DWORD
pcbSecretKey: [*c]u32, // DWORD* out
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc NCryptDecapsulate(
hKey: uint, # NCRYPT_KEY_HANDLE
pbCipherText: ptr uint8, # BYTE*
cbCipherText: uint32, # DWORD
pbSecretKey: ptr uint8, # BYTE* optional, out
cbSecretKey: uint32, # DWORD
pcbSecretKey: ptr uint32, # DWORD* out
dwFlags: uint32 # DWORD
): int32 {.importc: "NCryptDecapsulate", stdcall, dynlib: "ncrypt.dll".}pragma(lib, "ncrypt");
extern(Windows)
int NCryptDecapsulate(
size_t hKey, // NCRYPT_KEY_HANDLE
ubyte* pbCipherText, // BYTE*
uint cbCipherText, // DWORD
ubyte* pbSecretKey, // BYTE* optional, out
uint cbSecretKey, // DWORD
uint* pcbSecretKey, // DWORD* out
uint dwFlags // DWORD
);ccall((:NCryptDecapsulate, "ncrypt.dll"), stdcall, Int32,
(Csize_t, Ptr{UInt8}, UInt32, Ptr{UInt8}, UInt32, Ptr{UInt32}, UInt32),
hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags)
# hKey : NCRYPT_KEY_HANDLE -> Csize_t
# pbCipherText : BYTE* -> Ptr{UInt8}
# cbCipherText : DWORD -> UInt32
# pbSecretKey : BYTE* optional, out -> Ptr{UInt8}
# cbSecretKey : DWORD -> UInt32
# pcbSecretKey : DWORD* out -> Ptr{UInt32}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t NCryptDecapsulate(
uintptr_t hKey,
uint8_t* pbCipherText,
uint32_t cbCipherText,
uint8_t* pbSecretKey,
uint32_t cbSecretKey,
uint32_t* pcbSecretKey,
uint32_t dwFlags);
]]
local ncrypt = ffi.load("ncrypt")
-- ncrypt.NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags)
-- hKey : NCRYPT_KEY_HANDLE
-- pbCipherText : BYTE*
-- cbCipherText : DWORD
-- pbSecretKey : BYTE* optional, out
-- cbSecretKey : DWORD
-- pcbSecretKey : DWORD* out
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ncrypt.dll');
const NCryptDecapsulate = lib.func('__stdcall', 'NCryptDecapsulate', 'int32_t', ['uintptr_t', 'uint8_t *', 'uint32_t', 'uint8_t *', 'uint32_t', 'uint32_t *', 'uint32_t']);
// NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags)
// hKey : NCRYPT_KEY_HANDLE -> 'uintptr_t'
// pbCipherText : BYTE* -> 'uint8_t *'
// cbCipherText : DWORD -> 'uint32_t'
// pbSecretKey : BYTE* optional, out -> 'uint8_t *'
// cbSecretKey : DWORD -> 'uint32_t'
// pcbSecretKey : DWORD* out -> 'uint32_t *'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ncrypt.dll", {
NCryptDecapsulate: { parameters: ["usize", "pointer", "u32", "pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags)
// hKey : NCRYPT_KEY_HANDLE -> "usize"
// pbCipherText : BYTE* -> "pointer"
// cbCipherText : DWORD -> "u32"
// pbSecretKey : BYTE* optional, out -> "pointer"
// cbSecretKey : DWORD -> "u32"
// pcbSecretKey : DWORD* out -> "pointer"
// dwFlags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t NCryptDecapsulate(
size_t hKey,
uint8_t* pbCipherText,
uint32_t cbCipherText,
uint8_t* pbSecretKey,
uint32_t cbSecretKey,
uint32_t* pcbSecretKey,
uint32_t dwFlags);
C, "ncrypt.dll");
// $ffi->NCryptDecapsulate(hKey, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, pcbSecretKey, dwFlags);
// hKey : NCRYPT_KEY_HANDLE
// pbCipherText : BYTE*
// cbCipherText : DWORD
// pbSecretKey : BYTE* optional, out
// cbSecretKey : DWORD
// pcbSecretKey : DWORD* 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 NCryptDecapsulate(
long hKey, // NCRYPT_KEY_HANDLE
byte[] pbCipherText, // BYTE*
int cbCipherText, // DWORD
byte[] pbSecretKey, // BYTE* optional, out
int cbSecretKey, // DWORD
IntByReference pcbSecretKey, // DWORD* out
int dwFlags // DWORD
);
}@[Link("ncrypt")]
lib Libncrypt
fun NCryptDecapsulate = NCryptDecapsulate(
hKey : LibC::SizeT, # NCRYPT_KEY_HANDLE
pbCipherText : UInt8*, # BYTE*
cbCipherText : UInt32, # DWORD
pbSecretKey : UInt8*, # BYTE* optional, out
cbSecretKey : UInt32, # DWORD
pcbSecretKey : UInt32*, # DWORD* 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 NCryptDecapsulateNative = Int32 Function(UintPtr, Pointer<Uint8>, Uint32, Pointer<Uint8>, Uint32, Pointer<Uint32>, Uint32);
typedef NCryptDecapsulateDart = int Function(int, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint32>, int);
final NCryptDecapsulate = DynamicLibrary.open('ncrypt.dll')
.lookupFunction<NCryptDecapsulateNative, NCryptDecapsulateDart>('NCryptDecapsulate');
// hKey : NCRYPT_KEY_HANDLE -> UintPtr
// pbCipherText : BYTE* -> Pointer<Uint8>
// cbCipherText : DWORD -> Uint32
// pbSecretKey : BYTE* optional, out -> Pointer<Uint8>
// cbSecretKey : DWORD -> Uint32
// pcbSecretKey : DWORD* out -> Pointer<Uint32>
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NCryptDecapsulate(
hKey: NativeUInt; // NCRYPT_KEY_HANDLE
pbCipherText: Pointer; // BYTE*
cbCipherText: DWORD; // DWORD
pbSecretKey: Pointer; // BYTE* optional, out
cbSecretKey: DWORD; // DWORD
pcbSecretKey: Pointer; // DWORD* out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'NCryptDecapsulate';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NCryptDecapsulate"
c_NCryptDecapsulate :: CUIntPtr -> Ptr Word8 -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word32 -> Word32 -> IO Int32
-- hKey : NCRYPT_KEY_HANDLE -> CUIntPtr
-- pbCipherText : BYTE* -> Ptr Word8
-- cbCipherText : DWORD -> Word32
-- pbSecretKey : BYTE* optional, out -> Ptr Word8
-- cbSecretKey : DWORD -> Word32
-- pcbSecretKey : DWORD* out -> Ptr Word32
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ncryptdecapsulate =
foreign "NCryptDecapsulate"
(size_t @-> (ptr uint8_t) @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> returning int32_t)
(* hKey : NCRYPT_KEY_HANDLE -> size_t *)
(* pbCipherText : BYTE* -> (ptr uint8_t) *)
(* cbCipherText : DWORD -> uint32_t *)
(* pbSecretKey : BYTE* optional, out -> (ptr uint8_t) *)
(* cbSecretKey : DWORD -> uint32_t *)
(* pcbSecretKey : DWORD* out -> (ptr uint32_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 ("NCryptDecapsulate" ncrypt-decapsulate :convention :stdcall) :int32
(h-key :uint64) ; NCRYPT_KEY_HANDLE
(pb-cipher-text :pointer) ; BYTE*
(cb-cipher-text :uint32) ; DWORD
(pb-secret-key :pointer) ; BYTE* optional, out
(cb-secret-key :uint32) ; DWORD
(pcb-secret-key :pointer) ; DWORD* out
(dw-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NCryptDecapsulate = Win32::API::More->new('ncrypt',
'int NCryptDecapsulate(WPARAM hKey, LPVOID pbCipherText, DWORD cbCipherText, LPVOID pbSecretKey, DWORD cbSecretKey, LPVOID pcbSecretKey, DWORD dwFlags)');
# my $ret = $NCryptDecapsulate->Call($hKey, $pbCipherText, $cbCipherText, $pbSecretKey, $cbSecretKey, $pcbSecretKey, $dwFlags);
# hKey : NCRYPT_KEY_HANDLE -> WPARAM
# pbCipherText : BYTE* -> LPVOID
# cbCipherText : DWORD -> DWORD
# pbSecretKey : BYTE* optional, out -> LPVOID
# cbSecretKey : DWORD -> DWORD
# pcbSecretKey : DWORD* out -> LPVOID
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。