You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cms.h 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _IPXE_CMS_H
  2. #define _IPXE_CMS_H
  3. /** @file
  4. *
  5. * Cryptographic Message Syntax (PKCS #7)
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <time.h>
  10. #include <ipxe/asn1.h>
  11. #include <ipxe/crypto.h>
  12. #include <ipxe/x509.h>
  13. #include <ipxe/refcnt.h>
  14. #include <ipxe/uaccess.h>
  15. /** CMS signer information */
  16. struct cms_signer_info {
  17. /** List of signer information blocks */
  18. struct list_head list;
  19. /** Certificate chain */
  20. struct x509_chain *chain;
  21. /** Digest algorithm */
  22. struct digest_algorithm *digest;
  23. /** Public-key algorithm */
  24. struct pubkey_algorithm *pubkey;
  25. /** Signature */
  26. void *signature;
  27. /** Length of signature */
  28. size_t signature_len;
  29. };
  30. /** A CMS signature */
  31. struct cms_signature {
  32. /** Reference count */
  33. struct refcnt refcnt;
  34. /** List of all certificates */
  35. struct x509_chain *certificates;
  36. /** List of signer information blocks */
  37. struct list_head info;
  38. };
  39. /**
  40. * Get reference to CMS signature
  41. *
  42. * @v sig CMS signature
  43. * @ret sig CMS signature
  44. */
  45. static inline __attribute__ (( always_inline )) struct cms_signature *
  46. cms_get ( struct cms_signature *sig ) {
  47. ref_get ( &sig->refcnt );
  48. return sig;
  49. }
  50. /**
  51. * Drop reference to CMS signature
  52. *
  53. * @v sig CMS signature
  54. */
  55. static inline __attribute__ (( always_inline )) void
  56. cms_put ( struct cms_signature *sig ) {
  57. ref_put ( &sig->refcnt );
  58. }
  59. extern int cms_signature ( const void *data, size_t len,
  60. struct cms_signature **sig );
  61. extern int cms_verify ( struct cms_signature *sig, userptr_t data, size_t len,
  62. const char *name, time_t time, struct x509_chain *store,
  63. struct x509_root *root );
  64. #endif /* _IPXE_CMS_H */