asymmetric-subtype.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Asymmetric public-key cryptography key subtype
  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 _KEYS_ASYMMETRIC_SUBTYPE_H
  14. #define _KEYS_ASYMMETRIC_SUBTYPE_H
  15. #include <linux/seq_file.h>
  16. #include <keys/asymmetric-type.h>
  17. struct kernel_pkey_query;
  18. struct kernel_pkey_params;
  19. struct public_key_signature;
  20. /*
  21. * Keys of this type declare a subtype that indicates the handlers and
  22. * capabilities.
  23. */
  24. struct asymmetric_key_subtype {
  25. struct module *owner;
  26. const char *name;
  27. unsigned short name_len; /* length of name */
  28. /* Describe a key of this subtype for /proc/keys */
  29. void (*describe)(const struct key *key, struct seq_file *m);
  30. /* Destroy a key of this subtype */
  31. void (*destroy)(void *payload_crypto, void *payload_auth);
  32. int (*query)(const struct kernel_pkey_params *params,
  33. struct kernel_pkey_query *info);
  34. /* Encrypt/decrypt/sign data */
  35. int (*eds_op)(struct kernel_pkey_params *params,
  36. const void *in, void *out);
  37. /* Verify the signature on a key of this subtype (optional) */
  38. int (*verify_signature)(const struct key *key,
  39. const struct public_key_signature *sig);
  40. };
  41. /**
  42. * asymmetric_key_subtype - Get the subtype from an asymmetric key
  43. * @key: The key of interest.
  44. *
  45. * Retrieves and returns the subtype pointer of the asymmetric key from the
  46. * type-specific data attached to the key.
  47. */
  48. static inline
  49. struct asymmetric_key_subtype *asymmetric_key_subtype(const struct key *key)
  50. {
  51. return key->payload.data[asym_subtype];
  52. }
  53. #endif /* _KEYS_ASYMMETRIC_SUBTYPE_H */