x509_parser.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. char *fingerprint; /* Key fingerprint as hex */
  21. char *authority; /* Authority key fingerprint as hex */
  22. struct tm valid_from;
  23. struct tm valid_to;
  24. const void *tbs; /* Signed data */
  25. unsigned tbs_size; /* Size of signed data */
  26. unsigned raw_sig_size; /* Size of sigature */
  27. const void *raw_sig; /* Signature data */
  28. const void *raw_serial; /* Raw serial number in ASN.1 */
  29. unsigned raw_serial_size;
  30. unsigned raw_issuer_size;
  31. const void *raw_issuer; /* Raw issuer name in ASN.1 */
  32. const void *raw_subject; /* Raw subject name in ASN.1 */
  33. unsigned raw_subject_size;
  34. unsigned index;
  35. bool seen; /* Infinite recursion prevention */
  36. bool verified;
  37. bool trusted;
  38. };
  39. /*
  40. * x509_cert_parser.c
  41. */
  42. extern void x509_free_certificate(struct x509_certificate *cert);
  43. extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
  44. /*
  45. * x509_public_key.c
  46. */
  47. extern int x509_get_sig_params(struct x509_certificate *cert);
  48. extern int x509_check_signature(const struct public_key *pub,
  49. struct x509_certificate *cert);