ホーム › Security.Cryptography › CERT_CHAIN_CONTEXT
CERT_CHAIN_CONTEXT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト単位)。 |
| TrustStatus | CERT_TRUST_STATUS | 8 | +4 | +4 | チェーンコンテキスト全体の信頼状態。 |
| cChain | DWORD | 4 | +12 | +12 | rgpChain配列の要素数。 |
| rgpChain | CERT_SIMPLE_CHAIN** | 8/4 | +16 | +16 | 単純チェーンポインタの配列へのポインタ。 |
| cLowerQualityChainContext | DWORD | 4 | +24 | +20 | rgpLowerQualityChainContext配列の要素数。 |
| rgpLowerQualityChainContext | CERT_CHAIN_CONTEXT** | 8/4 | +32 | +24 | 品質の低い代替チェーンコンテキストポインタの配列へのポインタ。 |
| fHasRevocationFreshnessTime | BOOL | 4 | +40 | +28 | dwRevocationFreshnessTimeが有効かを示すブール値。 |
| dwRevocationFreshnessTime | DWORD | 4 | +44 | +32 | 失効情報の鮮度(秒単位)。フラグがTRUEで有効。 |
| dwCreateFlags | DWORD | 4 | +48 | +36 | チェーン作成時に指定されたフラグ。 |
| ChainId | GUID | 16 | +52 | +40 | このチェーンコンテキストを識別するGUID。 |
各言語での定義
#include <windows.h>
// CERT_TRUST_STATUS (x64 8 / x86 8 バイト)
typedef struct CERT_TRUST_STATUS {
DWORD dwErrorStatus;
DWORD dwInfoStatus;
} CERT_TRUST_STATUS;
// CERT_CHAIN_CONTEXT (x64 72 / x86 56 バイト)
typedef struct CERT_CHAIN_CONTEXT {
DWORD cbSize;
CERT_TRUST_STATUS TrustStatus;
DWORD cChain;
CERT_SIMPLE_CHAIN** rgpChain;
DWORD cLowerQualityChainContext;
CERT_CHAIN_CONTEXT** rgpLowerQualityChainContext;
BOOL fHasRevocationFreshnessTime;
DWORD dwRevocationFreshnessTime;
DWORD dwCreateFlags;
GUID ChainId;
} CERT_CHAIN_CONTEXT;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_CONTEXT
{
public uint cbSize;
public CERT_TRUST_STATUS TrustStatus;
public uint cChain;
public IntPtr rgpChain;
public uint cLowerQualityChainContext;
public IntPtr rgpLowerQualityChainContext;
[MarshalAs(UnmanagedType.Bool)] public bool fHasRevocationFreshnessTime;
public uint dwRevocationFreshnessTime;
public uint dwCreateFlags;
public Guid ChainId;
}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_CONTEXT
Public cbSize As UInteger
Public TrustStatus As CERT_TRUST_STATUS
Public cChain As UInteger
Public rgpChain As IntPtr
Public cLowerQualityChainContext As UInteger
Public rgpLowerQualityChainContext As IntPtr
<MarshalAs(UnmanagedType.Bool)> Public fHasRevocationFreshnessTime As Boolean
Public dwRevocationFreshnessTime As UInteger
Public dwCreateFlags As UInteger
Public ChainId As Guid
End Structureimport ctypes
from ctypes import wintypes
class CERT_TRUST_STATUS(ctypes.Structure):
_fields_ = [
("dwErrorStatus", wintypes.DWORD),
("dwInfoStatus", wintypes.DWORD),
]
class CERT_CHAIN_CONTEXT(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("TrustStatus", CERT_TRUST_STATUS),
("cChain", wintypes.DWORD),
("rgpChain", ctypes.c_void_p),
("cLowerQualityChainContext", wintypes.DWORD),
("rgpLowerQualityChainContext", ctypes.c_void_p),
("fHasRevocationFreshnessTime", wintypes.BOOL),
("dwRevocationFreshnessTime", wintypes.DWORD),
("dwCreateFlags", wintypes.DWORD),
("ChainId", GUID),
]#[repr(C)]
pub struct CERT_TRUST_STATUS {
pub dwErrorStatus: u32,
pub dwInfoStatus: u32,
}
#[repr(C)]
pub struct CERT_CHAIN_CONTEXT {
pub cbSize: u32,
pub TrustStatus: CERT_TRUST_STATUS,
pub cChain: u32,
pub rgpChain: *mut core::ffi::c_void,
pub cLowerQualityChainContext: u32,
pub rgpLowerQualityChainContext: *mut core::ffi::c_void,
pub fHasRevocationFreshnessTime: i32,
pub dwRevocationFreshnessTime: u32,
pub dwCreateFlags: u32,
pub ChainId: GUID,
}import "golang.org/x/sys/windows"
type CERT_TRUST_STATUS struct {
dwErrorStatus uint32
dwInfoStatus uint32
}
type CERT_CHAIN_CONTEXT struct {
cbSize uint32
TrustStatus CERT_TRUST_STATUS
cChain uint32
rgpChain uintptr
cLowerQualityChainContext uint32
rgpLowerQualityChainContext uintptr
fHasRevocationFreshnessTime int32
dwRevocationFreshnessTime uint32
dwCreateFlags uint32
ChainId windows.GUID
}type
CERT_TRUST_STATUS = record
dwErrorStatus: DWORD;
dwInfoStatus: DWORD;
end;
CERT_CHAIN_CONTEXT = record
cbSize: DWORD;
TrustStatus: CERT_TRUST_STATUS;
cChain: DWORD;
rgpChain: Pointer;
cLowerQualityChainContext: DWORD;
rgpLowerQualityChainContext: Pointer;
fHasRevocationFreshnessTime: BOOL;
dwRevocationFreshnessTime: DWORD;
dwCreateFlags: DWORD;
ChainId: TGUID;
end;const CERT_TRUST_STATUS = extern struct {
dwErrorStatus: u32,
dwInfoStatus: u32,
};
const CERT_CHAIN_CONTEXT = extern struct {
cbSize: u32,
TrustStatus: CERT_TRUST_STATUS,
cChain: u32,
rgpChain: ?*anyopaque,
cLowerQualityChainContext: u32,
rgpLowerQualityChainContext: ?*anyopaque,
fHasRevocationFreshnessTime: i32,
dwRevocationFreshnessTime: u32,
dwCreateFlags: u32,
ChainId: GUID,
};type
CERT_TRUST_STATUS {.bycopy.} = object
dwErrorStatus: uint32
dwInfoStatus: uint32
CERT_CHAIN_CONTEXT {.bycopy.} = object
cbSize: uint32
TrustStatus: CERT_TRUST_STATUS
cChain: uint32
rgpChain: pointer
cLowerQualityChainContext: uint32
rgpLowerQualityChainContext: pointer
fHasRevocationFreshnessTime: int32
dwRevocationFreshnessTime: uint32
dwCreateFlags: uint32
ChainId: GUIDstruct CERT_TRUST_STATUS
{
uint dwErrorStatus;
uint dwInfoStatus;
}
struct CERT_CHAIN_CONTEXT
{
uint cbSize;
CERT_TRUST_STATUS TrustStatus;
uint cChain;
void* rgpChain;
uint cLowerQualityChainContext;
void* rgpLowerQualityChainContext;
int fHasRevocationFreshnessTime;
uint dwRevocationFreshnessTime;
uint dwCreateFlags;
GUID ChainId;
}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_CONTEXT サイズ: 56 バイト(x86)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; TrustStatus : CERT_TRUST_STATUS (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; cChain : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; rgpChain : CERT_SIMPLE_CHAIN** (+16, 4byte) varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; cLowerQualityChainContext : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; rgpLowerQualityChainContext : CERT_CHAIN_CONTEXT** (+24, 4byte) varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; fHasRevocationFreshnessTime : BOOL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwRevocationFreshnessTime : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; dwCreateFlags : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; ChainId : GUID (+40, 16byte) varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CERT_CHAIN_CONTEXT サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; TrustStatus : CERT_TRUST_STATUS (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; cChain : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; rgpChain : CERT_SIMPLE_CHAIN** (+16, 8byte) varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; cLowerQualityChainContext : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; rgpLowerQualityChainContext : CERT_CHAIN_CONTEXT** (+32, 8byte) varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; fHasRevocationFreshnessTime : BOOL (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; dwRevocationFreshnessTime : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; dwCreateFlags : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; ChainId : GUID (+52, 16byte) varptr(st)+52 を基点に操作(16byte:入れ子/配列)
; ※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 GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global CERT_CHAIN_CONTEXT
#field int cbSize
#field CERT_TRUST_STATUS TrustStatus
#field int cChain
#field intptr rgpChain
#field int cLowerQualityChainContext
#field intptr rgpLowerQualityChainContext
#field bool fHasRevocationFreshnessTime
#field int dwRevocationFreshnessTime
#field int dwCreateFlags
#field GUID ChainId
#endstruct
stdim st, CERT_CHAIN_CONTEXT ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize