encrypted.h 1.4 KB

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