x509_parser.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* X.509 certificate 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/time.h>
  12. #include <crypto/public_key.h>
  13. struct x509_certificate {
  14. struct x509_certificate *next;
  15. struct x509_certificate *signer; /* Certificate that signed this one */
  16. struct public_key *pub; /* Public key details */
  17. struct public_key_signature sig; /* Signature parameters */
  18. char *issuer; /* Name of certificate issuer */
  19. char *subject; /* Name of certificate subject */
  20. struct asymmetric_key_id *id; /* Issuer + Serial number */
  21. struct asymmetric_key_id *skid; /* Subject + subjectKeyId (optional) */
  22. struct asymmetric_key_id *akid_id; /* CA AuthKeyId matching ->id (optional) */
  23. struct asymmetric_key_id *akid_skid; /* CA AuthKeyId matching ->skid (optional) */
  24. time64_t valid_from;
  25. time64_t valid_to;
  26. const void *tbs; /* Signed data */
  27. unsigned tbs_size; /* Size of signed data */
  28. unsigned raw_sig_size; /* Size of sigature */
  29. const void *raw_sig; /* Signature data */
  30. const void *raw_serial; /* Raw serial number in ASN.1 */
  31. unsigned raw_serial_size;
  32. unsigned raw_issuer_size;
  33. const void *raw_issuer; /* Raw issuer name in ASN.1 */
  34. const void *raw_subject; /* Raw subject name in ASN.1 */
  35. unsigned raw_subject_size;
  36. unsigned raw_skid_size;
  37. const void *raw_skid; /* Raw subjectKeyId in ASN.1 */
  38. unsigned index;
  39. bool seen; /* Infinite recursion prevention */
  40. bool verified;
  41. bool trusted;
  42. bool unsupported_crypto; /* T if can't be verified due to missing crypto */
  43. };
  44. /*
  45. * x509_cert_parser.c
  46. */
  47. extern void x509_free_certificate(struct x509_certificate *cert);
  48. extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
  49. extern int x509_decode_time(time64_t *_t, size_t hdrlen,
  50. unsigned char tag,
  51. const unsigned char *value, size_t vlen);
  52. /*
  53. * x509_public_key.c
  54. */
  55. extern int x509_get_sig_params(struct x509_certificate *cert);
  56. extern int x509_check_signature(const struct public_key *pub,
  57. struct x509_certificate *cert);