18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* PKCS#7 crypto data parser internal definitions 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 58c2ecf20Sopenharmony_ci * Written by David Howells (dhowells@redhat.com) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/oid_registry.h> 98c2ecf20Sopenharmony_ci#include <crypto/pkcs7.h> 108c2ecf20Sopenharmony_ci#include "x509_parser.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define kenter(FMT, ...) \ 138c2ecf20Sopenharmony_ci pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__) 148c2ecf20Sopenharmony_ci#define kleave(FMT, ...) \ 158c2ecf20Sopenharmony_ci pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct pkcs7_signed_info { 188c2ecf20Sopenharmony_ci struct pkcs7_signed_info *next; 198c2ecf20Sopenharmony_ci struct x509_certificate *signer; /* Signing certificate (in msg->certs) */ 208c2ecf20Sopenharmony_ci unsigned index; 218c2ecf20Sopenharmony_ci bool unsupported_crypto; /* T if not usable due to missing crypto */ 228c2ecf20Sopenharmony_ci bool blacklisted; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci /* Message digest - the digest of the Content Data (or NULL) */ 258c2ecf20Sopenharmony_ci const void *msgdigest; 268c2ecf20Sopenharmony_ci unsigned msgdigest_len; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci /* Authenticated Attribute data (or NULL) */ 298c2ecf20Sopenharmony_ci unsigned authattrs_len; 308c2ecf20Sopenharmony_ci const void *authattrs; 318c2ecf20Sopenharmony_ci unsigned long aa_set; 328c2ecf20Sopenharmony_ci#define sinfo_has_content_type 0 338c2ecf20Sopenharmony_ci#define sinfo_has_signing_time 1 348c2ecf20Sopenharmony_ci#define sinfo_has_message_digest 2 358c2ecf20Sopenharmony_ci#define sinfo_has_smime_caps 3 368c2ecf20Sopenharmony_ci#define sinfo_has_ms_opus_info 4 378c2ecf20Sopenharmony_ci#define sinfo_has_ms_statement_type 5 388c2ecf20Sopenharmony_ci#define sinfo_has_owner_identifier 6 398c2ecf20Sopenharmony_ci time64_t signing_time; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#ifdef CONFIG_SECURITY_CODE_SIGN 428c2ecf20Sopenharmony_ci const char *ownerid; 438c2ecf20Sopenharmony_ci unsigned ownerid_len; 448c2ecf20Sopenharmony_ci#endif /* CONFIG_SECURITY_CODE_SIGN */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci /* Message signature. 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * This contains the generated digest of _either_ the Content Data or 498c2ecf20Sopenharmony_ci * the Authenticated Attributes [RFC2315 9.3]. If the latter, one of 508c2ecf20Sopenharmony_ci * the attributes contains the digest of the the Content Data within 518c2ecf20Sopenharmony_ci * it. 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * THis also contains the issuing cert serial number and issuer's name 548c2ecf20Sopenharmony_ci * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3]. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci struct public_key_signature *sig; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct pkcs7_message { 608c2ecf20Sopenharmony_ci struct x509_certificate *certs; /* Certificate list */ 618c2ecf20Sopenharmony_ci struct x509_certificate *crl; /* Revocation list */ 628c2ecf20Sopenharmony_ci struct pkcs7_signed_info *signed_infos; 638c2ecf20Sopenharmony_ci u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */ 648c2ecf20Sopenharmony_ci bool have_authattrs; /* T if have authattrs */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /* Content Data (or NULL) */ 678c2ecf20Sopenharmony_ci enum OID data_type; /* Type of Data */ 688c2ecf20Sopenharmony_ci size_t data_len; /* Length of Data */ 698c2ecf20Sopenharmony_ci size_t data_hdrlen; /* Length of Data ASN.1 header */ 708c2ecf20Sopenharmony_ci const void *data; /* Content Data (or 0) */ 718c2ecf20Sopenharmony_ci}; 72