x509_parser.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* X.509 certificate 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/time.h>
  8. #include <crypto/public_key.h>
  9. #include <keys/asymmetric-type.h>
  10. struct x509_certificate {
  11. struct x509_certificate *next;
  12. struct x509_certificate *signer; /* Certificate that signed this one */
  13. struct public_key *pub; /* Public key details */
  14. struct public_key_signature *sig; /* Signature parameters */
  15. char *issuer; /* Name of certificate issuer */
  16. char *subject; /* Name of certificate subject */
  17. struct asymmetric_key_id *id; /* Issuer + Serial number */
  18. struct asymmetric_key_id *skid; /* Subject + subjectKeyId (optional) */
  19. time64_t valid_from;
  20. time64_t valid_to;
  21. const void *tbs; /* Signed data */
  22. unsigned tbs_size; /* Size of signed data */
  23. unsigned raw_sig_size; /* Size of sigature */
  24. const void *raw_sig; /* Signature data */
  25. const void *raw_serial; /* Raw serial number in ASN.1 */
  26. unsigned raw_serial_size;
  27. unsigned raw_issuer_size;
  28. const void *raw_issuer; /* Raw issuer name in ASN.1 */
  29. const void *raw_subject; /* Raw subject name in ASN.1 */
  30. unsigned raw_subject_size;
  31. unsigned raw_skid_size;
  32. const void *raw_skid; /* Raw subjectKeyId in ASN.1 */
  33. unsigned index;
  34. bool seen; /* Infinite recursion prevention */
  35. bool verified;
  36. bool self_signed; /* T if self-signed (check unsupported_sig too) */
  37. bool unsupported_key; /* T if key uses unsupported crypto */
  38. bool unsupported_sig; /* T if signature uses unsupported crypto */
  39. bool blacklisted;
  40. };
  41. /*
  42. * x509_cert_parser.c
  43. */
  44. extern void x509_free_certificate(struct x509_certificate *cert);
  45. extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
  46. extern int x509_decode_time(time64_t *_t, size_t hdrlen,
  47. unsigned char tag,
  48. const unsigned char *value, size_t vlen);
  49. /*
  50. * x509_public_key.c
  51. */
  52. extern int x509_get_sig_params(struct x509_certificate *cert);
  53. extern int x509_check_for_self_signed(struct x509_certificate *cert);