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

CRYPT_TIMESTAMP_REQUEST

構造体
サイズx64: 88 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwVersionCRYPT_TIMESTAMP_VERSION4+0+0

タイムスタンプ要求のバージョンを指定する DWORD 値です。

このメンバーには、次の値のいずれかを指定できます。

意味
TIMESTAMP_VERSION
1
バージョン 1 のタイムスタンプ要求です。
HashAlgorithmCRYPT_ALGORITHM_IDENTIFIER24/12+8+4ハッシュの計算に使用されたアルゴリズムに関する情報を格納する CRYPT_ALGORITHM_IDENTIFIER 構造体です。
HashedMessageCRYPT_INTEGER_BLOB16/8+32+16タイムスタンプを付与するハッシュ値を指定する CRYPT_DER_BLOB 構造体です。
pszTSAPolicyIdLPSTR8/4+48+24省略可能です。タイムスタンプ トークンを提供する際に適用されるタイムスタンプ機関 (TSA) のポリシーを指定する、NULL で終わる文字列へのポインターです。
NonceCRYPT_INTEGER_BLOB16/8+56+28省略可能です。ローカル クロックが利用できない場合に、応答が適時のものであることをクライアントが検証するために使用するナンス値を格納する CRYPT_INTEGER_BLOB 構造体です。
fCertReqBOOL4+72+36タイムスタンプ トークンの署名に使用された証明書を TSA が応答に含めなければならないかどうかを示すブール値です。
cExtensionDWORD4+76+40rgExtension メンバーが指す配列の要素数です。
rgExtensionCERT_EXTENSION*8/4+80+44要求で渡される拡張情報を格納する CERT_EXTENSION 構造体の配列へのポインターです。

公式ドキュメント

CRYPT_TIMESTAMP_REQUEST 構造体は、TimeStampReq 型の Abstract Syntax Notation One (ASN.1) 定義に対応するタイムスタンプ要求構造体を定義します。CRYPT_TIMESTAMP_REQUEST 構造体は内部的に使用されます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// CRYPT_INTEGER_BLOB  (x64 16 / x86 8 バイト)
typedef struct CRYPT_INTEGER_BLOB {
    DWORD cbData;
    BYTE* pbData;
} CRYPT_INTEGER_BLOB;

// CRYPT_ALGORITHM_IDENTIFIER  (x64 24 / x86 12 バイト)
typedef struct CRYPT_ALGORITHM_IDENTIFIER {
    LPSTR pszObjId;
    CRYPT_INTEGER_BLOB Parameters;
} CRYPT_ALGORITHM_IDENTIFIER;

