blob: d5eec31e95b60c600dd97421ce75772548f10951 [file] [log] [blame]
David Howells2e3fadb2014-07-01 16:40:19 +01001/* PKCS#7 crypto data parser internal definitions
2 *
3 * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#include <linux/oid_registry.h>
13#include <crypto/pkcs7.h>
14#include "x509_parser.h"
15
16#define kenter(FMT, ...) \
17 pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__)
18#define kleave(FMT, ...) \
19 pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
20
21struct pkcs7_signed_info {
22 struct pkcs7_signed_info *next;
23 struct x509_certificate *signer; /* Signing certificate (in msg->certs) */
David Howells99db4432015-08-05 15:22:27 +010024 unsigned index;
25 bool trusted;
26 bool unsupported_crypto; /* T if not usable due to missing crypto */
David Howells2e3fadb2014-07-01 16:40:19 +010027
28 /* Message digest - the digest of the Content Data (or NULL) */
29 const void *msgdigest;
30 unsigned msgdigest_len;
31
32 /* Authenticated Attribute data (or NULL) */
33 unsigned authattrs_len;
34 const void *authattrs;
David Howells99db4432015-08-05 15:22:27 +010035 unsigned long aa_set;
36#define sinfo_has_content_type 0
37#define sinfo_has_signing_time 1
38#define sinfo_has_message_digest 2
39#define sinfo_has_smime_caps 3
40#define sinfo_has_ms_opus_info 4
41#define sinfo_has_ms_statement_type 5
42 time64_t signing_time;
David Howells2e3fadb2014-07-01 16:40:19 +010043
David Howells2e3fadb2014-07-01 16:40:19 +010044 /* Message signature.
45 *
46 * This contains the generated digest of _either_ the Content Data or
47 * the Authenticated Attributes [RFC2315 9.3]. If the latter, one of
48 * the attributes contains the digest of the the Content Data within
49 * it.
David Howells566a1172016-04-06 16:13:33 +010050 *
51 * THis also contains the issuing cert serial number and issuer's name
52 * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3].
David Howells2e3fadb2014-07-01 16:40:19 +010053 */
David Howells566a1172016-04-06 16:13:33 +010054 struct public_key_signature *sig;
David Howells2e3fadb2014-07-01 16:40:19 +010055};
56
57struct pkcs7_message {
58 struct x509_certificate *certs; /* Certificate list */
59 struct x509_certificate *crl; /* Revocation list */
60 struct pkcs7_signed_info *signed_infos;
David Howells60d65ca2015-07-20 21:16:33 +010061 u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */
David Howells99db4432015-08-05 15:22:27 +010062 bool have_authattrs; /* T if have authattrs */
David Howells2e3fadb2014-07-01 16:40:19 +010063
64 /* Content Data (or NULL) */
65 enum OID data_type; /* Type of Data */
66 size_t data_len; /* Length of Data */
67 size_t data_hdrlen; /* Length of Data ASN.1 header */
68 const void *data; /* Content Data (or 0) */
69};