ホーム › Security.Cryptography › CryptMsgVerifyCountersignatureEncodedEx
CryptMsgVerifyCountersignatureEncodedEx
関数エンコードされた副署名を検証する拡張版関数。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptMsgVerifyCountersignatureEncodedEx(
HCRYPTPROV_LEGACY hCryptProv, // optional
DWORD dwEncodingType,
BYTE* pbSignerInfo,
DWORD cbSignerInfo,
BYTE* pbSignerInfoCountersignature,
DWORD cbSignerInfoCountersignature,
DWORD dwSignerType,
void* pvSigner,
DWORD dwFlags,
void* pvExtra // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hCryptProv | HCRYPTPROV_LEGACY | inoptional |
| dwEncodingType | DWORD | in |
| pbSignerInfo | BYTE* | in |
| cbSignerInfo | DWORD | in |
| pbSignerInfoCountersignature | BYTE* | in |
| cbSignerInfoCountersignature | DWORD | in |
| dwSignerType | DWORD | in |
| pvSigner | void* | in |
| dwFlags | DWORD | in |
| pvExtra | void* | inoutoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptMsgVerifyCountersignatureEncodedEx(
HCRYPTPROV_LEGACY hCryptProv, // optional
DWORD dwEncodingType,
BYTE* pbSignerInfo,
DWORD cbSignerInfo,
BYTE* pbSignerInfoCountersignature,
DWORD cbSignerInfoCountersignature,
DWORD dwSignerType,
void* pvSigner,
DWORD dwFlags,
void* pvExtra // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptMsgVerifyCountersignatureEncodedEx(
UIntPtr hCryptProv, // HCRYPTPROV_LEGACY optional
uint dwEncodingType, // DWORD
IntPtr pbSignerInfo, // BYTE*
uint cbSignerInfo, // DWORD
IntPtr pbSignerInfoCountersignature, // BYTE*
uint cbSignerInfoCountersignature, // DWORD
uint dwSignerType, // DWORD
IntPtr pvSigner, // void*
uint dwFlags, // DWORD
IntPtr pvExtra // void* optional, in/out
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptMsgVerifyCountersignatureEncodedEx(
hCryptProv As UIntPtr, ' HCRYPTPROV_LEGACY optional
dwEncodingType As UInteger, ' DWORD
pbSignerInfo As IntPtr, ' BYTE*
cbSignerInfo As UInteger, ' DWORD
pbSignerInfoCountersignature As IntPtr, ' BYTE*
cbSignerInfoCountersignature As UInteger, ' DWORD
dwSignerType As UInteger, ' DWORD
pvSigner As IntPtr, ' void*
dwFlags As UInteger, ' DWORD
pvExtra As IntPtr ' void* optional, in/out
) As Boolean
End Function' hCryptProv : HCRYPTPROV_LEGACY optional
' dwEncodingType : DWORD
' pbSignerInfo : BYTE*
' cbSignerInfo : DWORD
' pbSignerInfoCountersignature : BYTE*
' cbSignerInfoCountersignature : DWORD
' dwSignerType : DWORD
' pvSigner : void*
' dwFlags : DWORD
' pvExtra : void* optional, in/out
Declare PtrSafe Function CryptMsgVerifyCountersignatureEncodedEx Lib "crypt32" ( _
ByVal hCryptProv As LongPtr, _
ByVal dwEncodingType As Long, _
ByVal pbSignerInfo As LongPtr, _
ByVal cbSignerInfo As Long, _
ByVal pbSignerInfoCountersignature As LongPtr, _
ByVal cbSignerInfoCountersignature As Long, _
ByVal dwSignerType As Long, _
ByVal pvSigner As LongPtr, _
ByVal dwFlags As Long, _
ByVal pvExtra As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptMsgVerifyCountersignatureEncodedEx = ctypes.windll.crypt32.CryptMsgVerifyCountersignatureEncodedEx
CryptMsgVerifyCountersignatureEncodedEx.restype = wintypes.BOOL
CryptMsgVerifyCountersignatureEncodedEx.argtypes = [
ctypes.c_size_t, # hCryptProv : HCRYPTPROV_LEGACY optional
wintypes.DWORD, # dwEncodingType : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pbSignerInfo : BYTE*
wintypes.DWORD, # cbSignerInfo : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pbSignerInfoCountersignature : BYTE*
wintypes.DWORD, # cbSignerInfoCountersignature : DWORD
wintypes.DWORD, # dwSignerType : DWORD
ctypes.POINTER(None), # pvSigner : void*
wintypes.DWORD, # dwFlags : DWORD
ctypes.POINTER(None), # pvExtra : void* optional, in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptMsgVerifyCountersignatureEncodedEx = Fiddle::Function.new(
lib['CryptMsgVerifyCountersignatureEncodedEx'],
[
Fiddle::TYPE_UINTPTR_T, # hCryptProv : HCRYPTPROV_LEGACY optional
-Fiddle::TYPE_INT, # dwEncodingType : DWORD
Fiddle::TYPE_VOIDP, # pbSignerInfo : BYTE*
-Fiddle::TYPE_INT, # cbSignerInfo : DWORD
Fiddle::TYPE_VOIDP, # pbSignerInfoCountersignature : BYTE*
-Fiddle::TYPE_INT, # cbSignerInfoCountersignature : DWORD
-Fiddle::TYPE_INT, # dwSignerType : DWORD
Fiddle::TYPE_VOIDP, # pvSigner : void*
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pvExtra : void* optional, in/out
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptMsgVerifyCountersignatureEncodedEx(
hCryptProv: usize, // HCRYPTPROV_LEGACY optional
dwEncodingType: u32, // DWORD
pbSignerInfo: *mut u8, // BYTE*
cbSignerInfo: u32, // DWORD
pbSignerInfoCountersignature: *mut u8, // BYTE*
cbSignerInfoCountersignature: u32, // DWORD
dwSignerType: u32, // DWORD
pvSigner: *mut (), // void*
dwFlags: u32, // DWORD
pvExtra: *mut () // void* optional, in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern bool CryptMsgVerifyCountersignatureEncodedEx(UIntPtr hCryptProv, uint dwEncodingType, IntPtr pbSignerInfo, uint cbSignerInfo, IntPtr pbSignerInfoCountersignature, uint cbSignerInfoCountersignature, uint dwSignerType, IntPtr pvSigner, uint dwFlags, IntPtr pvExtra);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptMsgVerifyCountersignatureEncodedEx' -Namespace Win32 -PassThru
# $api::CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra)#uselib "CRYPT32.dll"
#func global CryptMsgVerifyCountersignatureEncodedEx "CryptMsgVerifyCountersignatureEncodedEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CryptMsgVerifyCountersignatureEncodedEx hCryptProv, dwEncodingType, varptr(pbSignerInfo), cbSignerInfo, varptr(pbSignerInfoCountersignature), cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra ; 戻り値は stat
; hCryptProv : HCRYPTPROV_LEGACY optional -> "sptr"
; dwEncodingType : DWORD -> "sptr"
; pbSignerInfo : BYTE* -> "sptr"
; cbSignerInfo : DWORD -> "sptr"
; pbSignerInfoCountersignature : BYTE* -> "sptr"
; cbSignerInfoCountersignature : DWORD -> "sptr"
; dwSignerType : DWORD -> "sptr"
; pvSigner : void* -> "sptr"
; dwFlags : DWORD -> "sptr"
; pvExtra : void* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CRYPT32.dll" #cfunc global CryptMsgVerifyCountersignatureEncodedEx "CryptMsgVerifyCountersignatureEncodedEx" sptr, int, var, int, var, int, int, sptr, int, sptr ; res = CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra) ; hCryptProv : HCRYPTPROV_LEGACY optional -> "sptr" ; dwEncodingType : DWORD -> "int" ; pbSignerInfo : BYTE* -> "var" ; cbSignerInfo : DWORD -> "int" ; pbSignerInfoCountersignature : BYTE* -> "var" ; cbSignerInfoCountersignature : DWORD -> "int" ; dwSignerType : DWORD -> "int" ; pvSigner : void* -> "sptr" ; dwFlags : DWORD -> "int" ; pvExtra : void* optional, in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CRYPT32.dll" #cfunc global CryptMsgVerifyCountersignatureEncodedEx "CryptMsgVerifyCountersignatureEncodedEx" sptr, int, sptr, int, sptr, int, int, sptr, int, sptr ; res = CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, varptr(pbSignerInfo), cbSignerInfo, varptr(pbSignerInfoCountersignature), cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra) ; hCryptProv : HCRYPTPROV_LEGACY optional -> "sptr" ; dwEncodingType : DWORD -> "int" ; pbSignerInfo : BYTE* -> "sptr" ; cbSignerInfo : DWORD -> "int" ; pbSignerInfoCountersignature : BYTE* -> "sptr" ; cbSignerInfoCountersignature : DWORD -> "int" ; dwSignerType : DWORD -> "int" ; pvSigner : void* -> "sptr" ; dwFlags : DWORD -> "int" ; pvExtra : void* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CryptMsgVerifyCountersignatureEncodedEx(HCRYPTPROV_LEGACY hCryptProv, DWORD dwEncodingType, BYTE* pbSignerInfo, DWORD cbSignerInfo, BYTE* pbSignerInfoCountersignature, DWORD cbSignerInfoCountersignature, DWORD dwSignerType, void* pvSigner, DWORD dwFlags, void* pvExtra) #uselib "CRYPT32.dll" #cfunc global CryptMsgVerifyCountersignatureEncodedEx "CryptMsgVerifyCountersignatureEncodedEx" intptr, int, var, int, var, int, int, intptr, int, intptr ; res = CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra) ; hCryptProv : HCRYPTPROV_LEGACY optional -> "intptr" ; dwEncodingType : DWORD -> "int" ; pbSignerInfo : BYTE* -> "var" ; cbSignerInfo : DWORD -> "int" ; pbSignerInfoCountersignature : BYTE* -> "var" ; cbSignerInfoCountersignature : DWORD -> "int" ; dwSignerType : DWORD -> "int" ; pvSigner : void* -> "intptr" ; dwFlags : DWORD -> "int" ; pvExtra : void* optional, in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CryptMsgVerifyCountersignatureEncodedEx(HCRYPTPROV_LEGACY hCryptProv, DWORD dwEncodingType, BYTE* pbSignerInfo, DWORD cbSignerInfo, BYTE* pbSignerInfoCountersignature, DWORD cbSignerInfoCountersignature, DWORD dwSignerType, void* pvSigner, DWORD dwFlags, void* pvExtra) #uselib "CRYPT32.dll" #cfunc global CryptMsgVerifyCountersignatureEncodedEx "CryptMsgVerifyCountersignatureEncodedEx" intptr, int, intptr, int, intptr, int, int, intptr, int, intptr ; res = CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, varptr(pbSignerInfo), cbSignerInfo, varptr(pbSignerInfoCountersignature), cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra) ; hCryptProv : HCRYPTPROV_LEGACY optional -> "intptr" ; dwEncodingType : DWORD -> "int" ; pbSignerInfo : BYTE* -> "intptr" ; cbSignerInfo : DWORD -> "int" ; pbSignerInfoCountersignature : BYTE* -> "intptr" ; cbSignerInfoCountersignature : DWORD -> "int" ; dwSignerType : DWORD -> "int" ; pvSigner : void* -> "intptr" ; dwFlags : DWORD -> "int" ; pvExtra : void* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptMsgVerifyCountersignatureEncodedEx = crypt32.NewProc("CryptMsgVerifyCountersignatureEncodedEx")
)
// hCryptProv (HCRYPTPROV_LEGACY optional), dwEncodingType (DWORD), pbSignerInfo (BYTE*), cbSignerInfo (DWORD), pbSignerInfoCountersignature (BYTE*), cbSignerInfoCountersignature (DWORD), dwSignerType (DWORD), pvSigner (void*), dwFlags (DWORD), pvExtra (void* optional, in/out)
r1, _, err := procCryptMsgVerifyCountersignatureEncodedEx.Call(
uintptr(hCryptProv),
uintptr(dwEncodingType),
uintptr(pbSignerInfo),
uintptr(cbSignerInfo),
uintptr(pbSignerInfoCountersignature),
uintptr(cbSignerInfoCountersignature),
uintptr(dwSignerType),
uintptr(pvSigner),
uintptr(dwFlags),
uintptr(pvExtra),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptMsgVerifyCountersignatureEncodedEx(
hCryptProv: NativeUInt; // HCRYPTPROV_LEGACY optional
dwEncodingType: DWORD; // DWORD
pbSignerInfo: Pointer; // BYTE*
cbSignerInfo: DWORD; // DWORD
pbSignerInfoCountersignature: Pointer; // BYTE*
cbSignerInfoCountersignature: DWORD; // DWORD
dwSignerType: DWORD; // DWORD
pvSigner: Pointer; // void*
dwFlags: DWORD; // DWORD
pvExtra: Pointer // void* optional, in/out
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptMsgVerifyCountersignatureEncodedEx';result := DllCall("CRYPT32\CryptMsgVerifyCountersignatureEncodedEx"
, "UPtr", hCryptProv ; HCRYPTPROV_LEGACY optional
, "UInt", dwEncodingType ; DWORD
, "Ptr", pbSignerInfo ; BYTE*
, "UInt", cbSignerInfo ; DWORD
, "Ptr", pbSignerInfoCountersignature ; BYTE*
, "UInt", cbSignerInfoCountersignature ; DWORD
, "UInt", dwSignerType ; DWORD
, "Ptr", pvSigner ; void*
, "UInt", dwFlags ; DWORD
, "Ptr", pvExtra ; void* optional, in/out
, "Int") ; return: BOOL●CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra) = DLL("CRYPT32.dll", "bool CryptMsgVerifyCountersignatureEncodedEx(int, dword, void*, dword, void*, dword, dword, void*, dword, void*)")
# 呼び出し: CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra)
# hCryptProv : HCRYPTPROV_LEGACY optional -> "int"
# dwEncodingType : DWORD -> "dword"
# pbSignerInfo : BYTE* -> "void*"
# cbSignerInfo : DWORD -> "dword"
# pbSignerInfoCountersignature : BYTE* -> "void*"
# cbSignerInfoCountersignature : DWORD -> "dword"
# dwSignerType : DWORD -> "dword"
# pvSigner : void* -> "void*"
# dwFlags : DWORD -> "dword"
# pvExtra : void* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。