// CRYPT_TIMESTAMP_REQUEST  (x64 88 / x86 48 バイト)
typedef struct CRYPT_TIMESTAMP_REQUEST {
    CRYPT_TIMESTAMP_VERSION dwVersion;
    CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
    CRYPT_INTEGER_BLOB HashedMessage;
    LPSTR pszTSAPolicyId;
    CRYPT_INTEGER_BLOB Nonce;
    BOOL fCertReq;
    DWORD cExtension;
    CERT_EXTENSION* rgExtension;
} CRYPT_TIMESTAMP_REQUEST;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_INTEGER_BLOB
{
    public uint cbData;
    public IntPtr pbData;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_ALGORITHM_IDENTIFIER
{
    public IntPtr pszObjId;
    public CRYPT_INTEGER_BLOB Parameters;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_TIMESTAMP_REQUEST
{
    public uint dwVersion;
    public CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
    public CRYPT_INTEGER_BLOB HashedMessage;
    public IntPtr pszTSAPolicyId;
    public CRYPT_INTEGER_BLOB Nonce;
    [MarshalAs(UnmanagedType.Bool)] public bool fCertReq;
    public uint cExtension;
    public IntPtr rgExtension;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_INTEGER_BLOB
    Public cbData As UInteger
    Public pbData As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_ALGORITHM_IDENTIFIER
    Public pszObjId As IntPtr
    Public Parameters As CRYPT_INTEGER_BLOB
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_TIMESTAMP_REQUEST
    Public dwVersion As UInteger
    Public HashAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
    Public HashedMessage As CRYPT_INTEGER_BLOB
    Public pszTSAPolicyId As IntPtr
    Public Nonce As CRYPT_INTEGER_BLOB
    <MarshalAs(UnmanagedType.Bool)> Public fCertReq As Boolean
    Public cExtension As UInteger
    Public rgExtension As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class CRYPT_INTEGER_BLOB(ctypes.Structure):
    _fields_ = [
        ("cbData", wintypes.DWORD),
        ("pbData", ctypes.c_void_p),
    ]

class CRYPT_ALGORITHM_IDENTIFIER(ctypes.Structure):
    _fields_ = [
        ("pszObjId", ctypes.c_void_p),
        ("Parameters", CRYPT_INTEGER_BLOB),
    ]

class CRYPT_TIMESTAMP_REQUEST(ctypes.Structure):
    _fields_ = [
        ("dwVersion", wintypes.DWORD),
        ("HashAlgorithm", CRYPT_ALGORITHM_IDENTIFIER),
        ("HashedMessage", CRYPT_INTEGER_BLOB),
        ("pszTSAPolicyId", ctypes.c_void_p),
        ("Nonce", CRYPT_INTEGER_BLOB),
        ("fCertReq", wintypes.BOOL),
        ("cExtension", wintypes.DWORD),
        ("rgExtension", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct CRYPT_INTEGER_BLOB {
    pub cbData: u32,
    pub pbData: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct CRYPT_ALGORITHM_IDENTIFIER {
    pub pszObjId: *mut core::ffi::c_void,
    pub Parameters: CRYPT_INTEGER_BLOB,
}

#[repr(C)]
pub struct CRYPT_TIMESTAMP_REQUEST {
    pub dwVersion: u32,
    pub HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
    pub HashedMessage: CRYPT_INTEGER_BLOB,
    pub pszTSAPolicyId: *mut core::ffi::c_void,
    pub Nonce: CRYPT_INTEGER_BLOB,
    pub fCertReq: i32,
    pub cExtension: u32,
    pub rgExtension: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type CRYPT_INTEGER_BLOB struct {
	cbData uint32
	pbData uintptr
}

type CRYPT_ALGORITHM_IDENTIFIER struct {
	pszObjId uintptr
	Parameters CRYPT_INTEGER_BLOB
}

type CRYPT_TIMESTAMP_REQUEST struct {
	dwVersion uint32
	HashAlgorithm CRYPT_ALGORITHM_IDENTIFIER
	HashedMessage CRYPT_INTEGER_BLOB
	pszTSAPolicyId uintptr
	Nonce CRYPT_INTEGER_BLOB
	fCertReq int32
	cExtension uint32
	rgExtension uintptr
}
type
  CRYPT_INTEGER_BLOB = record
    cbData: DWORD;
    pbData: Pointer;
  end;

  CRYPT_ALGORITHM_IDENTIFIER = record
    pszObjId: Pointer;
    Parameters: CRYPT_INTEGER_BLOB;
  end;

  CRYPT_TIMESTAMP_REQUEST = record
    dwVersion: DWORD;
    HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
    HashedMessage: CRYPT_INTEGER_BLOB;
    pszTSAPolicyId: Pointer;
    Nonce: CRYPT_INTEGER_BLOB;
    fCertReq: BOOL;
    cExtension: DWORD;
    rgExtension: Pointer;
  end;
const CRYPT_INTEGER_BLOB = extern struct {
    cbData: u32,
    pbData: ?*anyopaque,
};

const CRYPT_ALGORITHM_IDENTIFIER = extern struct {
    pszObjId: ?*anyopaque,
    Parameters: CRYPT_INTEGER_BLOB,
};

const CRYPT_TIMESTAMP_REQUEST = extern struct {
    dwVersion: u32,
    HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER,
    HashedMessage: CRYPT_INTEGER_BLOB,
    pszTSAPolicyId: ?*anyopaque,
    Nonce: CRYPT_INTEGER_BLOB,
    fCertReq: i32,
    cExtension: u32,
    rgExtension: ?*anyopaque,
};
type
  CRYPT_INTEGER_BLOB {.bycopy.} = object
    cbData: uint32
    pbData: pointer

  CRYPT_ALGORITHM_IDENTIFIER {.bycopy.} = object
    pszObjId: pointer
    Parameters: CRYPT_INTEGER_BLOB

  CRYPT_TIMESTAMP_REQUEST {.bycopy.} = object
    dwVersion: uint32
    HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER
    HashedMessage: CRYPT_INTEGER_BLOB
    pszTSAPolicyId: pointer
    Nonce: CRYPT_INTEGER_BLOB
    fCertReq: int32
    cExtension: uint32
    rgExtension: pointer
struct CRYPT_INTEGER_BLOB
{
    uint cbData;
    void* pbData;
}

struct CRYPT_ALGORITHM_IDENTIFIER
{
    void* pszObjId;
    CRYPT_INTEGER_BLOB Parameters;
}

struct CRYPT_TIMESTAMP_REQUEST
{
    uint dwVersion;
    CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
    CRYPT_INTEGER_BLOB HashedMessage;
    void* pszTSAPolicyId;
    CRYPT_INTEGER_BLOB Nonce;
    int fCertReq;
    uint cExtension;
    void* rgExtension;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CRYPT_TIMESTAMP_REQUEST サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; dwVersion : CRYPT_TIMESTAMP_VERSION (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; HashAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+4, 12byte)  varptr(st)+4 を基点に操作(12byte:入れ子/配列)
; HashedMessage : CRYPT_INTEGER_BLOB (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; pszTSAPolicyId : LPSTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; Nonce : CRYPT_INTEGER_BLOB (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; fCertReq : BOOL (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; cExtension : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; rgExtension : CERT_EXTENSION* (+44, 4byte)  varptr(st)+44 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CRYPT_TIMESTAMP_REQUEST サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; dwVersion : CRYPT_TIMESTAMP_VERSION (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; HashAlgorithm : CRYPT_ALGORITHM_IDENTIFIER (+8, 24byte)  varptr(st)+8 を基点に操作(24byte:入れ子/配列)
; HashedMessage : CRYPT_INTEGER_BLOB (+32, 16byte)  varptr(st)+32 を基点に操作(16byte:入れ子/配列)
; pszTSAPolicyId : LPSTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; Nonce : CRYPT_INTEGER_BLOB (+56, 16byte)  varptr(st)+56 を基点に操作(16byte:入れ子/配列)
; fCertReq : BOOL (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; cExtension : DWORD (+76, 4byte)  st.19 = 値  /  値 = st.19   (lpoke/lpeek も可)
; rgExtension : CERT_EXTENSION* (+80, 8byte)  varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CRYPT_INTEGER_BLOB
    #field int cbData
    #field intptr pbData
#endstruct

#defstruct global CRYPT_ALGORITHM_IDENTIFIER
    #field intptr pszObjId
    #field CRYPT_INTEGER_BLOB Parameters
#endstruct

#defstruct global CRYPT_TIMESTAMP_REQUEST
    #field int dwVersion
    #field CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm
    #field CRYPT_INTEGER_BLOB HashedMessage
    #field intptr pszTSAPolicyId
    #field CRYPT_INTEGER_BLOB Nonce
    #field bool fCertReq
    #field int cExtension
    #field intptr rgExtension
#endstruct

stdim st, CRYPT_TIMESTAMP_REQUEST        ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion