fscrypt_ice.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright (c) 2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _FSCRYPT_ICE_H
  13. #define _FSCRYPT_ICE_H
  14. #include <linux/blkdev.h>
  15. #include "fscrypt_private.h"
  16. #if IS_ENABLED(CONFIG_FS_ENCRYPTION)
  17. static inline int fscrypt_should_be_processed_by_ice(const struct inode *inode)
  18. {
  19. if (!inode->i_sb->s_cop)
  20. return 0;
  21. if (!IS_ENCRYPTED((struct inode *)inode))
  22. return 0;
  23. return fscrypt_using_hardware_encryption(inode);
  24. }
  25. static inline int fscrypt_is_ice_capable(const struct super_block *sb)
  26. {
  27. return blk_queue_inlinecrypt(bdev_get_queue(sb->s_bdev));
  28. }
  29. int fscrypt_is_aes_xts_cipher(const struct inode *inode);
  30. char *fscrypt_get_ice_encryption_key(const struct inode *inode);
  31. char *fscrypt_get_ice_encryption_salt(const struct inode *inode);
  32. bool fscrypt_is_ice_encryption_info_equal(const struct inode *inode1,
  33. const struct inode *inode2);
  34. static inline size_t fscrypt_get_ice_encryption_key_size(
  35. const struct inode *inode)
  36. {
  37. return FS_AES_256_XTS_KEY_SIZE / 2;
  38. }
  39. static inline size_t fscrypt_get_ice_encryption_salt_size(
  40. const struct inode *inode)
  41. {
  42. return FS_AES_256_XTS_KEY_SIZE / 2;
  43. }
  44. #else
  45. static inline int fscrypt_should_be_processed_by_ice(const struct inode *inode)
  46. {
  47. return 0;
  48. }
  49. static inline int fscrypt_is_ice_capable(const struct super_block *sb)
  50. {
  51. return 0;
  52. }
  53. static inline char *fscrypt_get_ice_encryption_key(const struct inode *inode)
  54. {
  55. return NULL;
  56. }
  57. static inline char *fscrypt_get_ice_encryption_salt(const struct inode *inode)
  58. {
  59. return NULL;
  60. }
  61. static inline size_t fscrypt_get_ice_encryption_key_size(
  62. const struct inode *inode)
  63. {
  64. return 0;
  65. }
  66. static inline size_t fscrypt_get_ice_encryption_salt_size(
  67. const struct inode *inode)
  68. {
  69. return 0;
  70. }
  71. static inline int fscrypt_is_xts_cipher(const struct inode *inode)
  72. {
  73. return 0;
  74. }
  75. static inline bool fscrypt_is_ice_encryption_info_equal(
  76. const struct inode *inode1,
  77. const struct inode *inode2)
  78. {
  79. return 0;
  80. }
  81. static inline int fscrypt_is_aes_xts_cipher(const struct inode *inode)
  82. {
  83. return 0;
  84. }
  85. #endif
  86. #endif /* _FSCRYPT_ICE_H */