blob: 40d826b743da87a9ee4be4cd8dde116303ab5a3a [file] [log] [blame]
Blagovest Kolenichev49875672020-04-20 07:29:59 -07001/* 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 */
12struct 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
18extern const struct blk_crypto_mode blk_crypto_modes[];
19
20#ifdef CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK
21
22int blk_crypto_fallback_submit_bio(struct bio **bio_ptr);
23
24bool blk_crypto_queue_decrypt_bio(struct bio *bio);
25
26int blk_crypto_fallback_evict_key(const struct blk_crypto_key *key);
27
28bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc);
29
30#else /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */
31
32static inline bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc)
33{
34 return false;
35}
36
37static 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
44static inline bool blk_crypto_queue_decrypt_bio(struct bio *bio)
45{
46 WARN_ON(1);
47 return false;
48}
49
50static inline int
51blk_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 */