Zhen Kong | ee7bdc6 | 2019-03-14 10:55:19 -0700 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
| 3 | * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #ifndef _FSCRYPT_ICE_H |
| 7 | #define _FSCRYPT_ICE_H |
| 8 | |
| 9 | #include <linux/blkdev.h> |
| 10 | #include "fscrypt_private.h" |
| 11 | |
| 12 | #if IS_ENABLED(CONFIG_FS_ENCRYPTION) |
| 13 | static inline bool fscrypt_should_be_processed_by_ice(const struct inode *inode) |
| 14 | { |
| 15 | if (!inode->i_sb->s_cop) |
| 16 | return false; |
| 17 | if (!inode->i_sb->s_cop->is_encrypted((struct inode *)inode)) |
| 18 | return false; |
| 19 | |
| 20 | return fscrypt_using_hardware_encryption(inode); |
| 21 | } |
| 22 | |
| 23 | static inline int fscrypt_is_ice_capable(const struct super_block *sb) |
| 24 | { |
| 25 | return blk_queue_inlinecrypt(bdev_get_queue(sb->s_bdev)); |
| 26 | } |
| 27 | |
| 28 | int fscrypt_is_aes_xts_cipher(const struct inode *inode); |
| 29 | |
| 30 | char *fscrypt_get_ice_encryption_key(const struct inode *inode); |
| 31 | char *fscrypt_get_ice_encryption_salt(const struct inode *inode); |
| 32 | |
| 33 | bool fscrypt_is_ice_encryption_info_equal(const struct inode *inode1, |
| 34 | const struct inode *inode2); |
| 35 | |
| 36 | static inline size_t fscrypt_get_ice_encryption_key_size( |
| 37 | const struct inode *inode) |
| 38 | { |
| 39 | return FS_AES_256_XTS_KEY_SIZE / 2; |
| 40 | } |
| 41 | |
| 42 | static inline size_t fscrypt_get_ice_encryption_salt_size( |
| 43 | const struct inode *inode) |
| 44 | { |
| 45 | return FS_AES_256_XTS_KEY_SIZE / 2; |
| 46 | } |
| 47 | #else |
| 48 | static inline bool fscrypt_should_be_processed_by_ice(const struct inode *inode) |
| 49 | { |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | static inline int fscrypt_is_ice_capable(const struct super_block *sb) |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | static inline char *fscrypt_get_ice_encryption_key(const struct inode *inode) |
| 59 | { |
| 60 | return NULL; |
| 61 | } |
| 62 | |
| 63 | static inline char *fscrypt_get_ice_encryption_salt(const struct inode *inode) |
| 64 | { |
| 65 | return NULL; |
| 66 | } |
| 67 | |
| 68 | static inline size_t fscrypt_get_ice_encryption_key_size( |
| 69 | const struct inode *inode) |
| 70 | { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | static inline size_t fscrypt_get_ice_encryption_salt_size( |
| 75 | const struct inode *inode) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | static inline int fscrypt_is_xts_cipher(const struct inode *inode) |
| 81 | { |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static inline bool fscrypt_is_ice_encryption_info_equal( |
| 86 | const struct inode *inode1, |
| 87 | const struct inode *inode2) |
| 88 | { |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | static inline int fscrypt_is_aes_xts_cipher(const struct inode *inode) |
| 93 | { |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | #endif |
| 98 | |
| 99 | #endif /* _FSCRYPT_ICE_H */ |