crypto/cms: Add support for CAdES Basic Electronic Signatures (CAdES-BES)
[openssl.git] / crypto / ess / ess_asn1.c
1 /*
2  * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (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 #include <openssl/err.h>
11 #include <openssl/asn1t.h>
12 #include <openssl/ess.h>
13 #include <openssl/x509v3.h>
14 #include "internal/ess_int.h"
15
16 /* ASN1 stuff for ESS Structure */
17
18 ASN1_SEQUENCE(ESS_ISSUER_SERIAL) = {
19         ASN1_SEQUENCE_OF(ESS_ISSUER_SERIAL, issuer, GENERAL_NAME),
20         ASN1_SIMPLE(ESS_ISSUER_SERIAL, serial, ASN1_INTEGER)
21 } static_ASN1_SEQUENCE_END(ESS_ISSUER_SERIAL)
22
23 IMPLEMENT_ASN1_FUNCTIONS_const(ESS_ISSUER_SERIAL)
24 IMPLEMENT_ASN1_DUP_FUNCTION(ESS_ISSUER_SERIAL)
25
26 ASN1_SEQUENCE(ESS_CERT_ID) = {
27         ASN1_SIMPLE(ESS_CERT_ID, hash, ASN1_OCTET_STRING),
28         ASN1_OPT(ESS_CERT_ID, issuer_serial, ESS_ISSUER_SERIAL)
29 } static_ASN1_SEQUENCE_END(ESS_CERT_ID)
30
31 IMPLEMENT_ASN1_FUNCTIONS_const(ESS_CERT_ID)
32 IMPLEMENT_ASN1_DUP_FUNCTION(ESS_CERT_ID)
33
34 ASN1_SEQUENCE(ESS_SIGNING_CERT) = {
35         ASN1_SEQUENCE_OF(ESS_SIGNING_CERT, cert_ids, ESS_CERT_ID),
36         ASN1_SEQUENCE_OF_OPT(ESS_SIGNING_CERT, policy_info, POLICYINFO)
37 } static_ASN1_SEQUENCE_END(ESS_SIGNING_CERT)
38
39 IMPLEMENT_ASN1_FUNCTIONS_const(ESS_SIGNING_CERT)
40 IMPLEMENT_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT)
41
42 ASN1_SEQUENCE(ESS_CERT_ID_V2) = {
43         ASN1_OPT(ESS_CERT_ID_V2, hash_alg, X509_ALGOR),
44         ASN1_SIMPLE(ESS_CERT_ID_V2, hash, ASN1_OCTET_STRING),
45         ASN1_OPT(ESS_CERT_ID_V2, issuer_serial, ESS_ISSUER_SERIAL)
46 } static_ASN1_SEQUENCE_END(ESS_CERT_ID_V2)
47
48 IMPLEMENT_ASN1_FUNCTIONS_const(ESS_CERT_ID_V2)
49 IMPLEMENT_ASN1_DUP_FUNCTION(ESS_CERT_ID_V2)
50
51 ASN1_SEQUENCE(ESS_SIGNING_CERT_V2) = {
52         ASN1_SEQUENCE_OF(ESS_SIGNING_CERT_V2, cert_ids, ESS_CERT_ID_V2),
53         ASN1_SEQUENCE_OF_OPT(ESS_SIGNING_CERT_V2, policy_info, POLICYINFO)
54 } static_ASN1_SEQUENCE_END(ESS_SIGNING_CERT_V2)
55
56 IMPLEMENT_ASN1_FUNCTIONS_const(ESS_SIGNING_CERT_V2)
57 IMPLEMENT_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT_V2)