pkcs7_parser.h 2.0 KB

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