blob: e17f7ce4fb434832a3867ce2254de6ccc7f06ae7 [file] [log] [blame]
Thomas Gleixnerb4d0d232019-05-20 19:08:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
David Howells2e3fadb2014-07-01 16:40:19 +01002/* PKCS#7 crypto data parser internal definitions
3 *
4 * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
David Howells2e3fadb2014-07-01 16:40:19 +01006 */
7
8#include <linux/oid_registry.h>
9#include <crypto/pkcs7.h>
10#include "x509_parser.h"
11
12#define kenter(FMT, ...) \
13 pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__)
14#define kleave(FMT, ...) \
15 pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
16
17struct pkcs7_signed_info {
18 struct pkcs7_signed_info *next;
19 struct x509_certificate *signer; /* Signing certificate (in msg->certs) */
David Howells99db4432015-08-05 15:22:27 +010020 unsigned index;
David Howells99db4432015-08-05 15:22:27 +010021 bool unsupported_crypto; /* T if not usable due to missing crypto */
David Howells03bb7932017-04-03 16:07:25 +010022 bool blacklisted;
David Howells2e3fadb2014-07-01 16:40:19 +010023
24 /* Message digest - the digest of the Content Data (or NULL) */
25 const void *msgdigest;
26 unsigned msgdigest_len;
27
28 /* Authenticated Attribute data (or NULL) */
29 unsigned authattrs_len;
30 const void *authattrs;
David Howells99db4432015-08-05 15:22:27 +010031 unsigned long aa_set;
32#define sinfo_has_content_type 0
33#define sinfo_has_signing_time 1
34#define sinfo_has_message_digest 2
35#define sinfo_has_smime_caps 3
36#define sinfo_has_ms_opus_info 4
37#define sinfo_has_ms_statement_type 5
38 time64_t signing_time;
David Howells2e3fadb2014-07-01 16:40:19 +010039
David Howells2e3fadb2014-07-01 16:40:19 +010040 /* Message signature.
41 *
42 * This contains the generated digest of _either_ the Content Data or
43 * the Authenticated Attributes [RFC2315 9.3]. If the latter, one of
Randy Dunlap1539dd72020-07-19 11:07:34 -070044 * the attributes contains the digest of the Content Data within it.
David Howells566a1172016-04-06 16:13:33 +010045 *
Randy Dunlap1539dd72020-07-19 11:07:34 -070046 * This also contains the issuing cert serial number and issuer's name
David Howells566a1172016-04-06 16:13:33 +010047 * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3].
David Howells2e3fadb2014-07-01 16:40:19 +010048 */
David Howells566a1172016-04-06 16:13:33 +010049 struct public_key_signature *sig;
David Howells2e3fadb2014-07-01 16:40:19 +010050};
51
52struct pkcs7_message {
53 struct x509_certificate *certs; /* Certificate list */
54 struct x509_certificate *crl; /* Revocation list */
55 struct pkcs7_signed_info *signed_infos;
David Howells60d65ca2015-07-20 21:16:33 +010056 u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */
David Howells99db4432015-08-05 15:22:27 +010057 bool have_authattrs; /* T if have authattrs */
David Howells2e3fadb2014-07-01 16:40:19 +010058
59 /* Content Data (or NULL) */
60 enum OID data_type; /* Type of Data */
61 size_t data_len; /* Length of Data */
62 size_t data_hdrlen; /* Length of Data ASN.1 header */
63 const void *data; /* Content Data (or 0) */
64};