Win32 API 日本語リファレンス
ホームSecurity.Cryptography › GetCryptoTransform

GetCryptoTransform

関数
対称鍵から暗号変換オブジェクトのハンドルを取得する。
DLLinfocardapi.dll呼出規約winapi

シグネチャ

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

HRESULT GetCryptoTransform(
    INFORMATIONCARD_CRYPTO_HANDLE* hSymmetricCrypto,
    DWORD mode,
    PaddingMode padding,
    DWORD feedbackSize,
    Direction direction,
    DWORD cbIV,
    BYTE* pIV,
    INFORMATIONCARD_CRYPTO_HANDLE** pphTransform
);

パラメーター

名前方向
hSymmetricCryptoINFORMATIONCARD_CRYPTO_HANDLE*in
modeDWORDin
paddingPaddingModein
feedbackSizeDWORDin
directionDirectionin
cbIVDWORDin
pIVBYTE*in
pphTransformINFORMATIONCARD_CRYPTO_HANDLE**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT GetCryptoTransform(
    INFORMATIONCARD_CRYPTO_HANDLE* hSymmetricCrypto,
    DWORD mode,
    PaddingMode padding,
    DWORD feedbackSize,
    Direction direction,
    DWORD cbIV,
    BYTE* pIV,
    INFORMATIONCARD_CRYPTO_HANDLE** pphTransform
);
[DllImport("infocardapi.dll", ExactSpelling = true)]
static extern int GetCryptoTransform(
    IntPtr hSymmetricCrypto,   // INFORMATIONCARD_CRYPTO_HANDLE*
    uint mode,   // DWORD
    int padding,   // PaddingMode
    uint feedbackSize,   // DWORD
    int direction,   // Direction
    uint cbIV,   // DWORD
    IntPtr pIV,   // BYTE*
    IntPtr pphTransform   // INFORMATIONCARD_CRYPTO_HANDLE** out
);
<DllImport("infocardapi.dll", ExactSpelling:=True)>
Public Shared Function GetCryptoTransform(
    hSymmetricCrypto As IntPtr,   ' INFORMATIONCARD_CRYPTO_HANDLE*
    mode As UInteger,   ' DWORD
    padding As Integer,   ' PaddingMode
    feedbackSize As UInteger,   ' DWORD
    direction As Integer,   ' Direction
    cbIV As UInteger,   ' DWORD
    pIV As IntPtr,   ' BYTE*
    pphTransform As IntPtr   ' INFORMATIONCARD_CRYPTO_HANDLE** out
) As Integer
End Function
' hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE*
' mode : DWORD
' padding : PaddingMode
' feedbackSize : DWORD
' direction : Direction
' cbIV : DWORD
' pIV : BYTE*
' pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out
Declare PtrSafe Function GetCryptoTransform Lib "infocardapi" ( _
    ByVal hSymmetricCrypto As LongPtr, _
    ByVal mode As Long, _
    ByVal padding As Long, _
    ByVal feedbackSize As Long, _
    ByVal direction As Long, _
    ByVal cbIV As Long, _
    ByVal pIV As LongPtr, _
    ByVal pphTransform As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetCryptoTransform = ctypes.windll.infocardapi.GetCryptoTransform
GetCryptoTransform.restype = ctypes.c_int
GetCryptoTransform.argtypes = [
    ctypes.c_void_p,  # hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE*
    wintypes.DWORD,  # mode : DWORD
    ctypes.c_int,  # padding : PaddingMode
    wintypes.DWORD,  # feedbackSize : DWORD
    ctypes.c_int,  # direction : Direction
    wintypes.DWORD,  # cbIV : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pIV : BYTE*
    ctypes.c_void_p,  # pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('infocardapi.dll')
GetCryptoTransform = Fiddle::Function.new(
  lib['GetCryptoTransform'],
  [
    Fiddle::TYPE_VOIDP,  # hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE*
    -Fiddle::TYPE_INT,  # mode : DWORD
    Fiddle::TYPE_INT,  # padding : PaddingMode
    -Fiddle::TYPE_INT,  # feedbackSize : DWORD
    Fiddle::TYPE_INT,  # direction : Direction
    -Fiddle::TYPE_INT,  # cbIV : DWORD
    Fiddle::TYPE_VOIDP,  # pIV : BYTE*
    Fiddle::TYPE_VOIDP,  # pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "infocardapi")]
extern "system" {
    fn GetCryptoTransform(
        hSymmetricCrypto: *mut INFORMATIONCARD_CRYPTO_HANDLE,  // INFORMATIONCARD_CRYPTO_HANDLE*
        mode: u32,  // DWORD
        padding: i32,  // PaddingMode
        feedbackSize: u32,  // DWORD
        direction: i32,  // Direction
        cbIV: u32,  // DWORD
        pIV: *mut u8,  // BYTE*
        pphTransform: *mut *mut INFORMATIONCARD_CRYPTO_HANDLE  // INFORMATIONCARD_CRYPTO_HANDLE** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("infocardapi.dll")]
public static extern int GetCryptoTransform(IntPtr hSymmetricCrypto, uint mode, int padding, uint feedbackSize, int direction, uint cbIV, IntPtr pIV, IntPtr pphTransform);
"@
$api = Add-Type -MemberDefinition $sig -Name 'infocardapi_GetCryptoTransform' -Namespace Win32 -PassThru
# $api::GetCryptoTransform(hSymmetricCrypto, mode, padding, feedbackSize, direction, cbIV, pIV, pphTransform)
#uselib "infocardapi.dll"
#func global GetCryptoTransform "GetCryptoTransform" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetCryptoTransform varptr(hSymmetricCrypto), mode, padding, feedbackSize, direction, cbIV, varptr(pIV), varptr(pphTransform)   ; 戻り値は stat
; hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE* -> "sptr"
; mode : DWORD -> "sptr"
; padding : PaddingMode -> "sptr"
; feedbackSize : DWORD -> "sptr"
; direction : Direction -> "sptr"
; cbIV : DWORD -> "sptr"
; pIV : BYTE* -> "sptr"
; pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "infocardapi.dll"
#cfunc global GetCryptoTransform "GetCryptoTransform" var, int, int, int, int, int, var, var
; res = GetCryptoTransform(hSymmetricCrypto, mode, padding, feedbackSize, direction, cbIV, pIV, pphTransform)
; hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE* -> "var"
; mode : DWORD -> "int"
; padding : PaddingMode -> "int"
; feedbackSize : DWORD -> "int"
; direction : Direction -> "int"
; cbIV : DWORD -> "int"
; pIV : BYTE* -> "var"
; pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT GetCryptoTransform(INFORMATIONCARD_CRYPTO_HANDLE* hSymmetricCrypto, DWORD mode, PaddingMode padding, DWORD feedbackSize, Direction direction, DWORD cbIV, BYTE* pIV, INFORMATIONCARD_CRYPTO_HANDLE** pphTransform)
#uselib "infocardapi.dll"
#cfunc global GetCryptoTransform "GetCryptoTransform" var, int, int, int, int, int, var, var
; res = GetCryptoTransform(hSymmetricCrypto, mode, padding, feedbackSize, direction, cbIV, pIV, pphTransform)
; hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE* -> "var"
; mode : DWORD -> "int"
; padding : PaddingMode -> "int"
; feedbackSize : DWORD -> "int"
; direction : Direction -> "int"
; cbIV : DWORD -> "int"
; pIV : BYTE* -> "var"
; pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	infocardapi = windows.NewLazySystemDLL("infocardapi.dll")
	procGetCryptoTransform = infocardapi.NewProc("GetCryptoTransform")
)

// hSymmetricCrypto (INFORMATIONCARD_CRYPTO_HANDLE*), mode (DWORD), padding (PaddingMode), feedbackSize (DWORD), direction (Direction), cbIV (DWORD), pIV (BYTE*), pphTransform (INFORMATIONCARD_CRYPTO_HANDLE** out)
r1, _, err := procGetCryptoTransform.Call(
	uintptr(hSymmetricCrypto),
	uintptr(mode),
	uintptr(padding),
	uintptr(feedbackSize),
	uintptr(direction),
	uintptr(cbIV),
	uintptr(pIV),
	uintptr(pphTransform),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetCryptoTransform(
  hSymmetricCrypto: Pointer;   // INFORMATIONCARD_CRYPTO_HANDLE*
  mode: DWORD;   // DWORD
  padding: Integer;   // PaddingMode
  feedbackSize: DWORD;   // DWORD
  direction: Integer;   // Direction
  cbIV: DWORD;   // DWORD
  pIV: Pointer;   // BYTE*
  pphTransform: Pointer   // INFORMATIONCARD_CRYPTO_HANDLE** out
): Integer; stdcall;
  external 'infocardapi.dll' name 'GetCryptoTransform';
result := DllCall("infocardapi\GetCryptoTransform"
    , "Ptr", hSymmetricCrypto   ; INFORMATIONCARD_CRYPTO_HANDLE*
    , "UInt", mode   ; DWORD
    , "Int", padding   ; PaddingMode
    , "UInt", feedbackSize   ; DWORD
    , "Int", direction   ; Direction
    , "UInt", cbIV   ; DWORD
    , "Ptr", pIV   ; BYTE*
    , "Ptr", pphTransform   ; INFORMATIONCARD_CRYPTO_HANDLE** out
    , "Int")   ; return: HRESULT
●GetCryptoTransform(hSymmetricCrypto, mode, padding, feedbackSize, direction, cbIV, pIV, pphTransform) = DLL("infocardapi.dll", "int GetCryptoTransform(void*, dword, int, dword, int, dword, void*, void*)")
# 呼び出し: GetCryptoTransform(hSymmetricCrypto, mode, padding, feedbackSize, direction, cbIV, pIV, pphTransform)
# hSymmetricCrypto : INFORMATIONCARD_CRYPTO_HANDLE* -> "void*"
# mode : DWORD -> "dword"
# padding : PaddingMode -> "int"
# feedbackSize : DWORD -> "dword"
# direction : Direction -> "int"
# cbIV : DWORD -> "dword"
# pIV : BYTE* -> "void*"
# pphTransform : INFORMATIONCARD_CRYPTO_HANDLE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。