Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/crmf/crmf_local.h

raw
1 /*-
2 * Copyright 2007-2025 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Nokia 2007-2019
4 * Copyright Siemens AG 2015-2019
5 *
6 * Licensed under the Apache License 2.0 (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
10 *
11 * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb.
12 */
13
14 #ifndef OSSL_CRYPTO_CRMF_LOCAL_H
15 #define OSSL_CRYPTO_CRMF_LOCAL_H
16
17 #include "internal/crmf.h"
18
19 /*-
20 * EncryptedValue ::= SEQUENCE {
21 * intendedAlg [0] AlgorithmIdentifier OPTIONAL,
22 * -- the intended algorithm for which the value will be used
23 * symmAlg [1] AlgorithmIdentifier OPTIONAL,
24 * -- the symmetric algorithm used to encrypt the value
25 * encSymmKey [2] BIT STRING OPTIONAL,
26 * -- the (encrypted) symmetric key used to encrypt the value
27 * keyAlg [3] AlgorithmIdentifier OPTIONAL,
28 * -- algorithm used to encrypt the symmetric key
29 * valueHint [4] OCTET STRING OPTIONAL,
30 * -- a brief description or identifier of the encValue content
31 * -- (may be meaningful only to the sending entity, and
32 * -- used only if EncryptedValue might be re-examined
33 * -- by the sending entity in the future)
34 * encValue BIT STRING
35 * -- the encrypted value itself
36 * }
37 */
38 struct ossl_crmf_encryptedvalue_st {
39 X509_ALGOR *intendedAlg; /* 0 */
40 X509_ALGOR *symmAlg; /* 1 */
41 ASN1_BIT_STRING *encSymmKey; /* 2 */
42 X509_ALGOR *keyAlg; /* 3 */
43 ASN1_OCTET_STRING *valueHint; /* 4 */
44 ASN1_BIT_STRING *encValue;
45 } /* OSSL_CRMF_ENCRYPTEDVALUE */;
46
47 /*
48 * EncryptedKey ::= CHOICE {
49 * encryptedValue EncryptedValue, -- Deprecated
50 * envelopedData [0] EnvelopedData }
51 * -- The encrypted private key MUST be placed in the envelopedData
52 * -- encryptedContentInfo encryptedContent OCTET STRING.
53 */
54 #define OSSL_CRMF_ENCRYPTEDKEY_ENVELOPEDDATA 1
55
56 struct ossl_crmf_encryptedkey_st {
57 int type;
58 union {
59 OSSL_CRMF_ENCRYPTEDVALUE *encryptedValue; /* 0 */ /* Deprecated */
60 #ifndef OPENSSL_NO_CMS
61 CMS_EnvelopedData *envelopedData; /* 1 */
62 #endif
63 } value;
64 } /* OSSL_CRMF_ENCRYPTEDKEY */;
65
66 /*-
67 * Attributes ::= SET OF Attribute
68 * => X509_ATTRIBUTE
69 *
70 * PrivateKeyInfo ::= SEQUENCE {
71 * version INTEGER,
72 * privateKeyAlgorithm AlgorithmIdentifier,
73 * privateKey OCTET STRING,
74 * attributes [0] IMPLICIT Attributes OPTIONAL
75 * }
76 */
77 typedef struct ossl_crmf_privatekeyinfo_st {
78 ASN1_INTEGER *version;
79 X509_ALGOR *privateKeyAlgorithm;
80 ASN1_OCTET_STRING *privateKey;
81 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
82 } OSSL_CRMF_PRIVATEKEYINFO;
83 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PRIVATEKEYINFO)
84
85 /*-
86 * section 4.2.1 Private Key Info Content Type
87 * id-ct-encKeyWithID OBJECT IDENTIFIER ::= {id-ct 21}
88 *
89 * EncKeyWithID ::= SEQUENCE {
90 * privateKey PrivateKeyInfo,
91 * identifier CHOICE {
92 * string UTF8String,
93 * generalName GeneralName
94 * } OPTIONAL
95 * }
96 */
97 typedef struct ossl_crmf_enckeywithid_identifier_st {
98 int type;
99 union {
100 ASN1_UTF8STRING *string;
101 GENERAL_NAME *generalName;
102 } value;
103 } OSSL_CRMF_ENCKEYWITHID_IDENTIFIER;
104 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER)
105
106 typedef struct ossl_crmf_enckeywithid_st {
107 OSSL_CRMF_PRIVATEKEYINFO *privateKey;
108 /* [0] */
109 OSSL_CRMF_ENCKEYWITHID_IDENTIFIER *identifier;
110 } OSSL_CRMF_ENCKEYWITHID;
111 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID)
112
113 /*-
114 * CertId ::= SEQUENCE {
115 * issuer GeneralName,
116 * serialNumber INTEGER
117 * }
118 */
119 struct ossl_crmf_certid_st {
120 GENERAL_NAME *issuer;
121 ASN1_INTEGER *serialNumber;
122 } /* OSSL_CRMF_CERTID */;
123
124 /*-
125 * SinglePubInfo ::= SEQUENCE {
126 * pubMethod INTEGER {
127 * dontCare (0),
128 * x500 (1),
129 * web (2),
130 * ldap (3) },
131 * pubLocation GeneralName OPTIONAL
132 * }
133 */
134 struct ossl_crmf_singlepubinfo_st {
135 ASN1_INTEGER *pubMethod;
136 GENERAL_NAME *pubLocation;
137 } /* OSSL_CRMF_SINGLEPUBINFO */;
138 DEFINE_STACK_OF(OSSL_CRMF_SINGLEPUBINFO)
139 typedef STACK_OF(OSSL_CRMF_SINGLEPUBINFO) OSSL_CRMF_PUBINFOS;
140
141 /*-
142 * PKIPublicationInfo ::= SEQUENCE {
143 * action INTEGER {
144 * dontPublish (0),
145 * pleasePublish (1) },
146 * pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL
147 * -- pubInfos MUST NOT be present if action is "dontPublish"
148 * -- (if action is "pleasePublish" and pubInfos is omitted,
149 * -- "dontCare" is assumed)
150 * }
151 */
152 struct ossl_crmf_pkipublicationinfo_st {
153 ASN1_INTEGER *action;
154 OSSL_CRMF_PUBINFOS *pubInfos;
155 } /* OSSL_CRMF_PKIPUBLICATIONINFO */;
156 DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_PKIPUBLICATIONINFO)
157
158 /*-
159 * PKMACValue ::= SEQUENCE {
160 * algId AlgorithmIdentifier,
161 * -- algorithm value shall be PasswordBasedMac {1 2 840 113533 7 66 13}
162 * -- parameter value is PBMParameter
163 * value BIT STRING
164 * }
165 */
166 typedef struct ossl_crmf_pkmacvalue_st {
167 X509_ALGOR *algId;
168 ASN1_BIT_STRING *value;
169 } OSSL_CRMF_PKMACVALUE;
170 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKMACVALUE)
171
172 /*-
173 * SubsequentMessage ::= INTEGER {
174 * encrCert (0),
175 * -- requests that resulting certificate be encrypted for the
176 * -- end entity (following which, POP will be proven in a
177 * -- confirmation message)
178 * challengeResp (1)
179 * -- requests that CA engage in challenge-response exchange with
180 * -- end entity in order to prove private key possession
181 * }
182 *
183 * POPOPrivKey ::= CHOICE {
184 * thisMessage [0] BIT STRING, -- Deprecated
185 * -- possession is proven in this message (which contains the private
186 * -- key itself (encrypted for the CA))
187 * subsequentMessage [1] SubsequentMessage,
188 * -- possession will be proven in a subsequent message
189 * dhMAC [2] BIT STRING, -- Deprecated
190 * agreeMAC [3] PKMACValue,
191 * encryptedKey [4] EnvelopedData
192 * }
193 */
194
195 typedef struct ossl_crmf_popoprivkey_st {
196 int type;
197 union {
198 ASN1_BIT_STRING *thisMessage; /* 0 */ /* Deprecated */
199 ASN1_INTEGER *subsequentMessage; /* 1 */
200 ASN1_BIT_STRING *dhMAC; /* 2 */ /* Deprecated */
201 OSSL_CRMF_PKMACVALUE *agreeMAC; /* 3 */
202 ASN1_NULL *encryptedKey; /* 4 */
203 /* When supported, ASN1_NULL needs to be replaced by CMS_ENVELOPEDDATA */
204 } value;
205 } OSSL_CRMF_POPOPRIVKEY;
206 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOPRIVKEY)
207
208 /*-
209 * PBMParameter ::= SEQUENCE {
210 * salt OCTET STRING,
211 * owf AlgorithmIdentifier,
212 * -- AlgId for a One-Way Function (SHA-1 recommended)
213 * iterationCount INTEGER,
214 * -- number of times the OWF is applied
215 * mac AlgorithmIdentifier
216 * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
217 * -- or HMAC [HMAC, RFC2202])
218 * }
219 */
220 struct ossl_crmf_pbmparameter_st {
221 ASN1_OCTET_STRING *salt;
222 X509_ALGOR *owf;
223 ASN1_INTEGER *iterationCount;
224 X509_ALGOR *mac;
225 } /* OSSL_CRMF_PBMPARAMETER */;
226 #define OSSL_CRMF_PBM_MAX_ITERATION_COUNT 100000 /* if too large allows DoS */
227
228 /*-
229 * POPOSigningKeyInput ::= SEQUENCE {
230 * authInfo CHOICE {
231 * sender [0] GeneralName,
232 * -- used only if an authenticated identity has been
233 * -- established for the sender (e.g., a DN from a
234 * -- previously-issued and currently-valid certificate)
235 * publicKeyMAC PKMACValue },
236 * -- used if no authenticated GeneralName currently exists for
237 * -- the sender; publicKeyMAC contains a password-based MAC
238 * -- on the DER-encoded value of publicKey
239 * publicKey SubjectPublicKeyInfo -- from CertTemplate
240 * }
241 */
242 typedef struct ossl_crmf_poposigningkeyinput_authinfo_st {
243 int type;
244 union {
245 /* 0 */ GENERAL_NAME *sender;
246 /* 1 */ OSSL_CRMF_PKMACVALUE *publicKeyMAC;
247 } value;
248 } OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO;
249 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO)
250
251 typedef struct ossl_crmf_poposigningkeyinput_st {
252 OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO *authInfo;
253 X509_PUBKEY *publicKey;
254 } OSSL_CRMF_POPOSIGNINGKEYINPUT;
255 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT)
256
257 /*-
258 * POPOSigningKey ::= SEQUENCE {
259 * poposkInput [0] POPOSigningKeyInput OPTIONAL,
260 * algorithmIdentifier AlgorithmIdentifier,
261 * signature BIT STRING
262 * }
263 */
264 struct ossl_crmf_poposigningkey_st {
265 OSSL_CRMF_POPOSIGNINGKEYINPUT *poposkInput;
266 X509_ALGOR *algorithmIdentifier;
267 ASN1_BIT_STRING *signature;
268 } /* OSSL_CRMF_POPOSIGNINGKEY */;
269 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEY)
270
271 /*-
272 * ProofOfPossession ::= CHOICE {
273 * raVerified [0] NULL,
274 * -- used if the RA has already verified that the requester is in
275 * -- possession of the private key
276 * signature [1] POPOSigningKey,
277 * keyEncipherment [2] POPOPrivKey,
278 * keyAgreement [3] POPOPrivKey
279 * }
280 */
281 typedef struct ossl_crmf_popo_st {
282 int type;
283 union {
284 ASN1_NULL *raVerified; /* 0 */
285 OSSL_CRMF_POPOSIGNINGKEY *signature; /* 1 */
286 OSSL_CRMF_POPOPRIVKEY *keyEncipherment; /* 2 */
287 OSSL_CRMF_POPOPRIVKEY *keyAgreement; /* 3 */
288 } value;
289 } OSSL_CRMF_POPO;
290 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
291
292 /*-
293 * OptionalValidity ::= SEQUENCE {
294 * notBefore [0] Time OPTIONAL,
295 * notAfter [1] Time OPTIONAL -- at least one MUST be present
296 * }
297 */
298 struct ossl_crmf_optionalvalidity_st {
299 /* 0 */ ASN1_TIME *notBefore;
300 /* 1 */ ASN1_TIME *notAfter;
301 } /* OSSL_CRMF_OPTIONALVALIDITY */;
302 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_OPTIONALVALIDITY)
303
304 /*-
305 * CertTemplate ::= SEQUENCE {
306 * version [0] Version OPTIONAL,
307 * serialNumber [1] INTEGER OPTIONAL,
308 * signingAlg [2] AlgorithmIdentifier OPTIONAL,
309 * issuer [3] Name OPTIONAL,
310 * validity [4] OptionalValidity OPTIONAL,
311 * subject [5] Name OPTIONAL,
312 * publicKey [6] SubjectPublicKeyInfo OPTIONAL,
313 * issuerUID [7] UniqueIdentifier OPTIONAL,
314 * subjectUID [8] UniqueIdentifier OPTIONAL,
315 * extensions [9] Extensions OPTIONAL
316 * }
317 */
318 struct ossl_crmf_certtemplate_st {
319 ASN1_INTEGER *version;
320 ASN1_INTEGER *serialNumber; /* serialNumber MUST be omitted */
321 /* This field is assigned by the CA during certificate creation */
322 X509_ALGOR *signingAlg; /* signingAlg MUST be omitted */
323 /* This field is assigned by the CA during certificate creation */
324 const X509_NAME *issuer;
325 OSSL_CRMF_OPTIONALVALIDITY *validity;
326 const X509_NAME *subject;
327 X509_PUBKEY *publicKey;
328 ASN1_BIT_STRING *issuerUID; /* deprecated in version 2 */
329 /* According to rfc 3280: UniqueIdentifier ::= BIT STRING */
330 ASN1_BIT_STRING *subjectUID; /* deprecated in version 2 */
331 /* Could be X509_EXTENSION*S*, but that's only cosmetic */
332 STACK_OF(X509_EXTENSION) *extensions;
333 } /* OSSL_CRMF_CERTTEMPLATE */;
334
335 /*-
336 * CertRequest ::= SEQUENCE {
337 * certReqId INTEGER, -- ID for matching request and reply
338 * certTemplate CertTemplate, -- Selected fields of cert to be issued
339 * controls Controls OPTIONAL -- Attributes affecting issuance
340 * }
341 */
342 struct ossl_crmf_certrequest_st {
343 ASN1_INTEGER *certReqId;
344 OSSL_CRMF_CERTTEMPLATE *certTemplate;
345 STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE /* Controls expanded */) *controls;
346 } /* OSSL_CRMF_CERTREQUEST */;
347 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST)
348 DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST)
349
350 /*-
351 * CertReqMessages ::= SEQUENCE SIZE (1..MAX) OF CertReqMsg
352 * CertReqMsg ::= SEQUENCE {
353 * certReq CertRequest,
354 * popo ProofOfPossession OPTIONAL,
355 * -- content depends upon key type
356 * regInfo SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue OPTIONAL
357 * }
358 */
359 struct ossl_crmf_msg_st {
360 OSSL_CRMF_CERTREQUEST *certReq;
361 /* 0 */
362 OSSL_CRMF_POPO *popo;
363 /* 1 */
364 STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *regInfo;
365 } /* OSSL_CRMF_MSG */;
366 #endif