public_key.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include <linux/keyctl.h>
  16. /*
  17. * Cryptographic data for the public-key subtype of the asymmetric key type.
  18. *
  19. * Note that this may include private part of the key as well as the public
  20. * part.
  21. */
  22. struct public_key {
  23. void *key;
  24. u32 keylen;
  25. bool key_is_private;
  26. const char *id_type;
  27. const char *pkey_algo;
  28. };
  29. extern void public_key_free(struct public_key *key);
  30. /*
  31. * Public key cryptography signature data
  32. */
  33. struct public_key_signature {
  34. struct asymmetric_key_id *auth_ids[2];
  35. u8 *s; /* Signature */
  36. u32 s_size; /* Number of bytes in signature */
  37. u8 *digest;
  38. u8 digest_size; /* Number of bytes in digest */
  39. const char *pkey_algo;
  40. const char *hash_algo;
  41. const char *encoding;
  42. };
  43. extern void public_key_signature_free(struct public_key_signature *sig);
  44. extern struct asymmetric_key_subtype public_key_subtype;
  45. struct key;
  46. struct key_type;
  47. union key_payload;
  48. extern int restrict_link_by_signature(struct key *dest_keyring,
  49. const struct key_type *type,
  50. const union key_payload *payload,
  51. struct key *trust_keyring);
  52. extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
  53. const struct key_type *type,
  54. const union key_payload *payload,
  55. struct key *trusted);
  56. extern int restrict_link_by_key_or_keyring_chain(struct key *trust_keyring,
  57. const struct key_type *type,
  58. const union key_payload *payload,
  59. struct key *trusted);
  60. extern int query_asymmetric_key(const struct kernel_pkey_params *,
  61. struct kernel_pkey_query *);
  62. extern int encrypt_blob(struct kernel_pkey_params *, const void *, void *);
  63. extern int decrypt_blob(struct kernel_pkey_params *, const void *, void *);
  64. extern int create_signature(struct kernel_pkey_params *, const void *, void *);
  65. extern int verify_signature(const struct key *,
  66. const struct public_key_signature *);
  67. int public_key_verify_signature(const struct public_key *pkey,
  68. const struct public_key_signature *sig);
  69. #endif /* _LINUX_PUBLIC_KEY_H */