Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* PKCS#7 crypto data parser internal definitions
0003  *
0004  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
0005  * Written by David Howells (dhowells@redhat.com)
0006  */
0007 
0008 #include <linux/oid_registry.h>
0009 #include <crypto/pkcs7.h>
0010 #include "x509_parser.h"
0011 
0012 #define kenter(FMT, ...) \
0013     pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__)
0014 #define kleave(FMT, ...) \
0015     pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
0016 
0017 struct pkcs7_signed_info {
0018     struct pkcs7_signed_info *next;
0019     struct x509_certificate *signer; /* Signing certificate (in msg->certs) */
0020     unsigned    index;
0021     bool        unsupported_crypto; /* T if not usable due to missing crypto */
0022     bool        blacklisted;
0023 
0024     /* Message digest - the digest of the Content Data (or NULL) */
0025     const void  *msgdigest;
0026     unsigned    msgdigest_len;
0027 
0028     /* Authenticated Attribute data (or NULL) */
0029     unsigned    authattrs_len;
0030     const void  *authattrs;
0031     unsigned long   aa_set;
0032 #define sinfo_has_content_type      0
0033 #define sinfo_has_signing_time      1
0034 #define sinfo_has_message_digest    2
0035 #define sinfo_has_smime_caps        3
0036 #define sinfo_has_ms_opus_info      4
0037 #define sinfo_has_ms_statement_type 5
0038     time64_t    signing_time;
0039 
0040     /* Message signature.
0041      *
0042      * This contains the generated digest of _either_ the Content Data or
0043      * the Authenticated Attributes [RFC2315 9.3].  If the latter, one of
0044      * the attributes contains the digest of the Content Data within it.
0045      *
0046      * This also contains the issuing cert serial number and issuer's name
0047      * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3].
0048      */
0049     struct public_key_signature *sig;
0050 };
0051 
0052 struct pkcs7_message {
0053     struct x509_certificate *certs; /* Certificate list */
0054     struct x509_certificate *crl;   /* Revocation list */
0055     struct pkcs7_signed_info *signed_infos;
0056     u8      version;    /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */
0057     bool        have_authattrs; /* T if have authattrs */
0058 
0059     /* Content Data (or NULL) */
0060     enum OID    data_type;  /* Type of Data */
0061     size_t      data_len;   /* Length of Data */
0062     size_t      data_hdrlen;    /* Length of Data ASN.1 header */
0063     const void  *data;      /* Content Data (or 0) */
0064 };