public_key.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * Cryptographic data for the public-key subtype of the asymmetric key type.
  17. *
  18. * Note that this may include private part of the key as well as the public
  19. * part.
  20. */
  21. struct public_key {
  22. void *key;
  23. u32 keylen;
  24. const char *id_type;
  25. const char *pkey_algo;
  26. };
  27. extern void public_key_free(struct public_key *key);
  28. /*
  29. * Public key cryptography signature data
  30. */
  31. struct public_key_signature {
  32. struct asymmetric_key_id *auth_ids[2];
  33. u8 *s; /* Signature */
  34. u32 s_size; /* Number of bytes in signature */
  35. u8 *digest;
  36. u8 digest_size; /* Number of bytes in digest */
  37. const char *pkey_algo;
  38. const char *hash_algo;
  39. };
  40. extern void public_key_signature_free(struct public_key_signature *sig);
  41. extern struct asymmetric_key_subtype public_key_subtype;
  42. struct key;
  43. struct key_type;
  44. union key_payload;
  45. extern int restrict_link_by_signature(struct key *trust_keyring,
  46. const struct key_type *type,
  47. const union key_payload *payload);
  48. extern int verify_signature(const struct key *key,
  49. const struct public_key_signature *sig);
  50. int public_key_verify_signature(const struct public_key *pkey,
  51. const struct public_key_signature *sig);
  52. #endif /* _LINUX_PUBLIC_KEY_H */