162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* PKCS#7 crypto data parser internal definitions 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 562306a36Sopenharmony_ci * Written by David Howells (dhowells@redhat.com) 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <linux/oid_registry.h> 962306a36Sopenharmony_ci#include <crypto/pkcs7.h> 1062306a36Sopenharmony_ci#include "x509_parser.h" 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define kenter(FMT, ...) \ 1362306a36Sopenharmony_ci pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__) 1462306a36Sopenharmony_ci#define kleave(FMT, ...) \ 1562306a36Sopenharmony_ci pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__) 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct pkcs7_signed_info { 1862306a36Sopenharmony_ci struct pkcs7_signed_info *next; 1962306a36Sopenharmony_ci struct x509_certificate *signer; /* Signing certificate (in msg->certs) */ 2062306a36Sopenharmony_ci unsigned index; 2162306a36Sopenharmony_ci bool unsupported_crypto; /* T if not usable due to missing crypto */ 2262306a36Sopenharmony_ci bool blacklisted; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci /* Message digest - the digest of the Content Data (or NULL) */ 2562306a36Sopenharmony_ci const void *msgdigest; 2662306a36Sopenharmony_ci unsigned msgdigest_len; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci /* Authenticated Attribute data (or NULL) */ 2962306a36Sopenharmony_ci unsigned authattrs_len; 3062306a36Sopenharmony_ci const void *authattrs; 3162306a36Sopenharmony_ci unsigned long aa_set; 3262306a36Sopenharmony_ci#define sinfo_has_content_type 0 3362306a36Sopenharmony_ci#define sinfo_has_signing_time 1 3462306a36Sopenharmony_ci#define sinfo_has_message_digest 2 3562306a36Sopenharmony_ci#define sinfo_has_smime_caps 3 3662306a36Sopenharmony_ci#define sinfo_has_ms_opus_info 4 3762306a36Sopenharmony_ci#define sinfo_has_ms_statement_type 5 3862306a36Sopenharmony_ci time64_t signing_time; 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#ifdef CONFIG_SECURITY_CODE_SIGN 4162306a36Sopenharmony_ci const char *ownerid; 4262306a36Sopenharmony_ci unsigned ownerid_len; 4362306a36Sopenharmony_ci#endif /* CONFIG_SECURITY_CODE_SIGN */ 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci /* Message signature. 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * This contains the generated digest of _either_ the Content Data or 4862306a36Sopenharmony_ci * the Authenticated Attributes [RFC2315 9.3]. If the latter, one of 4962306a36Sopenharmony_ci * the attributes contains the digest of the Content Data within it. 5062306a36Sopenharmony_ci * 5162306a36Sopenharmony_ci * This also contains the issuing cert serial number and issuer's name 5262306a36Sopenharmony_ci * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3]. 5362306a36Sopenharmony_ci */ 5462306a36Sopenharmony_ci struct public_key_signature *sig; 5562306a36Sopenharmony_ci}; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistruct pkcs7_message { 5862306a36Sopenharmony_ci struct x509_certificate *certs; /* Certificate list */ 5962306a36Sopenharmony_ci struct x509_certificate *crl; /* Revocation list */ 6062306a36Sopenharmony_ci struct pkcs7_signed_info *signed_infos; 6162306a36Sopenharmony_ci u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */ 6262306a36Sopenharmony_ci bool have_authattrs; /* T if have authattrs */ 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci /* Content Data (or NULL) */ 6562306a36Sopenharmony_ci enum OID data_type; /* Type of Data */ 6662306a36Sopenharmony_ci size_t data_len; /* Length of Data */ 6762306a36Sopenharmony_ci size_t data_hdrlen; /* Length of Data ASN.1 header */ 6862306a36Sopenharmony_ci const void *data; /* Content Data (or 0) */ 6962306a36Sopenharmony_ci}; 70