Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Namespace

crypt32

Public Namespace

Namespaces

Structs

Types

Values

Functions

pub extern "crypt32" fn CertOpenStore(lpszStoreProvider: CERT_STORE.PROV, dwEncodingType: ENCODING.TYPE, hCryptProv: HCRYPTPROV_LEGACY, dwFlags: CERT_STORE.FLAG, pvPara: ?*const anyopaque) callconv(.winapi) ?HCERTSTORE
pub extern "crypt32" fn CertCloseStore(hCertStore: HCERTSTORE, dwFlags: CERT_CLOSE_STORE_FLAG) callconv(.winapi) BOOL
pub extern "crypt32" fn CertEnumCertificatesInStore(hCertStore: HCERTSTORE, pPrevCertContext: ?*CERT_CONTEXT) callconv(.winapi) ?*CERT_CONTEXT
pub extern "crypt32" fn CertFreeCertificateContext(pCertContext: ?*const CERT_CONTEXT) callconv(.winapi) BOOL
pub extern "crypt32" fn CertAddEncodedCertificateToStore(hCertStore: ?HCERTSTORE, dwCertEncodingType: ENCODING.TYPE, pbCertEncoded: [*]const BYTE, cbCertEncoded: DWORD, dwAddDisposition: CERT_STORE.ADD, ppCertContext: ?*?*const CERT_CONTEXT) callconv(.winapi) BOOL
pub extern "crypt32" fn CertOpenSystemStoreW(hProv: HCRYPTPROV_LEGACY, szSubsystemProtocol: LPCWSTR) callconv(.winapi) ?HCERTSTORE
pub extern "crypt32" fn CertGetCertificateChain(hChainEngine: HCERTCHAINENGINE, pCertContext: *const CERT_CONTEXT, pTime: ?*const FILETIME, hAdditionalStore: ?HCERTSTORE, pChainPara: *const CERT_CHAIN.PARA, dwFlags: CERT_CHAIN, pvReserved: ?*const anyopaque, ppChainContext: **const CERT_CHAIN.CONTEXT) callconv(.winapi) BOOL
pub extern "crypt32" fn CertFreeCertificateChain(pChainContext: *const CERT_CHAIN.CONTEXT) callconv(.winapi) void
pub extern "crypt32" fn CertVerifyCertificateChainPolicy(pszPolicyOID: CERT_CHAIN.POLICY, pChainContext: *const CERT_CHAIN.CONTEXT, pPolicyPara: *const CERT_CHAIN.POLICY.PARA, pPolicyStatus: *CERT_CHAIN.POLICY.STATUS) callconv(.winapi) BOOL

File

os/windows/crypt32.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
const std = @import("../../std.zig");
const windows = std.os.windows;

const BOOL = windows.BOOL;
const DWORD = windows.DWORD;
const BYTE = windows.BYTE;
const LONG = windows.LONG;
const LPCSTR = windows.LPCSTR;
const LPCWSTR = windows.LPCWSTR;
const FILETIME = windows.FILETIME;
const HANDLE = windows.HANDLE;

// ref: um/wincrypt.h

pub const HCRYPTPROV_LEGACY = enum(usize) { NULL = 0 };

pub const CERT_INFO = *opaque {};

pub const CTL_USAGE = extern struct {
    cUsageIdentifier: DWORD,
    rgpszUsageIdentifier: [*]const LPCSTR,
};

pub const CERT_ENHKEY_USAGE = CTL_USAGE;

pub const ENCODING = enum(u16) {
    UNSPECIFIED = 0x0000,
    ASN = 0x0001,
    NDR = 0x0002,
    _,

    pub const TYPE = packed struct(DWORD) {
        CERT: ENCODING = .UNSPECIFIED,
        CMSG: ENCODING = .UNSPECIFIED,
    };
};

pub const HCERTSTORE = *opaque {};

pub const CERT_CONTEXT = extern struct {
    dwCertEncodingType: ENCODING.TYPE,
    pbCertEncoded: [*]BYTE,
    cbCertEncoded: DWORD,
    pCertInfo: CERT_INFO,
    hCertStore: HCERTSTORE,
};

