pkcs7_parser.h 2.1 KB

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