20#ifndef LC_PKCS7_COMMON_H
21#define LC_PKCS7_COMMON_H
30struct lc_pkcs7_trust_store {
31 struct lc_x509_certificate *anchor_cert;
34struct lc_pkcs7_signed_info {
35 struct lc_pkcs7_signed_info *next;
46 struct lc_public_key_signature sig;
52 struct lc_x509_certificate *signer;
53 time64_t signing_time;
56 const uint8_t *msgdigest;
60 const uint8_t *authattrs;
64#define sinfo_has_content_type (1 << 0)
65#define sinfo_has_signing_time (1 << 1)
66#define sinfo_has_message_digest (1 << 2)
67#define sinfo_has_smime_caps (1 << 3)
68#define sinfo_has_ms_opus_info (1 << 4)
69#define sinfo_has_ms_statement_type (1 << 5)
74 unsupported_crypto : 1;
75 unsigned int blacklisted : 1;
78struct lc_pkcs7_message {
84 struct lc_x509_certificate *certs;
85 struct lc_x509_certificate *crl;
90 struct lc_pkcs7_signed_info *curr_sinfo;
91 struct lc_pkcs7_signed_info *list_head_sinfo;
92 struct lc_pkcs7_signed_info **list_tail_sinfo;
93 uint8_t avail_preallocated_sinfo;
94 uint8_t consumed_preallocated_sinfo;
95 struct lc_pkcs7_signed_info *preallocated_sinfo;
104 uint8_t avail_preallocated_x509;
105 uint8_t consumed_preallocated_x509;
106 struct lc_x509_certificate *preallocated_x509;
108 unsigned int have_authattrs : 1;
109 unsigned int embed_data : 1;
123#define LC_PKCS7_MSG_SIZE(num_sinfo, num_x509) \
124 sizeof(struct lc_pkcs7_message) + \
125 num_sinfo * sizeof(struct lc_pkcs7_signed_info) + \
126 num_x509 * sizeof(struct lc_x509_certificate)
151#define LC_PKCS7_MSG_ON_STACK(name, num_sinfo, num_x509) \
152 _Pragma("GCC diagnostic push") _Pragma( \
153 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
154 _Pragma("GCC diagnostic ignored \"-Wcast-align\"") \
157 LC_PKCS7_MSG_SIZE(num_sinfo, num_x509), 8); \
158 struct lc_pkcs7_message *name = \
159 (struct lc_pkcs7_message *)name##_ctx_buf; \
160 (name)->avail_preallocated_sinfo = num_sinfo; \
161 (name)->preallocated_sinfo = \
162 (struct lc_pkcs7_signed_info \
163 *)((uint8_t *)(name) + \
164 sizeof(struct lc_pkcs7_message)); \
165 (name)->avail_preallocated_x509 = num_x509; \
166 (name)->preallocated_x509 = \
167 (struct lc_x509_certificate \
168 *)((uint8_t *)(name) + \
169 sizeof(struct lc_pkcs7_message) + \
170 num_sinfo * sizeof(struct lc_pkcs7_signed_info)); \
171 _Pragma("GCC diagnostic pop")