encrypted.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __ENCRYPTED_KEY_H
  2. #define __ENCRYPTED_KEY_H
  3. #define ENCRYPTED_DEBUG 0
  4. #ifdef CONFIG_TRUSTED_KEYS
  5. extern struct key *request_trusted_key(const char *trusted_desc,
  6. u8 **master_key, size_t *master_keylen);
  7. #else
  8. static inline struct key *request_trusted_key(const char *trusted_desc,
  9. u8 **master_key,
  10. size_t *master_keylen)
  11. {
  12. return ERR_PTR(-EOPNOTSUPP);
  13. }
  14. #endif
  15. #if ENCRYPTED_DEBUG
  16. static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
  17. {
  18. print_hex_dump(KERN_ERR, "master key: ", DUMP_PREFIX_NONE, 32, 1,
  19. master_key, master_keylen, 0);
  20. }
  21. static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
  22. {
  23. print_hex_dump(KERN_ERR, "decrypted data: ", DUMP_PREFIX_NONE, 32, 1,
  24. epayload->decrypted_data,
  25. epayload->decrypted_datalen, 0);
  26. }
  27. static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
  28. unsigned int encrypted_datalen)
  29. {
  30. print_hex_dump(KERN_ERR, "encrypted data: ", DUMP_PREFIX_NONE, 32, 1,
  31. epayload->encrypted_data, encrypted_datalen, 0);
  32. }
  33. static inline void dump_hmac(const char *str, const u8 *digest,
  34. unsigned int hmac_size)
  35. {
  36. if (str)
  37. pr_info("encrypted_key: %s", str);
  38. print_hex_dump(KERN_ERR, "hmac: ", DUMP_PREFIX_NONE, 32, 1, digest,
  39. hmac_size, 0);
  40. }
  41. #else
  42. static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
  43. {
  44. }
  45. static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
  46. {
  47. }
  48. static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
  49. unsigned int encrypted_datalen)
  50. {
  51. }
  52. static inline void dump_hmac(const char *str, const u8 *digest,
  53. unsigned int hmac_size)
  54. {
  55. }
  56. #endif
  57. #endif