pub const CERT_STORE = struct {
    pub const PROV = enum(usize) {
        MSG = 1,
        MEMORY = 2,
        FILE = 3,
        REG = 4,

        PKCS7 = 5,
        SERIALIZED = 6,
        FILENAME_A = 7,
        FILENAME_W = 8,
        SYSTEM_A = 9,
        SYSTEM_W = 10,

        COLLECTION = 11,
        SYSTEM_REGISTRY_A = 12,
        SYSTEM_REGISTRY_W = 13,
        PHYSICAL_W = 14,

        SMART_CARD_W = 15,

        LDAP_W = 16,
        PKCS12 = 17,

        /// LPCSTR
        _,

        pub fn fromString(str: LPCSTR) PROV {
            return @fromBackingInt(@intCast(@intFromPtr(str)));
        }
    };

    pub const FLAG = packed struct(DWORD) {
        NO_CRYPT_RELEASE: bool = false,
        SET_LOCALIZED_NAME: bool = false,
        DEFER_CLOSE_UNTIL_LAST_FREE: bool = false,
        Reserved3: u1 = 0,
        DELETE: bool = false,
        UNSAFE_PHYSICAL: bool = false,
        SHARE_STORE: bool = false,
        SHARE_CONTEXT: bool = false,
        MANIFOLD: bool = false,
        ENUM_ARCHIVED: bool = false,
        UPDATE_KEYID: bool = false,
        BACKUP_RESTORE: bool = false,
        MAXIMUM_ALLOWED: bool = false,
        CREATE_NEW: bool = false,
        OPEN_EXISTING: bool = false,
        READONLY: bool = false,
        Reserved16: u16 = 0,
    };

    pub const ADD = enum(DWORD) {
        NEW = 1,
        USE_EXISTING = 2,
        REPLACE_EXISTING = 3,
        ALWAYS = 4,
        REPLACE_EXISTING_INHERIT_PROPERTIES = 5,
        REWER = 6,
        NEWER_INHERIT_PROPERTIES = 7,
        _,
    };
};

pub extern "crypt32" fn CertOpenStore(
    lpszStoreProvider: CERT_STORE.PROV,
    dwEncodingType: ENCODING.TYPE,
    hCryptProv: HCRYPTPROV_LEGACY,
    dwFlags: CERT_STORE.FLAG,
    pvPara: ?*const anyopaque,
) callconv(.winapi) ?HCERTSTORE;

pub const CERT_CLOSE_STORE_FLAG = packed struct(DWORD) {
    FORCE: bool = false,
    CHECK: bool = false,
    Reserved2: u30 = 0,
};

pub extern "crypt32" fn CertCloseStore(
    hCertStore: HCERTSTORE,
    dwFlags: CERT_CLOSE_STORE_FLAG,
) callconv(.winapi) BOOL;

pub extern "crypt32" fn CertEnumCertificatesInStore(
    hCertStore: HCERTSTORE,
    pPrevCertContext: ?*CERT_CONTEXT,
) callconv(.winapi) ?*CERT_CONTEXT;

pub extern "crypt32" fn CertFreeCertificateContext(
    pCertContext: ?*const CERT_CONTEXT,
) callconv(.winapi) BOOL;

pub extern "crypt32" fn CertAddEncodedCertificateToStore(
    hCertStore: ?HCERTSTORE,
    dwCertEncodingType: ENCODING.TYPE,
    pbCertEncoded: [*]const BYTE,
    cbCertEncoded: DWORD,
    dwAddDisposition: CERT_STORE.ADD,
    ppCertContext: ?*?*const CERT_CONTEXT,
) callconv(.winapi) BOOL;

pub extern "crypt32" fn CertOpenSystemStoreW(
    hProv: HCRYPTPROV_LEGACY,
    szSubsystemProtocol: LPCWSTR,
) callconv(.winapi) ?HCERTSTORE;

pub const HCERTCHAINENGINE = enum(usize) {
    CURRENT_USER = 0x0,
    LOCAL_MACHINE = 0x1,
    SERIAL_LOCAL_MACHINE = 0x2,
    /// HANDLE
    _,

    pub fn fromHandle(handle: HANDLE) HCERTCHAINENGINE {
        return @fromBackingInt(@intCast(@intFromPtr(handle)));
    }
};

