source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/cms/cms_lcl.h

Last change on this file was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 13.4 KB
Line 
1/*
2 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef HEADER_CMS_LCL_H
11# define HEADER_CMS_LCL_H
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17# include <openssl/x509.h>
18
19/*
20 * Cryptographic message syntax (CMS) structures: taken from RFC3852
21 */
22
23/* Forward references */
24
25typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber;
26typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo;
27typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier;
28typedef struct CMS_SignedData_st CMS_SignedData;
29typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat;
30typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo;
31typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo;
32typedef struct CMS_EnvelopedData_st CMS_EnvelopedData;
33typedef struct CMS_DigestedData_st CMS_DigestedData;
34typedef struct CMS_EncryptedData_st CMS_EncryptedData;
35typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData;
36typedef struct CMS_CompressedData_st CMS_CompressedData;
37typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat;
38typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo;
39typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey;
40typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey;
41typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo;
42typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier;
43typedef struct CMS_KeyAgreeRecipientIdentifier_st
44 CMS_KeyAgreeRecipientIdentifier;
45typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier;
46typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo;
47typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo;
48typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo;
49typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
50
51struct CMS_ContentInfo_st {
52 ASN1_OBJECT *contentType;
53 union {
54 ASN1_OCTET_STRING *data;
55 CMS_SignedData *signedData;
56 CMS_EnvelopedData *envelopedData;
57 CMS_DigestedData *digestedData;
58 CMS_EncryptedData *encryptedData;
59 CMS_AuthenticatedData *authenticatedData;
60 CMS_CompressedData *compressedData;
61 ASN1_TYPE *other;
62 /* Other types ... */
63 void *otherData;
64 } d;
65};
66
67DEFINE_STACK_OF(CMS_CertificateChoices)
68
69struct CMS_SignedData_st {
70 long version;
71 STACK_OF(X509_ALGOR) *digestAlgorithms;
72 CMS_EncapsulatedContentInfo *encapContentInfo;
73 STACK_OF(CMS_CertificateChoices) *certificates;
74 STACK_OF(CMS_RevocationInfoChoice) *crls;
75 STACK_OF(CMS_SignerInfo) *signerInfos;
76};
77
78struct CMS_EncapsulatedContentInfo_st {
79 ASN1_OBJECT *eContentType;
80 ASN1_OCTET_STRING *eContent;
81 /* Set to 1 if incomplete structure only part set up */
82 int partial;
83};
84
85struct CMS_SignerInfo_st {
86 long version;
87 CMS_SignerIdentifier *sid;
88 X509_ALGOR *digestAlgorithm;
89 STACK_OF(X509_ATTRIBUTE) *signedAttrs;
90 X509_ALGOR *signatureAlgorithm;
91 ASN1_OCTET_STRING *signature;
92 STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
93 /* Signing certificate and key */
94 X509 *signer;
95 EVP_PKEY *pkey;
96 /* Digest and public key context for alternative parameters */
97 EVP_MD_CTX *mctx;
98 EVP_PKEY_CTX *pctx;
99};
100
101struct CMS_SignerIdentifier_st {
102 int type;
103 union {
104 CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
105 ASN1_OCTET_STRING *subjectKeyIdentifier;
106 } d;
107};
108
109struct CMS_EnvelopedData_st {
110 long version;
111 CMS_OriginatorInfo *originatorInfo;
112 STACK_OF(CMS_RecipientInfo) *recipientInfos;
113 CMS_EncryptedContentInfo *encryptedContentInfo;
114 STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
115};
116
117struct CMS_OriginatorInfo_st {
118 STACK_OF(CMS_CertificateChoices) *certificates;
119 STACK_OF(CMS_RevocationInfoChoice) *crls;
120};
121
122struct CMS_EncryptedContentInfo_st {
123 ASN1_OBJECT *contentType;
124 X509_ALGOR *contentEncryptionAlgorithm;
125 ASN1_OCTET_STRING *encryptedContent;
126 /* Content encryption algorithm and key */
127 const EVP_CIPHER *cipher;
128 unsigned char *key;
129 size_t keylen;
130 /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
131 int debug;
132};
133
134struct CMS_RecipientInfo_st {
135 int type;
136 union {
137 CMS_KeyTransRecipientInfo *ktri;
138 CMS_KeyAgreeRecipientInfo *kari;
139 CMS_KEKRecipientInfo *kekri;
140 CMS_PasswordRecipientInfo *pwri;
141 CMS_OtherRecipientInfo *ori;
142 } d;
143};
144
145typedef CMS_SignerIdentifier CMS_RecipientIdentifier;
146
147struct CMS_KeyTransRecipientInfo_st {
148 long version;
149 CMS_RecipientIdentifier *rid;
150 X509_ALGOR *keyEncryptionAlgorithm;
151 ASN1_OCTET_STRING *encryptedKey;
152 /* Recipient Key and cert */
153 X509 *recip;
154 EVP_PKEY *pkey;
155 /* Public key context for this operation */
156 EVP_PKEY_CTX *pctx;
157};
158
159struct CMS_KeyAgreeRecipientInfo_st {
160 long version;
161 CMS_OriginatorIdentifierOrKey *originator;
162 ASN1_OCTET_STRING *ukm;
163 X509_ALGOR *keyEncryptionAlgorithm;
164 STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
165 /* Public key context associated with current operation */
166 EVP_PKEY_CTX *pctx;
167 /* Cipher context for CEK wrapping */
168 EVP_CIPHER_CTX *ctx;
169};
170
171struct CMS_OriginatorIdentifierOrKey_st {
172 int type;
173 union {
174 CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
175 ASN1_OCTET_STRING *subjectKeyIdentifier;
176 CMS_OriginatorPublicKey *originatorKey;
177 } d;
178};
179
180struct CMS_OriginatorPublicKey_st {
181 X509_ALGOR *algorithm;
182 ASN1_BIT_STRING *publicKey;
183};
184
185struct CMS_RecipientEncryptedKey_st {
186 CMS_KeyAgreeRecipientIdentifier *rid;
187 ASN1_OCTET_STRING *encryptedKey;
188 /* Public key associated with this recipient */
189 EVP_PKEY *pkey;
190};
191
192struct CMS_KeyAgreeRecipientIdentifier_st {
193 int type;
194 union {
195 CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
196 CMS_RecipientKeyIdentifier *rKeyId;
197 } d;
198};
199
200struct CMS_RecipientKeyIdentifier_st {
201 ASN1_OCTET_STRING *subjectKeyIdentifier;
202 ASN1_GENERALIZEDTIME *date;
203 CMS_OtherKeyAttribute *other;
204};
205
206struct CMS_KEKRecipientInfo_st {
207 long version;
208 CMS_KEKIdentifier *kekid;
209 X509_ALGOR *keyEncryptionAlgorithm;
210 ASN1_OCTET_STRING *encryptedKey;
211 /* Extra info: symmetric key to use */
212 unsigned char *key;
213 size_t keylen;
214};
215
216struct CMS_KEKIdentifier_st {
217 ASN1_OCTET_STRING *keyIdentifier;
218 ASN1_GENERALIZEDTIME *date;
219 CMS_OtherKeyAttribute *other;
220};
221
222struct CMS_PasswordRecipientInfo_st {
223 long version;
224 X509_ALGOR *keyDerivationAlgorithm;
225 X509_ALGOR *keyEncryptionAlgorithm;
226 ASN1_OCTET_STRING *encryptedKey;
227 /* Extra info: password to use */
228 unsigned char *pass;
229 size_t passlen;
230};
231
232struct CMS_OtherRecipientInfo_st {
233 ASN1_OBJECT *oriType;
234 ASN1_TYPE *oriValue;
235};
236
237struct CMS_DigestedData_st {
238 long version;
239 X509_ALGOR *digestAlgorithm;
240 CMS_EncapsulatedContentInfo *encapContentInfo;
241 ASN1_OCTET_STRING *digest;
242};
243
244struct CMS_EncryptedData_st {
245 long version;
246 CMS_EncryptedContentInfo *encryptedContentInfo;
247 STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
248};
249
250struct CMS_AuthenticatedData_st {
251 long version;
252 CMS_OriginatorInfo *originatorInfo;
253 STACK_OF(CMS_RecipientInfo) *recipientInfos;
254 X509_ALGOR *macAlgorithm;
255 X509_ALGOR *digestAlgorithm;
256 CMS_EncapsulatedContentInfo *encapContentInfo;
257 STACK_OF(X509_ATTRIBUTE) *authAttrs;
258 ASN1_OCTET_STRING *mac;
259 STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
260};
261
262struct CMS_CompressedData_st {
263 long version;
264 X509_ALGOR *compressionAlgorithm;
265 STACK_OF(CMS_RecipientInfo) *recipientInfos;
266 CMS_EncapsulatedContentInfo *encapContentInfo;
267};
268
269struct CMS_RevocationInfoChoice_st {
270 int type;
271 union {
272 X509_CRL *crl;
273 CMS_OtherRevocationInfoFormat *other;
274 } d;
275};
276
277# define CMS_REVCHOICE_CRL 0
278# define CMS_REVCHOICE_OTHER 1
279
280struct CMS_OtherRevocationInfoFormat_st {
281 ASN1_OBJECT *otherRevInfoFormat;
282 ASN1_TYPE *otherRevInfo;
283};
284
285struct CMS_CertificateChoices {
286 int type;
287 union {
288 X509 *certificate;
289 ASN1_STRING *extendedCertificate; /* Obsolete */
290 ASN1_STRING *v1AttrCert; /* Left encoded for now */
291 ASN1_STRING *v2AttrCert; /* Left encoded for now */
292 CMS_OtherCertificateFormat *other;
293 } d;
294};
295
296# define CMS_CERTCHOICE_CERT 0
297# define CMS_CERTCHOICE_EXCERT 1
298# define CMS_CERTCHOICE_V1ACERT 2
299# define CMS_CERTCHOICE_V2ACERT 3
300# define CMS_CERTCHOICE_OTHER 4
301
302struct CMS_OtherCertificateFormat_st {
303 ASN1_OBJECT *otherCertFormat;
304 ASN1_TYPE *otherCert;
305};
306
307/*
308 * This is also defined in pkcs7.h but we duplicate it to allow the CMS code
309 * to be independent of PKCS#7
310 */
311
312struct CMS_IssuerAndSerialNumber_st {
313 X509_NAME *issuer;
314 ASN1_INTEGER *serialNumber;
315};
316
317struct CMS_OtherKeyAttribute_st {
318 ASN1_OBJECT *keyAttrId;
319 ASN1_TYPE *keyAttr;
320};
321
322/* ESS structures */
323
324# ifdef HEADER_X509V3_H
325
326struct CMS_ReceiptRequest_st {
327 ASN1_OCTET_STRING *signedContentIdentifier;
328 CMS_ReceiptsFrom *receiptsFrom;
329 STACK_OF(GENERAL_NAMES) *receiptsTo;
330};
331
332struct CMS_ReceiptsFrom_st {
333 int type;
334 union {
335 long allOrFirstTier;
336 STACK_OF(GENERAL_NAMES) *receiptList;
337 } d;
338};
339# endif
340
341struct CMS_Receipt_st {
342 long version;
343 ASN1_OBJECT *contentType;
344 ASN1_OCTET_STRING *signedContentIdentifier;
345 ASN1_OCTET_STRING *originatorSignatureValue;
346};
347
348DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
349DECLARE_ASN1_ITEM(CMS_SignerInfo)
350DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
351DECLARE_ASN1_ITEM(CMS_Attributes_Sign)
352DECLARE_ASN1_ITEM(CMS_Attributes_Verify)
353DECLARE_ASN1_ITEM(CMS_RecipientInfo)
354DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
355DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)
356
357# define CMS_SIGNERINFO_ISSUER_SERIAL 0
358# define CMS_SIGNERINFO_KEYIDENTIFIER 1
359
360# define CMS_RECIPINFO_ISSUER_SERIAL 0
361# define CMS_RECIPINFO_KEYIDENTIFIER 1
362
363# define CMS_REK_ISSUER_SERIAL 0
364# define CMS_REK_KEYIDENTIFIER 1
365
366# define CMS_OIK_ISSUER_SERIAL 0
367# define CMS_OIK_KEYIDENTIFIER 1
368# define CMS_OIK_PUBKEY 2
369
370BIO *cms_content_bio(CMS_ContentInfo *cms);
371
372CMS_ContentInfo *cms_Data_create(void);
373
374CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md);
375BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms);
376int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify);
377
378BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms);
379int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
380int cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert,
381 int type);
382int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
383 ASN1_OCTET_STRING **keyid,
384 X509_NAME **issuer,
385 ASN1_INTEGER **sno);
386int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
387
388CMS_ContentInfo *cms_CompressedData_create(int comp_nid);
389BIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms);
390
391BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
392int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
393 X509_ALGOR *mdalg);
394
395int cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert);
396int cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert);
397int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert);
398int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert);
399
400BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec);
401BIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms);
402int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
403 const EVP_CIPHER *cipher,
404 const unsigned char *key, size_t keylen);
405
406int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
407int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
408ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si);
409
410BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms);
411CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms);
412int cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd);
413int cms_pkey_get_ri_type(EVP_PKEY *pk);
414/* KARI routines */
415int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip,
416 EVP_PKEY *pk, unsigned int flags);
417int cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms,
418 CMS_RecipientInfo *ri);
419
420/* PWRI routines */
421int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
422 int en_de);
423
424DECLARE_ASN1_ITEM(CMS_CertificateChoices)
425DECLARE_ASN1_ITEM(CMS_DigestedData)
426DECLARE_ASN1_ITEM(CMS_EncryptedData)
427DECLARE_ASN1_ITEM(CMS_EnvelopedData)
428DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo)
429DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo)
430DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo)
431DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey)
432DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute)
433DECLARE_ASN1_ITEM(CMS_Receipt)
434DECLARE_ASN1_ITEM(CMS_ReceiptRequest)
435DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey)
436DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier)
437DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice)
438DECLARE_ASN1_ITEM(CMS_SignedData)
439DECLARE_ASN1_ITEM(CMS_CompressedData)
440
441#ifdef __cplusplus
442}
443#endif
444#endif
Note: See TracBrowser for help on using the repository browser.