pkcs7_parser.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* PKCS#7 crypto data parser internal definitions
  2. *
  3. * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/oid_registry.h>
  12. #include <crypto/pkcs7.h>
  13. #include "x509_parser.h"
  14. #define kenter(FMT, ...) \
  15. pr_devel("==> %s("FMT")\n", __func__, ##__VA_ARGS__)
  16. #define kleave(FMT, ...) \
  17. pr_devel("<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
  18. struct pkcs7_signed_info {
  19. struct pkcs7_signed_info *next;
  20. struct x509_certificate *signer; /* Signing certificate (in msg->certs) */
  21. unsigned index;
  22. bool trusted;
  23. bool unsupported_crypto; /* T if not usable due to missing crypto */
  24. /* Message digest - the digest of the Content Data (or NULL) */
  25. const void *msgdigest;
  26. unsigned msgdigest_len;
  27. /* Authenticated Attribute data (or NULL) */
  28. unsigned authattrs_len;
  29. const void *authattrs;
  30. unsigned long aa_set;
  31. #define sinfo_has_content_type 0
  32. #define sinfo_has_signing_time 1
  33. #define sinfo_has_message_digest 2
  34. #define sinfo_has_smime_caps 3
  35. #define sinfo_has_ms_opus_info 4
  36. #define sinfo_has_ms_statement_type 5
  37. time64_t signing_time;
  38. /* Issuing cert serial number and issuer's name [PKCS#7 or CMS ver 1]
  39. * or issuing cert's SKID [CMS ver 3].
  40. */
  41. struct asymmetric_key_id *signing_cert_id;
  42. /* Message signature.
  43. *
  44. * This contains the generated digest of _either_ the Content Data or
  45. * the Authenticated Attributes [RFC2315 9.3]. If the latter, one of
  46. * the attributes contains the digest of the the Content Data within
  47. * it.
  48. */
  49. struct public_key_signature sig;
  50. };
  51. struct pkcs7_message {
  52. struct x509_certificate *certs; /* Certificate list */
  53. struct x509_certificate *crl; /* Revocation list */
  54. struct pkcs7_signed_info *signed_infos;
  55. u8 version; /* Version of cert (1 -> PKCS#7 or CMS; 3 -> CMS) */
  56. bool have_authattrs; /* T if have authattrs */
  57. /* Content Data (or NULL) */
  58. enum OID data_type; /* Type of Data */
  59. size_t data_len; /* Length of Data */
  60. size_t data_hdrlen; /* Length of Data ASN.1 header */
  61. const void *data; /* Content Data (or 0) */
  62. };