asymmetric-type.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Asymmetric Public-key cryptography key type interface
  2. *
  3. * See Documentation/security/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_TYPE_H
  14. #define _KEYS_ASYMMETRIC_TYPE_H
  15. #include <linux/key-type.h>
  16. extern struct key_type key_type_asymmetric;
  17. /*
  18. * Identifiers for an asymmetric key ID. We have three ways of looking up a
  19. * key derived from an X.509 certificate:
  20. *
  21. * (1) Serial Number & Issuer. Non-optional. This is the only valid way to
  22. * map a PKCS#7 signature to an X.509 certificate.
  23. *
  24. * (2) Issuer & Subject Unique IDs. Optional. These were the original way to
  25. * match X.509 certificates, but have fallen into disuse in favour of (3).
  26. *
  27. * (3) Auth & Subject Key Identifiers. Optional. SKIDs are only provided on
  28. * CA keys that are intended to sign other keys, so don't appear in end
  29. * user certificates unless forced.
  30. *
  31. * We could also support an PGP key identifier, which is just a SHA1 sum of the
  32. * public key and certain parameters, but since we don't support PGP keys at
  33. * the moment, we shall ignore those.
  34. *
  35. * What we actually do is provide a place where binary identifiers can be
  36. * stashed and then compare against them when checking for an id match.
  37. */
  38. struct asymmetric_key_id {
  39. unsigned short len;
  40. unsigned char data[];
  41. };
  42. struct asymmetric_key_ids {
  43. void *id[2];
  44. };
  45. extern bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1,
  46. const struct asymmetric_key_id *kid2);
  47. extern bool asymmetric_key_id_partial(const struct asymmetric_key_id *kid1,
  48. const struct asymmetric_key_id *kid2);
  49. extern struct asymmetric_key_id *asymmetric_key_generate_id(const void *val_1,
  50. size_t len_1,
  51. const void *val_2,
  52. size_t len_2);
  53. /*
  54. * The payload is at the discretion of the subtype.
  55. */
  56. #endif /* _KEYS_ASYMMETRIC_TYPE_H */