public_key.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Asymmetric public-key algorithm definitions
  2. *
  3. * See Documentation/crypto/asymmetric-keys.txt
  4. *
  5. * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  6. * Written by David Howells (dhowells@redhat.com)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public Licence
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the Licence, or (at your option) any later version.
  12. */
  13. #ifndef _LINUX_PUBLIC_KEY_H
  14. #define _LINUX_PUBLIC_KEY_H
  15. /*
  16. * The use to which an asymmetric key is being put.
  17. */
  18. enum key_being_used_for {
  19. VERIFYING_MODULE_SIGNATURE,
  20. VERIFYING_FIRMWARE_SIGNATURE,
  21. VERIFYING_KEXEC_PE_SIGNATURE,
  22. VERIFYING_KEY_SIGNATURE,
  23. VERIFYING_KEY_SELF_SIGNATURE,
  24. VERIFYING_UNSPECIFIED_SIGNATURE,
  25. NR__KEY_BEING_USED_FOR
  26. };
  27. extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
  28. /*
  29. * Cryptographic data for the public-key subtype of the asymmetric key type.
  30. *
  31. * Note that this may include private part of the key as well as the public
  32. * part.
  33. */
  34. struct public_key {
  35. void *key;
  36. u32 keylen;
  37. const char *id_type;
  38. const char *pkey_algo;
  39. };
  40. extern void public_key_destroy(void *payload);
  41. /*
  42. * Public key cryptography signature data
  43. */
  44. struct public_key_signature {
  45. u8 *s; /* Signature */
  46. u32 s_size; /* Number of bytes in signature */
  47. u8 *digest;
  48. u8 digest_size; /* Number of bytes in digest */
  49. const char *pkey_algo;
  50. const char *hash_algo;
  51. };
  52. extern struct asymmetric_key_subtype public_key_subtype;
  53. struct key;
  54. extern int verify_signature(const struct key *key,
  55. const struct public_key_signature *sig);
  56. struct asymmetric_key_id;
  57. extern struct key *x509_request_asymmetric_key(struct key *keyring,
  58. const struct asymmetric_key_id *id,
  59. const struct asymmetric_key_id *skid,
  60. bool partial);
  61. int public_key_verify_signature(const struct public_key *pkey,
  62. const struct public_key_signature *sig);
  63. #endif /* _LINUX_PUBLIC_KEY_H */