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

CERT_CHAIN_ELEMENT

構造体
サイズx64: 56 バイト / x86: 32 バイト

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のサイズ(バイト単位)。
pCertContextCERT_CONTEXT*8/4+8+4このチェーン要素に対応する証明書コンテキストへのポインタ。
TrustStatusCERT_TRUST_STATUS8+16+8この要素の信頼状態(エラー・情報フラグ)。
pRevocationInfoCERT_REVOCATION_INFO*8/4+24+16この要素の失効確認情報へのポインタ。NULL可。
pIssuanceUsageCTL_USAGE*8/4+32+20発行ポリシー用途の集合へのポインタ。NULL可。
pApplicationUsageCTL_USAGE*8/4+40+24アプリケーションポリシー用途の集合へのポインタ。NULL可。
pwszExtendedErrorInfoLPWSTR8/4+48+28拡張エラー情報を示す文字列。NULL可。

各言語での定義

#include <windows.h>

// CERT_TRUST_STATUS  (x64 8 / x86 8 バイト)
typedef struct CERT_TRUST_STATUS {
    DWORD dwErrorStatus;
    DWORD dwInfoStatus;
} CERT_TRUST_STATUS;

// CERT_CHAIN_ELEMENT  (x64 56 / x86 32 バイト)
typedef struct CERT_CHAIN_ELEMENT {
    DWORD cbSize;
    CERT_CONTEXT* pCertContext;
    CERT_TRUST_STATUS TrustStatus;
    CERT_REVOCATION_INFO* pRevocationInfo;
    CTL_USAGE* pIssuanceUsage;
    CTL_USAGE* pApplicationUsage;
    LPWSTR pwszExtendedErrorInfo;
} CERT_CHAIN_ELEMENT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CERT_TRUST_STATUS
{
    public uint dwErrorStatus;
    public uint dwInfoStatus;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CERT_CHAIN_ELEMENT
{
    public uint cbSize;
    public IntPtr pCertContext;
    public CERT_TRUST_STATUS TrustStatus;
    public IntPtr pRevocationInfo;
    public IntPtr pIssuanceUsage;
    public IntPtr pApplicationUsage;
    public IntPtr pwszExtendedErrorInfo;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CERT_TRUST_STATUS
    Public dwErrorStatus As UInteger
    Public dwInfoStatus As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CERT_CHAIN_ELEMENT
    Public cbSize As UInteger
    Public pCertContext As IntPtr
    Public TrustStatus As CERT_TRUST_STATUS
    Public pRevocationInfo As IntPtr
    Public pIssuanceUsage As IntPtr
    Public pApplicationUsage As IntPtr
    Public pwszExtendedErrorInfo As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class CERT_TRUST_STATUS(ctypes.Structure):
    _fields_ = [
        ("dwErrorStatus", wintypes.DWORD),
        ("dwInfoStatus", wintypes.DWORD),
    ]

class CERT_CHAIN_ELEMENT(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("pCertContext", ctypes.c_void_p),
        ("TrustStatus", CERT_TRUST_STATUS),
        ("pRevocationInfo", ctypes.c_void_p),
        ("pIssuanceUsage", ctypes.c_void_p),
        ("pApplicationUsage", ctypes.c_void_p),
        ("pwszExtendedErrorInfo", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct CERT_TRUST_STATUS {
    pub dwErrorStatus: u32,
    pub dwInfoStatus: u32,
}

#[repr(C)]
pub struct CERT_CHAIN_ELEMENT {
    pub cbSize: u32,
    pub pCertContext: *mut core::ffi::c_void,
    pub TrustStatus: CERT_TRUST_STATUS,
    pub pRevocationInfo: *mut core::ffi::c_void,
    pub pIssuanceUsage: *mut core::ffi::c_void,
    pub pApplicationUsage: *mut core::ffi::c_void,
    pub pwszExtendedErrorInfo: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type CERT_TRUST_STATUS struct {
	dwErrorStatus uint32
	dwInfoStatus uint32
}

type CERT_CHAIN_ELEMENT struct {
	cbSize uint32
	pCertContext uintptr
	TrustStatus CERT_TRUST_STATUS
	pRevocationInfo uintptr
	pIssuanceUsage uintptr
	pApplicationUsage uintptr
	pwszExtendedErrorInfo uintptr
}
type
  CERT_TRUST_STATUS = record
    dwErrorStatus: DWORD;
    dwInfoStatus: DWORD;
  end;

  CERT_CHAIN_ELEMENT = record
    cbSize: DWORD;
    pCertContext: Pointer;
    TrustStatus: CERT_TRUST_STATUS;
    pRevocationInfo: Pointer;
    pIssuanceUsage: Pointer;
    pApplicationUsage: Pointer;
    pwszExtendedErrorInfo: Pointer;
  end;
const CERT_TRUST_STATUS = extern struct {
    dwErrorStatus: u32,
    dwInfoStatus: u32,
};

const CERT_CHAIN_ELEMENT = extern struct {
    cbSize: u32,
    pCertContext: ?*anyopaque,
    TrustStatus: CERT_TRUST_STATUS,
    pRevocationInfo: ?*anyopaque,
    pIssuanceUsage: ?*anyopaque,
    pApplicationUsage: ?*anyopaque,
    pwszExtendedErrorInfo: ?*anyopaque,
};
type
  CERT_TRUST_STATUS {.bycopy.} = object
    dwErrorStatus: uint32
    dwInfoStatus: uint32

  CERT_CHAIN_ELEMENT {.bycopy.} = object
    cbSize: uint32
    pCertContext: pointer
    TrustStatus: CERT_TRUST_STATUS
    pRevocationInfo: pointer
    pIssuanceUsage: pointer
    pApplicationUsage: pointer
    pwszExtendedErrorInfo: pointer
struct CERT_TRUST_STATUS
{
    uint dwErrorStatus;
    uint dwInfoStatus;
}

struct CERT_CHAIN_ELEMENT
{
    uint cbSize;
    void* pCertContext;
    CERT_TRUST_STATUS TrustStatus;
    void* pRevocationInfo;
    void* pIssuanceUsage;
    void* pApplicationUsage;
    void* pwszExtendedErrorInfo;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CERT_CHAIN_ELEMENT サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pCertContext : CERT_CONTEXT* (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; TrustStatus : CERT_TRUST_STATUS (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; pRevocationInfo : CERT_REVOCATION_INFO* (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; pIssuanceUsage : CTL_USAGE* (+20, 4byte)  varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; pApplicationUsage : CTL_USAGE* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; pwszExtendedErrorInfo : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CERT_CHAIN_ELEMENT サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pCertContext : CERT_CONTEXT* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; TrustStatus : CERT_TRUST_STATUS (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; pRevocationInfo : CERT_REVOCATION_INFO* (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; pIssuanceUsage : CTL_USAGE* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; pApplicationUsage : CTL_USAGE* (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; pwszExtendedErrorInfo : LPWSTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CERT_TRUST_STATUS
    #field int dwErrorStatus
    #field int dwInfoStatus
#endstruct

#defstruct global CERT_CHAIN_ELEMENT
    #field int cbSize
    #field intptr pCertContext
    #field CERT_TRUST_STATUS TrustStatus
    #field intptr pRevocationInfo
    #field intptr pIssuanceUsage
    #field intptr pApplicationUsage
    #field intptr pwszExtendedErrorInfo
#endstruct

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