blob: 5be7d9e1f8a8825383598eef24148c77e597e519 [file] [log] [blame]
Neeraj Sonic692cb92018-04-18 17:20:22 +05301/* 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
18struct ice_crypto_setting;
19
20#ifdef CONFIG_PFK
21
Neeraj Soni36c65122018-04-18 21:04:46 +053022/*
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
31struct blk_encryption_key {
32 u8 raw[BLK_ENCRYPTION_KEY_SIZE_AES_256_XTS];
33};
34
Neeraj Sonic692cb92018-04-18 17:20:22 +053035int pfk_load_key_start(const struct bio *bio,
Neeraj Sonie3af8d52018-09-05 14:32:49 +053036 struct ice_crypto_setting *ice_setting,
37 bool *is_pfe, bool async, int ice_rev);
Neeraj Sonic692cb92018-04-18 17:20:22 +053038int pfk_load_key_end(const struct bio *bio, bool *is_pfe);
39int pfk_remove_key(const unsigned char *key, size_t key_size);
40bool pfk_allow_merge_bio(const struct bio *bio1, const struct bio *bio2);
41void pfk_clear_on_reset(void);
42
43#else
44static inline int pfk_load_key_start(const struct bio *bio,
Neeraj Sonie3af8d52018-09-05 14:32:49 +053045 struct ice_crypto_setting *ice_setting, bool *is_pfe,
46 bool async, int ice_rev)
Neeraj Sonic692cb92018-04-18 17:20:22 +053047{
48 return -ENODEV;
49}
50
51static inline int pfk_load_key_end(const struct bio *bio, bool *is_pfe)
52{
53 return -ENODEV;
54}
55
56static inline int pfk_remove_key(const unsigned char *key, size_t key_size)
57{
58 return -ENODEV;
59}
60
61static inline bool pfk_allow_merge_bio(const struct bio *bio1,
62 const struct bio *bio2)
63{
64 return true;
65}
66
67static inline void pfk_clear_on_reset(void)
68{}
69
70#endif /* CONFIG_PFK */
71
72#endif /* PFK_H */