module_signature.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Module signature handling.
  4. *
  5. * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  6. * Written by David Howells (dhowells@redhat.com)
  7. */
  8. #ifndef _LINUX_MODULE_SIGNATURE_H
  9. #define _LINUX_MODULE_SIGNATURE_H
  10. #include <linux/types.h>
  11. /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
  12. #define MODULE_SIG_STRING "~Module signature appended~\n"
  13. enum pkey_id_type {
  14. PKEY_ID_PGP, /* OpenPGP generated key ID */
  15. PKEY_ID_X509, /* X.509 arbitrary subjectKeyIdentifier */
  16. PKEY_ID_PKCS7, /* Signature in PKCS#7 message */
  17. };
  18. /*
  19. * Module signature information block.
  20. *
  21. * The constituents of the signature section are, in order:
  22. *
  23. * - Signer's name
  24. * - Key identifier
  25. * - Signature data
  26. * - Information block
  27. */
  28. struct module_signature {
  29. u8 algo; /* Public-key crypto algorithm [0] */
  30. u8 hash; /* Digest algorithm [0] */
  31. u8 id_type; /* Key identifier type [PKEY_ID_PKCS7] */
  32. u8 signer_len; /* Length of signer's name [0] */
  33. u8 key_id_len; /* Length of key identifier [0] */
  34. u8 __pad[3];
  35. __be32 sig_len; /* Length of signature data */
  36. };
  37. int mod_check_sig(const struct module_signature *ms, size_t file_len,
  38. const char *name);
  39. #endif /* _LINUX_MODULE_SIGNATURE_H */