pkcs7_parser.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #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 the Content Data within
  39. * it.
  40. *
  41. * THis also contains the issuing cert serial number and issuer's name
  42. * [PKCS#7 or CMS ver 1] or issuing cert's SKID [CMS ver 3].
  43. */
  44. struct public_key_signature *sig;
  45. };
  46. struct pkcs7_message {
  47. struct x509_certificate *certs; /* Certificate list */
  48. struct x509_certificate *crl; /* Revocation list */
  49. struct pkcs7_signed_info *signed_infos;
  50. u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */
  51. bool have_authattrs; /* T if have authattrs */
  52. /* Content Data (or NULL) */
  53. enum OID data_type; /* Type of Data */
  54. size_t data_len; /* Length of Data */
  55. size_t data_hdrlen; /* Length of Data ASN.1 header */
  56. const void *data; /* Content Data (or 0) */
  57. };