Neeraj Soni | c692cb9 | 2018-04-18 17:20:22 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2015-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 | |
| 13 | #ifndef PFK_H_ |
| 14 | #define PFK_H_ |
| 15 | |
| 16 | #include <linux/bio.h> |
| 17 | |
| 18 | struct ice_crypto_setting; |
| 19 | |
| 20 | #ifdef CONFIG_PFK |
| 21 | |
Neeraj Soni | 36c6512 | 2018-04-18 21:04:46 +0530 | [diff] [blame] | 22 | /* |
| 23 | * Default key for inline encryption. |
| 24 | * |
| 25 | * For now only AES-256-XTS is supported, so this is a fixed length. But if |
| 26 | * ever needed, this should be made variable-length with a 'mode' and 'size'. |
| 27 | * (Remember to update pfk_allow_merge_bio() when doing so!) |
| 28 | */ |
| 29 | #define BLK_ENCRYPTION_KEY_SIZE_AES_256_XTS 64 |
| 30 | |
| 31 | struct blk_encryption_key { |
| 32 | u8 raw[BLK_ENCRYPTION_KEY_SIZE_AES_256_XTS]; |
| 33 | }; |
| 34 | |
Neeraj Soni | c692cb9 | 2018-04-18 17:20:22 +0530 | [diff] [blame] | 35 | int pfk_load_key_start(const struct bio *bio, |
Neeraj Soni | e3af8d5 | 2018-09-05 14:32:49 +0530 | [diff] [blame^] | 36 | struct ice_crypto_setting *ice_setting, |
| 37 | bool *is_pfe, bool async, int ice_rev); |
Neeraj Soni | c692cb9 | 2018-04-18 17:20:22 +0530 | [diff] [blame] | 38 | int pfk_load_key_end(const struct bio *bio, bool *is_pfe); |
| 39 | int pfk_remove_key(const unsigned char *key, size_t key_size); |
| 40 | bool pfk_allow_merge_bio(const struct bio *bio1, const struct bio *bio2); |
| 41 | void pfk_clear_on_reset(void); |
| 42 | |
| 43 | #else |
| 44 | static inline int pfk_load_key_start(const struct bio *bio, |
Neeraj Soni | e3af8d5 | 2018-09-05 14:32:49 +0530 | [diff] [blame^] | 45 | struct ice_crypto_setting *ice_setting, bool *is_pfe, |
| 46 | bool async, int ice_rev) |
Neeraj Soni | c692cb9 | 2018-04-18 17:20:22 +0530 | [diff] [blame] | 47 | { |
| 48 | return -ENODEV; |
| 49 | } |
| 50 | |
| 51 | static inline int pfk_load_key_end(const struct bio *bio, bool *is_pfe) |
| 52 | { |
| 53 | return -ENODEV; |
| 54 | } |
| 55 | |
| 56 | static inline int pfk_remove_key(const unsigned char *key, size_t key_size) |
| 57 | { |
| 58 | return -ENODEV; |
| 59 | } |
| 60 | |
| 61 | static inline bool pfk_allow_merge_bio(const struct bio *bio1, |
| 62 | const struct bio *bio2) |
| 63 | { |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | static inline void pfk_clear_on_reset(void) |
| 68 | {} |
| 69 | |
| 70 | #endif /* CONFIG_PFK */ |
| 71 | |
| 72 | #endif /* PFK_H */ |