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

SignerTimeStampEx2

関数
アルゴリズムを指定してRFC3161タイムスタンプを付与する。
DLLMssign32.dll呼出規約winapi

シグネチャ

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

HRESULT SignerTimeStampEx2(
    SIGNER_TIMESTAMP_FLAGS dwFlags,   // optional
    SIGNER_SUBJECT_INFO* pSubjectInfo,
    LPCWSTR pwszHttpTimeStamp,
    ALG_ID dwAlgId,
    CRYPT_ATTRIBUTES* psRequest,
    void* pSipData,
    SIGNER_CONTEXT** ppSignerContext
);

パラメーター

名前方向
dwFlagsSIGNER_TIMESTAMP_FLAGSoptional
pSubjectInfoSIGNER_SUBJECT_INFO*in
pwszHttpTimeStampLPCWSTRin
dwAlgIdALG_IDin
psRequestCRYPT_ATTRIBUTES*in
pSipDatavoid*in
ppSignerContextSIGNER_CONTEXT**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SignerTimeStampEx2(
    SIGNER_TIMESTAMP_FLAGS dwFlags,   // optional
    SIGNER_SUBJECT_INFO* pSubjectInfo,
    LPCWSTR pwszHttpTimeStamp,
    ALG_ID dwAlgId,
    CRYPT_ATTRIBUTES* psRequest,
    void* pSipData,
    SIGNER_CONTEXT** ppSignerContext
);
[DllImport("Mssign32.dll", ExactSpelling = true)]
static extern int SignerTimeStampEx2(
    uint dwFlags,   // SIGNER_TIMESTAMP_FLAGS optional
    IntPtr pSubjectInfo,   // SIGNER_SUBJECT_INFO*
    [MarshalAs(UnmanagedType.LPWStr)] string pwszHttpTimeStamp,   // LPCWSTR
    uint dwAlgId,   // ALG_ID
    IntPtr psRequest,   // CRYPT_ATTRIBUTES*
    IntPtr pSipData,   // void*
    IntPtr ppSignerContext   // SIGNER_CONTEXT** out
);
<DllImport("Mssign32.dll", ExactSpelling:=True)>
Public Shared Function SignerTimeStampEx2(
    dwFlags As UInteger,   ' SIGNER_TIMESTAMP_FLAGS optional
    pSubjectInfo As IntPtr,   ' SIGNER_SUBJECT_INFO*
    <MarshalAs(UnmanagedType.LPWStr)> pwszHttpTimeStamp As String,   ' LPCWSTR
    dwAlgId As UInteger,   ' ALG_ID
    psRequest As IntPtr,   ' CRYPT_ATTRIBUTES*
    pSipData As IntPtr,   ' void*
    ppSignerContext As IntPtr   ' SIGNER_CONTEXT** out
) As Integer
End Function
' dwFlags : SIGNER_TIMESTAMP_FLAGS optional
' pSubjectInfo : SIGNER_SUBJECT_INFO*
' pwszHttpTimeStamp : LPCWSTR
' dwAlgId : ALG_ID
' psRequest : CRYPT_ATTRIBUTES*
' pSipData : void*
' ppSignerContext : SIGNER_CONTEXT** out
Declare PtrSafe Function SignerTimeStampEx2 Lib "mssign32" ( _
    ByVal dwFlags As Long, _
    ByVal pSubjectInfo As LongPtr, _
    ByVal pwszHttpTimeStamp As LongPtr, _
    ByVal dwAlgId As Long, _
    ByVal psRequest As LongPtr, _
    ByVal pSipData As LongPtr, _
    ByVal ppSignerContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SignerTimeStampEx2 = ctypes.windll.mssign32.SignerTimeStampEx2
SignerTimeStampEx2.restype = ctypes.c_int
SignerTimeStampEx2.argtypes = [
    wintypes.DWORD,  # dwFlags : SIGNER_TIMESTAMP_FLAGS optional
    ctypes.c_void_p,  # pSubjectInfo : SIGNER_SUBJECT_INFO*
    wintypes.LPCWSTR,  # pwszHttpTimeStamp : LPCWSTR
    wintypes.DWORD,  # dwAlgId : ALG_ID
    ctypes.c_void_p,  # psRequest : CRYPT_ATTRIBUTES*
    ctypes.POINTER(None),  # pSipData : void*
    ctypes.c_void_p,  # ppSignerContext : SIGNER_CONTEXT** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('Mssign32.dll')
SignerTimeStampEx2 = Fiddle::Function.new(
  lib['SignerTimeStampEx2'],
  [
    -Fiddle::TYPE_INT,  # dwFlags : SIGNER_TIMESTAMP_FLAGS optional
    Fiddle::TYPE_VOIDP,  # pSubjectInfo : SIGNER_SUBJECT_INFO*
    Fiddle::TYPE_VOIDP,  # pwszHttpTimeStamp : LPCWSTR
    -Fiddle::TYPE_INT,  # dwAlgId : ALG_ID
    Fiddle::TYPE_VOIDP,  # psRequest : CRYPT_ATTRIBUTES*
    Fiddle::TYPE_VOIDP,  # pSipData : void*
    Fiddle::TYPE_VOIDP,  # ppSignerContext : SIGNER_CONTEXT** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mssign32")]
extern "system" {
    fn SignerTimeStampEx2(
        dwFlags: u32,  // SIGNER_TIMESTAMP_FLAGS optional
        pSubjectInfo: *mut SIGNER_SUBJECT_INFO,  // SIGNER_SUBJECT_INFO*
        pwszHttpTimeStamp: *const u16,  // LPCWSTR
        dwAlgId: u32,  // ALG_ID
        psRequest: *mut CRYPT_ATTRIBUTES,  // CRYPT_ATTRIBUTES*
        pSipData: *mut (),  // void*
        ppSignerContext: *mut *mut SIGNER_CONTEXT  // SIGNER_CONTEXT** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("Mssign32.dll")]
public static extern int SignerTimeStampEx2(uint dwFlags, IntPtr pSubjectInfo, [MarshalAs(UnmanagedType.LPWStr)] string pwszHttpTimeStamp, uint dwAlgId, IntPtr psRequest, IntPtr pSipData, IntPtr ppSignerContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Mssign32_SignerTimeStampEx2' -Namespace Win32 -PassThru
# $api::SignerTimeStampEx2(dwFlags, pSubjectInfo, pwszHttpTimeStamp, dwAlgId, psRequest, pSipData, ppSignerContext)
#uselib "Mssign32.dll"
#func global SignerTimeStampEx2 "SignerTimeStampEx2" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SignerTimeStampEx2 dwFlags, varptr(pSubjectInfo), pwszHttpTimeStamp, dwAlgId, varptr(psRequest), pSipData, varptr(ppSignerContext)   ; 戻り値は stat
; dwFlags : SIGNER_TIMESTAMP_FLAGS optional -> "sptr"
; pSubjectInfo : SIGNER_SUBJECT_INFO* -> "sptr"
; pwszHttpTimeStamp : LPCWSTR -> "sptr"
; dwAlgId : ALG_ID -> "sptr"
; psRequest : CRYPT_ATTRIBUTES* -> "sptr"
; pSipData : void* -> "sptr"
; ppSignerContext : SIGNER_CONTEXT** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "Mssign32.dll"
#cfunc global SignerTimeStampEx2 "SignerTimeStampEx2" int, var, wstr, int, var, sptr, var
; res = SignerTimeStampEx2(dwFlags, pSubjectInfo, pwszHttpTimeStamp, dwAlgId, psRequest, pSipData, ppSignerContext)
; dwFlags : SIGNER_TIMESTAMP_FLAGS optional -> "int"
; pSubjectInfo : SIGNER_SUBJECT_INFO* -> "var"
; pwszHttpTimeStamp : LPCWSTR -> "wstr"
; dwAlgId : ALG_ID -> "int"
; psRequest : CRYPT_ATTRIBUTES* -> "var"
; pSipData : void* -> "sptr"
; ppSignerContext : SIGNER_CONTEXT** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SignerTimeStampEx2(SIGNER_TIMESTAMP_FLAGS dwFlags, SIGNER_SUBJECT_INFO* pSubjectInfo, LPCWSTR pwszHttpTimeStamp, ALG_ID dwAlgId, CRYPT_ATTRIBUTES* psRequest, void* pSipData, SIGNER_CONTEXT** ppSignerContext)
#uselib "Mssign32.dll"
#cfunc global SignerTimeStampEx2 "SignerTimeStampEx2" int, var, wstr, int, var, intptr, var
; res = SignerTimeStampEx2(dwFlags, pSubjectInfo, pwszHttpTimeStamp, dwAlgId, psRequest, pSipData, ppSignerContext)
; dwFlags : SIGNER_TIMESTAMP_FLAGS optional -> "int"
; pSubjectInfo : SIGNER_SUBJECT_INFO* -> "var"
; pwszHttpTimeStamp : LPCWSTR -> "wstr"
; dwAlgId : ALG_ID -> "int"
; psRequest : CRYPT_ATTRIBUTES* -> "var"
; pSipData : void* -> "intptr"
; ppSignerContext : SIGNER_CONTEXT** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mssign32 = windows.NewLazySystemDLL("Mssign32.dll")
	procSignerTimeStampEx2 = mssign32.NewProc("SignerTimeStampEx2")
)

// dwFlags (SIGNER_TIMESTAMP_FLAGS optional), pSubjectInfo (SIGNER_SUBJECT_INFO*), pwszHttpTimeStamp (LPCWSTR), dwAlgId (ALG_ID), psRequest (CRYPT_ATTRIBUTES*), pSipData (void*), ppSignerContext (SIGNER_CONTEXT** out)
r1, _, err := procSignerTimeStampEx2.Call(
	uintptr(dwFlags),
	uintptr(pSubjectInfo),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszHttpTimeStamp))),
	uintptr(dwAlgId),
	uintptr(psRequest),
	uintptr(pSipData),
	uintptr(ppSignerContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SignerTimeStampEx2(
  dwFlags: DWORD;   // SIGNER_TIMESTAMP_FLAGS optional
  pSubjectInfo: Pointer;   // SIGNER_SUBJECT_INFO*
  pwszHttpTimeStamp: PWideChar;   // LPCWSTR
  dwAlgId: DWORD;   // ALG_ID
  psRequest: Pointer;   // CRYPT_ATTRIBUTES*
  pSipData: Pointer;   // void*
  ppSignerContext: Pointer   // SIGNER_CONTEXT** out
): Integer; stdcall;
  external 'Mssign32.dll' name 'SignerTimeStampEx2';
result := DllCall("Mssign32\SignerTimeStampEx2"
    , "UInt", dwFlags   ; SIGNER_TIMESTAMP_FLAGS optional
    , "Ptr", pSubjectInfo   ; SIGNER_SUBJECT_INFO*
    , "WStr", pwszHttpTimeStamp   ; LPCWSTR
    , "UInt", dwAlgId   ; ALG_ID
    , "Ptr", psRequest   ; CRYPT_ATTRIBUTES*
    , "Ptr", pSipData   ; void*
    , "Ptr", ppSignerContext   ; SIGNER_CONTEXT** out
    , "Int")   ; return: HRESULT
●SignerTimeStampEx2(dwFlags, pSubjectInfo, pwszHttpTimeStamp, dwAlgId, psRequest, pSipData, ppSignerContext) = DLL("Mssign32.dll", "int SignerTimeStampEx2(dword, void*, char*, dword, void*, void*, void*)")
# 呼び出し: SignerTimeStampEx2(dwFlags, pSubjectInfo, pwszHttpTimeStamp, dwAlgId, psRequest, pSipData, ppSignerContext)
# dwFlags : SIGNER_TIMESTAMP_FLAGS optional -> "dword"
# pSubjectInfo : SIGNER_SUBJECT_INFO* -> "void*"
# pwszHttpTimeStamp : LPCWSTR -> "char*"
# dwAlgId : ALG_ID -> "dword"
# psRequest : CRYPT_ATTRIBUTES* -> "void*"
# pSipData : void* -> "void*"
# ppSignerContext : SIGNER_CONTEXT** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。