pub const CERT_CHAIN = packed struct(DWORD) {
    CACHE_END_CERT: bool = false,
    THREAD_STORE_SYNC: bool = false,
    CACHE_ONLY_URL_RETRIEVAL: bool = false,
    USE_LOCAL_MACHINE_STORE: bool = false,
    ENABLE_CACHE_AUTO_UPDATE: bool = false,
    ENABLE_SHARE_STORE: bool = false,
    Reserved6: u20 = 0,
    REVOCATION_CHECK_OCSP_CERT: bool = false,
    REVOCATION_ACCUMULATIVE_TIMEOUT: bool = false,
    REVOCATION_CHECK_END_CERT: bool = false,
    REVOCATION_CHECK_CHAIN: bool = false,
    REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT: bool = false,
    REVOCATION_CHECK_CACHE_ONLY: bool = false,

    pub const CONTEXT = opaque {};

    pub const USAGE_MATCH = extern struct {
        dwType: TYPE,
        Usage: CERT_ENHKEY_USAGE,

        pub const TYPE = enum(DWORD) { AND = 0x00000000, OR = 0x00000001, _ };
    };

    pub const PARA = extern struct {
        cbSize: DWORD = @sizeOf(PARA),
        RequestedUsage: USAGE_MATCH,
    };

    pub const POLICY = enum(usize) {
        BASE = 1,
        AUTHENTICODE = 2,
        AUTHENTICODE_TS = 3,
        SSL = 4,
        BASIC_CONSTRAINTS = 5,
        NT_AUTH = 6,
        MICROSOFT_ROOT = 7,
        EV = 8,
        SSL_F12 = 9,
        SSL_HPKP_HEADER = 10,
        THIRD_PARTY_ROOT = 11,
        SSL_KEY_PIN = 12,
        CT = 13,
        /// LPCSTR
        _,

        pub fn fromString(str: LPCSTR) POLICY {
            return @fromBackingInt(@intCast(@intFromPtr(str)));
        }

        pub const PARA = extern struct {
            cbSize: DWORD = @sizeOf(POLICY.PARA),
            dwFlags: FLAG,
            pvExtraPolicyPara: ?*anyopaque,
        };

        pub const STATUS = extern struct {
            cbSize: DWORD = @sizeOf(STATUS),
            dwError: windows.Win32Error,
            lChainIndex: LONG,
            lElementIndex: LONG,
            pvExtraPolicyStatus: ?*anyopaque,
        };

        pub const FLAG = packed struct(DWORD) {
            IGNORE_NOT_TIME_VALID: bool = false,
            IGNORE_CTL_NOT_TIME_VALID: bool = false,
            IGNORE_NOT_TIME_NESTED: bool = false,
            IGNORE_INVALID_BASIC_CONSTRAINTS: bool = false,
            ALLOW_UNKNOWN_CA: bool = false,
            IGNORE_WRONG_USAGE: bool = false,
            IGNORE_INVALID_NAME: bool = false,
            IGNORE_INVALID_POLICY: bool = false,
            IGNORE_END_REV_UNKNOWN: bool = false,
            IGNORE_CTL_SIGNER_REV_UNKNOWN: bool = false,
            IGNORE_CA_REV_UNKNOWN: bool = false,
            IGNORE_ROOT_REV_UNKNOWN: bool = false,
            IGNORE_PEER_TRUST: bool = false,
            IGNORE_NOT_SUPPORTED_CRITICAL_EXT: bool = false,
            TRUST_TESTROOT: bool = false,
            ALLOW_TESTROOT: bool = false,
            Reserved16: u11 = 0,
            IGNORE_WEAK_SIGNATURE: bool = false,
            Reserved28: u4 = 0,
        };
    };
};

pub const HTTPSPolicyCallbackData = extern struct {
    cbSize: DWORD = @sizeOf(HTTPSPolicyCallbackData),
    dwAuthType: AUTHTYPE,
    fdwChecks: DWORD = 0,
    pwszServerName: ?LPCWSTR = null,

    pub const AUTHTYPE = enum(DWORD) { CLIENT = 1, SERVER = 2, _ };
};

pub extern "crypt32" fn CertGetCertificateChain(
    hChainEngine: HCERTCHAINENGINE,
    pCertContext: *const CERT_CONTEXT,
    pTime: ?*const FILETIME,
    hAdditionalStore: ?HCERTSTORE,
    pChainPara: *const CERT_CHAIN.PARA,
    dwFlags: CERT_CHAIN,
    pvReserved: ?*const anyopaque,
    ppChainContext: **const CERT_CHAIN.CONTEXT,
) callconv(.winapi) BOOL;

pub extern "crypt32" fn CertFreeCertificateChain(
    pChainContext: *const CERT_CHAIN.CONTEXT,
) callconv(.winapi) void;

pub extern "crypt32" fn CertVerifyCertificateChainPolicy(
    pszPolicyOID: CERT_CHAIN.POLICY,
    pChainContext: *const CERT_CHAIN.CONTEXT,
    pPolicyPara: *const CERT_CHAIN.POLICY.PARA,
    pPolicyStatus: *CERT_CHAIN.POLICY.STATUS,
) callconv(.winapi) BOOL;