ホーム › Security.Cryptography › CTL_CONTEXT
CTL_CONTEXT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwMsgAndCertEncodingType | DWORD | 4 | +0 | +0 | 使用するエンコードの種類。次の例のように、証明書のエンコードの種類とメッセージのエンコードの種類をビット単位の OR 演算で組み合わせて、両方を指定することは常に可能です。 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING 現在定義されているエンコードの種類は次のとおりです。 |
| pbCtlEncoded | BYTE* | 8/4 | +8 | +4 | エンコードされた CTL へのポインター。 |
| cbCtlEncoded | DWORD | 4 | +16 | +8 | エンコードされた CTL のサイズ (バイト単位)。 |
| pCtlInfo | CTL_INFO* | 8/4 | +24 | +12 | CTL の情報を格納する CTL_INFO 構造体へのポインター。 |
| hCertStore | HCERTSTORE | 8/4 | +32 | +16 | 証明書ストアへのハンドル。 |
| hCryptMsg | void* | 8/4 | +40 | +20 | CTL_INFO を内部コンテンツとして含む、デコード済みの暗号署名されたメッセージへのオープンされた HCRYPTMSG ハンドル。 |
| pbCtlContent | BYTE* | 8/4 | +48 | +24 | 署名されたメッセージの、エンコードされた内部コンテンツ。 |
| cbCtlContent | DWORD | 4 | +56 | +28 | pbCtlContent のサイズ (バイト単位)。 |
公式ドキュメント
CTL_CONTEXT 構造体は、CTL のエンコードされた表現とデコードされた表現の両方を格納します。また、CTL_INFO を内部コンテンツとして含む、デコード済みの暗号署名されたメッセージへの、オープンされた HCRYPTMSG ハンドルも格納します。
CryptoAPI の低レベルメッセージ関数を使用すると、追加の署名者情報を取得できます。
CryptoAPI の関数から返された CTL_CONTEXT は、CertFreeCTLContext 関数を呼び出して解放する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// CTL_CONTEXT (x64 64 / x86 32 バイト)
typedef struct CTL_CONTEXT {
DWORD dwMsgAndCertEncodingType;
BYTE* pbCtlEncoded;
DWORD cbCtlEncoded;
CTL_INFO* pCtlInfo;
HCERTSTORE hCertStore;
void* hCryptMsg;
BYTE* pbCtlContent;
DWORD cbCtlContent;
} CTL_CONTEXT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CTL_CONTEXT
{
public uint dwMsgAndCertEncodingType;
public IntPtr pbCtlEncoded;
public uint cbCtlEncoded;
public IntPtr pCtlInfo;
public IntPtr hCertStore;
public IntPtr hCryptMsg;
public IntPtr pbCtlContent;
public uint cbCtlContent;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CTL_CONTEXT
Public dwMsgAndCertEncodingType As UInteger
Public pbCtlEncoded As IntPtr
Public cbCtlEncoded As UInteger
Public pCtlInfo As IntPtr
Public hCertStore As IntPtr
Public hCryptMsg As IntPtr
Public pbCtlContent As IntPtr
Public cbCtlContent As UInteger
End Structureimport ctypes
from ctypes import wintypes
class CTL_CONTEXT(ctypes.Structure):
_fields_ = [
("dwMsgAndCertEncodingType", wintypes.DWORD),
("pbCtlEncoded", ctypes.c_void_p),
("cbCtlEncoded", wintypes.DWORD),
("pCtlInfo", ctypes.c_void_p),
("hCertStore", ctypes.c_void_p),
("hCryptMsg", ctypes.c_void_p),
("pbCtlContent", ctypes.c_void_p),
("cbCtlContent", wintypes.DWORD),
]#[repr(C)]
pub struct CTL_CONTEXT {
pub dwMsgAndCertEncodingType: u32,
pub pbCtlEncoded: *mut core::ffi::c_void,
pub cbCtlEncoded: u32,
pub pCtlInfo: *mut core::ffi::c_void,
pub hCertStore: *mut core::ffi::c_void,
pub hCryptMsg: *mut core::ffi::c_void,
pub pbCtlContent: *mut core::ffi::c_void,
pub cbCtlContent: u32,
}import "golang.org/x/sys/windows"
type CTL_CONTEXT struct {
dwMsgAndCertEncodingType uint32
pbCtlEncoded uintptr
cbCtlEncoded uint32
pCtlInfo uintptr
hCertStore uintptr
hCryptMsg uintptr
pbCtlContent uintptr
cbCtlContent uint32
}type
CTL_CONTEXT = record
dwMsgAndCertEncodingType: DWORD;
pbCtlEncoded: Pointer;
cbCtlEncoded: DWORD;
pCtlInfo: Pointer;
hCertStore: Pointer;
hCryptMsg: Pointer;
pbCtlContent: Pointer;
cbCtlContent: DWORD;
end;const CTL_CONTEXT = extern struct {
dwMsgAndCertEncodingType: u32,
pbCtlEncoded: ?*anyopaque,
cbCtlEncoded: u32,
pCtlInfo: ?*anyopaque,
hCertStore: ?*anyopaque,
hCryptMsg: ?*anyopaque,
pbCtlContent: ?*anyopaque,
cbCtlContent: u32,
};type
CTL_CONTEXT {.bycopy.} = object
dwMsgAndCertEncodingType: uint32
pbCtlEncoded: pointer
cbCtlEncoded: uint32
pCtlInfo: pointer
hCertStore: pointer
hCryptMsg: pointer
pbCtlContent: pointer
cbCtlContent: uint32struct CTL_CONTEXT
{
uint dwMsgAndCertEncodingType;
void* pbCtlEncoded;
uint cbCtlEncoded;
void* pCtlInfo;
void* hCertStore;
void* hCryptMsg;
void* pbCtlContent;
uint cbCtlContent;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CTL_CONTEXT サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; dwMsgAndCertEncodingType : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pbCtlEncoded : BYTE* (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; cbCtlEncoded : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; pCtlInfo : CTL_INFO* (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; hCertStore : HCERTSTORE (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; hCryptMsg : void* (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; pbCtlContent : BYTE* (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; cbCtlContent : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CTL_CONTEXT サイズ: 64 バイト(x64)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; dwMsgAndCertEncodingType : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pbCtlEncoded : BYTE* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; cbCtlEncoded : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; pCtlInfo : CTL_INFO* (+24, 8byte) varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; hCertStore : HCERTSTORE (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; hCryptMsg : void* (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; pbCtlContent : BYTE* (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; cbCtlContent : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CTL_CONTEXT
#field int dwMsgAndCertEncodingType
#field intptr pbCtlEncoded
#field int cbCtlEncoded
#field intptr pCtlInfo
#field intptr hCertStore
#field intptr hCryptMsg
#field intptr pbCtlContent
#field int cbCtlContent
#endstruct
stdim st, CTL_CONTEXT ; NSTRUCT 変数を確保
st->dwMsgAndCertEncodingType = 100
mes "dwMsgAndCertEncodingType=" + st->dwMsgAndCertEncodingType