blob: b8234da45a6a25fb2a9b17daeaa8d3666cd2d2b3 [file] [log] [blame]
AKASHI Takahiroe85a7872019-11-13 09:45:01 +09001/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* 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)
6 */
7
AKASHI Takahiro7b8b63f2020-04-21 09:37:52 +09008#ifndef _PKCS7_PARSER_H
9#define _PKCS7_PARSER_H
10
AKASHI Takahiroe85a7872019-11-13 09:45:01 +090011#include <linux/oid_registry.h>
12#include <crypto/pkcs7.h>
13#include "x509_parser.h"
14
15#define kenter(FMT, ...) \
16 pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__)
17#define kleave(FMT, ...) \
18 pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
19
20struct pkcs7_signed_info {
21 struct pkcs7_signed_info *next;
22 struct x509_certificate *signer; /* Signing certificate (in msg->certs) */
23 unsigned index;
24 bool unsupported_crypto; /* T if not usable due to missing crypto */
25 bool blacklisted;
26
27 /* Message digest - the digest of the Content Data (or NULL) */
28 const void *msgdigest;
29 unsigned msgdigest_len;
30
31 /* Authenticated Attribute data (or NULL) */
32 unsigned authattrs_len;
33 const void *authattrs;
34 unsigned long aa_set;
35#define sinfo_has_content_type 0
36#define sinfo_has_signing_time 1
37#define sinfo_has_message_digest 2
38#define sinfo_has_smime_caps 3
39#define sinfo_has_ms_opus_info 4
40#define sinfo_has_ms_statement_type 5
41 time64_t signing_time;
42
43 /* Message signature.
44 *
45 * This contains the generated digest of _either_ the Content Data or
46 * the Authenticated Attributes [RFC2315 9.3]. If the latter, one of
47 * the attributes contains the digest of the the Content Data within
48 * it.
49 *
50 * THis also contains the issuing cert serial number and issuer's name
51 * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3].
52 */
53 struct public_key_signature *sig;
54};
55
56struct pkcs7_message {
57 struct x509_certificate *certs; /* Certificate list */
58 struct x509_certificate *crl; /* Revocation list */
59 struct pkcs7_signed_info *signed_infos;
60 u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */
61 bool have_authattrs; /* T if have authattrs */
62
63 /* Content Data (or NULL) */
64 enum OID data_type; /* Type of Data */
65 size_t data_len; /* Length of Data */
66 size_t data_hdrlen; /* Length of Data ASN.1 header */
67 const void *data; /* Content Data (or 0) */
68};
AKASHI Takahiro7b8b63f2020-04-21 09:37:52 +090069#endif /* _PKCS7_PARSER_H */