public_key.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 *dest_keyring,
  46. const struct key_type *type,
  47. const union key_payload *payload,
  48. struct key *trust_keyring);
  49. extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
  50. const struct key_type *type,
  51. const union key_payload *payload,
  52. struct key *trusted);
  53. extern int restrict_link_by_key_or_keyring_chain(struct key *trust_keyring,
  54. const struct key_type *type,
  55. const union key_payload *payload,
  56. struct key *trusted);
  57. extern int verify_signature(const struct key *key,
  58. const struct public_key_signature *sig);
  59. int public_key_verify_signature(const struct public_key *pkey,
  60. const struct public_key_signature *sig);
  61. #endif /* _LINUX_PUBLIC_KEY_H */