Blagovest Kolenichev | 4987567 | 2020-04-20 07:29:59 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright 2019 Google LLC |
| 4 | */ |
| 5 | |
| 6 | #ifndef __LINUX_BLK_CRYPTO_INTERNAL_H |
| 7 | #define __LINUX_BLK_CRYPTO_INTERNAL_H |
| 8 | |
| 9 | #include <linux/bio.h> |
| 10 | |
| 11 | /* Represents a crypto mode supported by blk-crypto */ |
| 12 | struct blk_crypto_mode { |
| 13 | const char *cipher_str; /* crypto API name (for fallback case) */ |
| 14 | unsigned int keysize; /* key size in bytes */ |
| 15 | unsigned int ivsize; /* iv size in bytes */ |
| 16 | }; |
| 17 | |
| 18 | extern const struct blk_crypto_mode blk_crypto_modes[]; |
| 19 | |
| 20 | #ifdef CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK |
| 21 | |
| 22 | int blk_crypto_fallback_submit_bio(struct bio **bio_ptr); |
| 23 | |
| 24 | bool blk_crypto_queue_decrypt_bio(struct bio *bio); |
| 25 | |
| 26 | int blk_crypto_fallback_evict_key(const struct blk_crypto_key *key); |
| 27 | |
| 28 | bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc); |
| 29 | |
| 30 | #else /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */ |
| 31 | |
| 32 | static inline bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc) |
| 33 | { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | static inline int blk_crypto_fallback_submit_bio(struct bio **bio_ptr) |
| 38 | { |
| 39 | pr_warn_once("crypto API fallback disabled; failing request\n"); |
| 40 | (*bio_ptr)->bi_status = BLK_STS_NOTSUPP; |
| 41 | return -EIO; |
| 42 | } |
| 43 | |
| 44 | static inline bool blk_crypto_queue_decrypt_bio(struct bio *bio) |
| 45 | { |
| 46 | WARN_ON(1); |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | static inline int |
| 51 | blk_crypto_fallback_evict_key(const struct blk_crypto_key *key) |
| 52 | { |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | #endif /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */ |
| 57 | |
| 58 | #endif /* __LINUX_BLK_CRYPTO_INTERNAL_H */ |