ホーム › System.Environment › EnclaveUnsealData
EnclaveUnsealData
関数封印されたエンクレーブデータを復号し展開する。
シグネチャ
// vertdll.dll
#include <windows.h>
HRESULT EnclaveUnsealData(
const void* ProtectedBlob,
DWORD ProtectedBlobSize,
void* DecryptedData, // optional
DWORD BufferSize,
DWORD* DecryptedDataSize,
ENCLAVE_IDENTITY* SealingIdentity, // optional
DWORD* UnsealingFlags // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ProtectedBlob | void* | in | 復号する封印済みデータ(保護ブロブ)を指すバッファ。 |
| ProtectedBlobSize | DWORD | in | ProtectedBlobのサイズ(バイト)。 |
| DecryptedData | void* | outoptional | 復号した平文を受け取る出力バッファ。 |
| BufferSize | DWORD | in | DecryptedDataバッファのサイズ(バイト)。 |
| DecryptedDataSize | DWORD* | out | 実際に必要/書込みされたサイズを受け取るDWORDへのポインタ。 |
| SealingIdentity | ENCLAVE_IDENTITY* | outoptional | 封印に使われたIDを受け取るENCLAVE_IDENTITY構造体へのポインタ。NULL可。 |
| UnsealingFlags | DWORD* | outoptional | 復号結果に関するフラグを受け取るDWORDへのポインタ。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// vertdll.dll
#include <windows.h>
HRESULT EnclaveUnsealData(
const void* ProtectedBlob,
DWORD ProtectedBlobSize,
void* DecryptedData, // optional
DWORD BufferSize,
DWORD* DecryptedDataSize,
ENCLAVE_IDENTITY* SealingIdentity, // optional
DWORD* UnsealingFlags // optional
);[DllImport("vertdll.dll", ExactSpelling = true)]
static extern int EnclaveUnsealData(
IntPtr ProtectedBlob, // void*
uint ProtectedBlobSize, // DWORD
IntPtr DecryptedData, // void* optional, out
uint BufferSize, // DWORD
out uint DecryptedDataSize, // DWORD* out
IntPtr SealingIdentity, // ENCLAVE_IDENTITY* optional, out
IntPtr UnsealingFlags // DWORD* optional, out
);<DllImport("vertdll.dll", ExactSpelling:=True)>
Public Shared Function EnclaveUnsealData(
ProtectedBlob As IntPtr, ' void*
ProtectedBlobSize As UInteger, ' DWORD
DecryptedData As IntPtr, ' void* optional, out
BufferSize As UInteger, ' DWORD
<Out> ByRef DecryptedDataSize As UInteger, ' DWORD* out
SealingIdentity As IntPtr, ' ENCLAVE_IDENTITY* optional, out
UnsealingFlags As IntPtr ' DWORD* optional, out
) As Integer
End Function' ProtectedBlob : void*
' ProtectedBlobSize : DWORD
' DecryptedData : void* optional, out
' BufferSize : DWORD
' DecryptedDataSize : DWORD* out
' SealingIdentity : ENCLAVE_IDENTITY* optional, out
' UnsealingFlags : DWORD* optional, out
Declare PtrSafe Function EnclaveUnsealData Lib "vertdll" ( _
ByVal ProtectedBlob As LongPtr, _
ByVal ProtectedBlobSize As Long, _
ByVal DecryptedData As LongPtr, _
ByVal BufferSize As Long, _
ByRef DecryptedDataSize As Long, _
ByVal SealingIdentity As LongPtr, _
ByVal UnsealingFlags As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnclaveUnsealData = ctypes.windll.vertdll.EnclaveUnsealData
EnclaveUnsealData.restype = ctypes.c_int
EnclaveUnsealData.argtypes = [
ctypes.POINTER(None), # ProtectedBlob : void*
wintypes.DWORD, # ProtectedBlobSize : DWORD
ctypes.POINTER(None), # DecryptedData : void* optional, out
wintypes.DWORD, # BufferSize : DWORD
ctypes.POINTER(wintypes.DWORD), # DecryptedDataSize : DWORD* out
ctypes.c_void_p, # SealingIdentity : ENCLAVE_IDENTITY* optional, out
ctypes.POINTER(wintypes.DWORD), # UnsealingFlags : DWORD* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('vertdll.dll')
EnclaveUnsealData = Fiddle::Function.new(
lib['EnclaveUnsealData'],
[
Fiddle::TYPE_VOIDP, # ProtectedBlob : void*
-Fiddle::TYPE_INT, # ProtectedBlobSize : DWORD
Fiddle::TYPE_VOIDP, # DecryptedData : void* optional, out
-Fiddle::TYPE_INT, # BufferSize : DWORD
Fiddle::TYPE_VOIDP, # DecryptedDataSize : DWORD* out
Fiddle::TYPE_VOIDP, # SealingIdentity : ENCLAVE_IDENTITY* optional, out
Fiddle::TYPE_VOIDP, # UnsealingFlags : DWORD* optional, out
],
Fiddle::TYPE_INT)#[link(name = "vertdll")]
extern "system" {
fn EnclaveUnsealData(
ProtectedBlob: *const (), // void*
ProtectedBlobSize: u32, // DWORD
DecryptedData: *mut (), // void* optional, out
BufferSize: u32, // DWORD
DecryptedDataSize: *mut u32, // DWORD* out
SealingIdentity: *mut ENCLAVE_IDENTITY, // ENCLAVE_IDENTITY* optional, out
UnsealingFlags: *mut u32 // DWORD* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("vertdll.dll")]
public static extern int EnclaveUnsealData(IntPtr ProtectedBlob, uint ProtectedBlobSize, IntPtr DecryptedData, uint BufferSize, out uint DecryptedDataSize, IntPtr SealingIdentity, IntPtr UnsealingFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'vertdll_EnclaveUnsealData' -Namespace Win32 -PassThru
# $api::EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags)#uselib "vertdll.dll"
#func global EnclaveUnsealData "EnclaveUnsealData" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; EnclaveUnsealData ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, varptr(DecryptedDataSize), varptr(SealingIdentity), varptr(UnsealingFlags) ; 戻り値は stat
; ProtectedBlob : void* -> "sptr"
; ProtectedBlobSize : DWORD -> "sptr"
; DecryptedData : void* optional, out -> "sptr"
; BufferSize : DWORD -> "sptr"
; DecryptedDataSize : DWORD* out -> "sptr"
; SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "sptr"
; UnsealingFlags : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "vertdll.dll" #cfunc global EnclaveUnsealData "EnclaveUnsealData" sptr, int, sptr, int, var, var, var ; res = EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags) ; ProtectedBlob : void* -> "sptr" ; ProtectedBlobSize : DWORD -> "int" ; DecryptedData : void* optional, out -> "sptr" ; BufferSize : DWORD -> "int" ; DecryptedDataSize : DWORD* out -> "var" ; SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "var" ; UnsealingFlags : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "vertdll.dll" #cfunc global EnclaveUnsealData "EnclaveUnsealData" sptr, int, sptr, int, sptr, sptr, sptr ; res = EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, varptr(DecryptedDataSize), varptr(SealingIdentity), varptr(UnsealingFlags)) ; ProtectedBlob : void* -> "sptr" ; ProtectedBlobSize : DWORD -> "int" ; DecryptedData : void* optional, out -> "sptr" ; BufferSize : DWORD -> "int" ; DecryptedDataSize : DWORD* out -> "sptr" ; SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "sptr" ; UnsealingFlags : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT EnclaveUnsealData(void* ProtectedBlob, DWORD ProtectedBlobSize, void* DecryptedData, DWORD BufferSize, DWORD* DecryptedDataSize, ENCLAVE_IDENTITY* SealingIdentity, DWORD* UnsealingFlags) #uselib "vertdll.dll" #cfunc global EnclaveUnsealData "EnclaveUnsealData" intptr, int, intptr, int, var, var, var ; res = EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags) ; ProtectedBlob : void* -> "intptr" ; ProtectedBlobSize : DWORD -> "int" ; DecryptedData : void* optional, out -> "intptr" ; BufferSize : DWORD -> "int" ; DecryptedDataSize : DWORD* out -> "var" ; SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "var" ; UnsealingFlags : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT EnclaveUnsealData(void* ProtectedBlob, DWORD ProtectedBlobSize, void* DecryptedData, DWORD BufferSize, DWORD* DecryptedDataSize, ENCLAVE_IDENTITY* SealingIdentity, DWORD* UnsealingFlags) #uselib "vertdll.dll" #cfunc global EnclaveUnsealData "EnclaveUnsealData" intptr, int, intptr, int, intptr, intptr, intptr ; res = EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, varptr(DecryptedDataSize), varptr(SealingIdentity), varptr(UnsealingFlags)) ; ProtectedBlob : void* -> "intptr" ; ProtectedBlobSize : DWORD -> "int" ; DecryptedData : void* optional, out -> "intptr" ; BufferSize : DWORD -> "int" ; DecryptedDataSize : DWORD* out -> "intptr" ; SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "intptr" ; UnsealingFlags : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
vertdll = windows.NewLazySystemDLL("vertdll.dll")
procEnclaveUnsealData = vertdll.NewProc("EnclaveUnsealData")
)
// ProtectedBlob (void*), ProtectedBlobSize (DWORD), DecryptedData (void* optional, out), BufferSize (DWORD), DecryptedDataSize (DWORD* out), SealingIdentity (ENCLAVE_IDENTITY* optional, out), UnsealingFlags (DWORD* optional, out)
r1, _, err := procEnclaveUnsealData.Call(
uintptr(ProtectedBlob),
uintptr(ProtectedBlobSize),
uintptr(DecryptedData),
uintptr(BufferSize),
uintptr(DecryptedDataSize),
uintptr(SealingIdentity),
uintptr(UnsealingFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction EnclaveUnsealData(
ProtectedBlob: Pointer; // void*
ProtectedBlobSize: DWORD; // DWORD
DecryptedData: Pointer; // void* optional, out
BufferSize: DWORD; // DWORD
DecryptedDataSize: Pointer; // DWORD* out
SealingIdentity: Pointer; // ENCLAVE_IDENTITY* optional, out
UnsealingFlags: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'vertdll.dll' name 'EnclaveUnsealData';result := DllCall("vertdll\EnclaveUnsealData"
, "Ptr", ProtectedBlob ; void*
, "UInt", ProtectedBlobSize ; DWORD
, "Ptr", DecryptedData ; void* optional, out
, "UInt", BufferSize ; DWORD
, "Ptr", DecryptedDataSize ; DWORD* out
, "Ptr", SealingIdentity ; ENCLAVE_IDENTITY* optional, out
, "Ptr", UnsealingFlags ; DWORD* optional, out
, "Int") ; return: HRESULT●EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags) = DLL("vertdll.dll", "int EnclaveUnsealData(void*, dword, void*, dword, void*, void*, void*)")
# 呼び出し: EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags)
# ProtectedBlob : void* -> "void*"
# ProtectedBlobSize : DWORD -> "dword"
# DecryptedData : void* optional, out -> "void*"
# BufferSize : DWORD -> "dword"
# DecryptedDataSize : DWORD* out -> "void*"
# SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "void*"
# UnsealingFlags : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "vertdll" fn EnclaveUnsealData(
ProtectedBlob: ?*anyopaque, // void*
ProtectedBlobSize: u32, // DWORD
DecryptedData: ?*anyopaque, // void* optional, out
BufferSize: u32, // DWORD
DecryptedDataSize: [*c]u32, // DWORD* out
SealingIdentity: [*c]ENCLAVE_IDENTITY, // ENCLAVE_IDENTITY* optional, out
UnsealingFlags: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc EnclaveUnsealData(
ProtectedBlob: pointer, # void*
ProtectedBlobSize: uint32, # DWORD
DecryptedData: pointer, # void* optional, out
BufferSize: uint32, # DWORD
DecryptedDataSize: ptr uint32, # DWORD* out
SealingIdentity: ptr ENCLAVE_IDENTITY, # ENCLAVE_IDENTITY* optional, out
UnsealingFlags: ptr uint32 # DWORD* optional, out
): int32 {.importc: "EnclaveUnsealData", stdcall, dynlib: "vertdll.dll".}pragma(lib, "vertdll");
extern(Windows)
int EnclaveUnsealData(
void* ProtectedBlob, // void*
uint ProtectedBlobSize, // DWORD
void* DecryptedData, // void* optional, out
uint BufferSize, // DWORD
uint* DecryptedDataSize, // DWORD* out
ENCLAVE_IDENTITY* SealingIdentity, // ENCLAVE_IDENTITY* optional, out
uint* UnsealingFlags // DWORD* optional, out
);ccall((:EnclaveUnsealData, "vertdll.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt32}, Ptr{ENCLAVE_IDENTITY}, Ptr{UInt32}),
ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags)
# ProtectedBlob : void* -> Ptr{Cvoid}
# ProtectedBlobSize : DWORD -> UInt32
# DecryptedData : void* optional, out -> Ptr{Cvoid}
# BufferSize : DWORD -> UInt32
# DecryptedDataSize : DWORD* out -> Ptr{UInt32}
# SealingIdentity : ENCLAVE_IDENTITY* optional, out -> Ptr{ENCLAVE_IDENTITY}
# UnsealingFlags : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t EnclaveUnsealData(
void* ProtectedBlob,
uint32_t ProtectedBlobSize,
void* DecryptedData,
uint32_t BufferSize,
uint32_t* DecryptedDataSize,
void* SealingIdentity,
uint32_t* UnsealingFlags);
]]
local vertdll = ffi.load("vertdll")
-- vertdll.EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags)
-- ProtectedBlob : void*
-- ProtectedBlobSize : DWORD
-- DecryptedData : void* optional, out
-- BufferSize : DWORD
-- DecryptedDataSize : DWORD* out
-- SealingIdentity : ENCLAVE_IDENTITY* optional, out
-- UnsealingFlags : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('vertdll.dll');
const EnclaveUnsealData = lib.func('__stdcall', 'EnclaveUnsealData', 'int32_t', ['void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t *', 'void *', 'uint32_t *']);
// EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags)
// ProtectedBlob : void* -> 'void *'
// ProtectedBlobSize : DWORD -> 'uint32_t'
// DecryptedData : void* optional, out -> 'void *'
// BufferSize : DWORD -> 'uint32_t'
// DecryptedDataSize : DWORD* out -> 'uint32_t *'
// SealingIdentity : ENCLAVE_IDENTITY* optional, out -> 'void *'
// UnsealingFlags : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("vertdll.dll", {
EnclaveUnsealData: { parameters: ["pointer", "u32", "pointer", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags)
// ProtectedBlob : void* -> "pointer"
// ProtectedBlobSize : DWORD -> "u32"
// DecryptedData : void* optional, out -> "pointer"
// BufferSize : DWORD -> "u32"
// DecryptedDataSize : DWORD* out -> "pointer"
// SealingIdentity : ENCLAVE_IDENTITY* optional, out -> "pointer"
// UnsealingFlags : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t EnclaveUnsealData(
void* ProtectedBlob,
uint32_t ProtectedBlobSize,
void* DecryptedData,
uint32_t BufferSize,
uint32_t* DecryptedDataSize,
void* SealingIdentity,
uint32_t* UnsealingFlags);
C, "vertdll.dll");
// $ffi->EnclaveUnsealData(ProtectedBlob, ProtectedBlobSize, DecryptedData, BufferSize, DecryptedDataSize, SealingIdentity, UnsealingFlags);
// ProtectedBlob : void*
// ProtectedBlobSize : DWORD
// DecryptedData : void* optional, out
// BufferSize : DWORD
// DecryptedDataSize : DWORD* out
// SealingIdentity : ENCLAVE_IDENTITY* optional, out
// UnsealingFlags : DWORD* optional, out
// 構造体/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 Vertdll extends StdCallLibrary {
Vertdll INSTANCE = Native.load("vertdll", Vertdll.class);
int EnclaveUnsealData(
Pointer ProtectedBlob, // void*
int ProtectedBlobSize, // DWORD
Pointer DecryptedData, // void* optional, out
int BufferSize, // DWORD
IntByReference DecryptedDataSize, // DWORD* out
Pointer SealingIdentity, // ENCLAVE_IDENTITY* optional, out
IntByReference UnsealingFlags // DWORD* optional, out
);
}@[Link("vertdll")]
lib Libvertdll
fun EnclaveUnsealData = EnclaveUnsealData(
ProtectedBlob : Void*, # void*
ProtectedBlobSize : UInt32, # DWORD
DecryptedData : Void*, # void* optional, out
BufferSize : UInt32, # DWORD
DecryptedDataSize : UInt32*, # DWORD* out
SealingIdentity : ENCLAVE_IDENTITY*, # ENCLAVE_IDENTITY* optional, out
UnsealingFlags : UInt32* # DWORD* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef EnclaveUnsealDataNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Uint32>, Pointer<Void>, Pointer<Uint32>);
typedef EnclaveUnsealDataDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Uint32>, Pointer<Void>, Pointer<Uint32>);
final EnclaveUnsealData = DynamicLibrary.open('vertdll.dll')
.lookupFunction<EnclaveUnsealDataNative, EnclaveUnsealDataDart>('EnclaveUnsealData');
// ProtectedBlob : void* -> Pointer<Void>
// ProtectedBlobSize : DWORD -> Uint32
// DecryptedData : void* optional, out -> Pointer<Void>
// BufferSize : DWORD -> Uint32
// DecryptedDataSize : DWORD* out -> Pointer<Uint32>
// SealingIdentity : ENCLAVE_IDENTITY* optional, out -> Pointer<Void>
// UnsealingFlags : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function EnclaveUnsealData(
ProtectedBlob: Pointer; // void*
ProtectedBlobSize: DWORD; // DWORD
DecryptedData: Pointer; // void* optional, out
BufferSize: DWORD; // DWORD
DecryptedDataSize: Pointer; // DWORD* out
SealingIdentity: Pointer; // ENCLAVE_IDENTITY* optional, out
UnsealingFlags: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'vertdll.dll' name 'EnclaveUnsealData';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "EnclaveUnsealData"
c_EnclaveUnsealData :: Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr Word32 -> Ptr () -> Ptr Word32 -> IO Int32
-- ProtectedBlob : void* -> Ptr ()
-- ProtectedBlobSize : DWORD -> Word32
-- DecryptedData : void* optional, out -> Ptr ()
-- BufferSize : DWORD -> Word32
-- DecryptedDataSize : DWORD* out -> Ptr Word32
-- SealingIdentity : ENCLAVE_IDENTITY* optional, out -> Ptr ()
-- UnsealingFlags : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let enclaveunsealdata =
foreign "EnclaveUnsealData"
((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* ProtectedBlob : void* -> (ptr void) *)
(* ProtectedBlobSize : DWORD -> uint32_t *)
(* DecryptedData : void* optional, out -> (ptr void) *)
(* BufferSize : DWORD -> uint32_t *)
(* DecryptedDataSize : DWORD* out -> (ptr uint32_t) *)
(* SealingIdentity : ENCLAVE_IDENTITY* optional, out -> (ptr void) *)
(* UnsealingFlags : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library vertdll (t "vertdll.dll"))
(cffi:use-foreign-library vertdll)
(cffi:defcfun ("EnclaveUnsealData" enclave-unseal-data :convention :stdcall) :int32
(protected-blob :pointer) ; void*
(protected-blob-size :uint32) ; DWORD
(decrypted-data :pointer) ; void* optional, out
(buffer-size :uint32) ; DWORD
(decrypted-data-size :pointer) ; DWORD* out
(sealing-identity :pointer) ; ENCLAVE_IDENTITY* optional, out
(unsealing-flags :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $EnclaveUnsealData = Win32::API::More->new('vertdll',
'int EnclaveUnsealData(LPVOID ProtectedBlob, DWORD ProtectedBlobSize, LPVOID DecryptedData, DWORD BufferSize, LPVOID DecryptedDataSize, LPVOID SealingIdentity, LPVOID UnsealingFlags)');
# my $ret = $EnclaveUnsealData->Call($ProtectedBlob, $ProtectedBlobSize, $DecryptedData, $BufferSize, $DecryptedDataSize, $SealingIdentity, $UnsealingFlags);
# ProtectedBlob : void* -> LPVOID
# ProtectedBlobSize : DWORD -> DWORD
# DecryptedData : void* optional, out -> LPVOID
# BufferSize : DWORD -> DWORD
# DecryptedDataSize : DWORD* out -> LPVOID
# SealingIdentity : ENCLAVE_IDENTITY* optional, out -> LPVOID
# UnsealingFlags : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型