.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * AMD Cryptographic Coprocessor (CCP) crypto API support |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2013,2017 Advanced Micro Devices, Inc. |
---|
5 | 6 | * |
---|
6 | 7 | * Author: Tom Lendacky <thomas.lendacky@amd.com> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License version 2 as |
---|
10 | | - * published by the Free Software Foundation. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | #ifndef __CCP_CRYPTO_H__ |
---|
.. | .. |
---|
15 | 12 | |
---|
16 | 13 | #include <linux/list.h> |
---|
17 | 14 | #include <linux/wait.h> |
---|
18 | | -#include <linux/pci.h> |
---|
19 | 15 | #include <linux/ccp.h> |
---|
20 | 16 | #include <crypto/algapi.h> |
---|
21 | 17 | #include <crypto/aes.h> |
---|
.. | .. |
---|
25 | 21 | #include <crypto/hash.h> |
---|
26 | 22 | #include <crypto/sha.h> |
---|
27 | 23 | #include <crypto/akcipher.h> |
---|
| 24 | +#include <crypto/skcipher.h> |
---|
28 | 25 | #include <crypto/internal/rsa.h> |
---|
| 26 | + |
---|
| 27 | +/* We want the module name in front of our messages */ |
---|
| 28 | +#undef pr_fmt |
---|
| 29 | +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
29 | 30 | |
---|
30 | 31 | #define CCP_LOG_LEVEL KERN_INFO |
---|
31 | 32 | |
---|
32 | 33 | #define CCP_CRA_PRIORITY 300 |
---|
33 | 34 | |
---|
34 | | -struct ccp_crypto_ablkcipher_alg { |
---|
| 35 | +struct ccp_crypto_skcipher_alg { |
---|
35 | 36 | struct list_head entry; |
---|
36 | 37 | |
---|
37 | 38 | u32 mode; |
---|
38 | 39 | |
---|
39 | | - struct crypto_alg alg; |
---|
| 40 | + struct skcipher_alg alg; |
---|
40 | 41 | }; |
---|
41 | 42 | |
---|
42 | 43 | struct ccp_crypto_aead { |
---|
.. | .. |
---|
66 | 67 | struct akcipher_alg alg; |
---|
67 | 68 | }; |
---|
68 | 69 | |
---|
69 | | -static inline struct ccp_crypto_ablkcipher_alg * |
---|
70 | | - ccp_crypto_ablkcipher_alg(struct crypto_tfm *tfm) |
---|
| 70 | +static inline struct ccp_crypto_skcipher_alg * |
---|
| 71 | + ccp_crypto_skcipher_alg(struct crypto_skcipher *tfm) |
---|
71 | 72 | { |
---|
72 | | - struct crypto_alg *alg = tfm->__crt_alg; |
---|
| 73 | + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); |
---|
73 | 74 | |
---|
74 | | - return container_of(alg, struct ccp_crypto_ablkcipher_alg, alg); |
---|
| 75 | + return container_of(alg, struct ccp_crypto_skcipher_alg, alg); |
---|
75 | 76 | } |
---|
76 | 77 | |
---|
77 | 78 | static inline struct ccp_crypto_ahash_alg * |
---|
.. | .. |
---|
89 | 90 | struct ccp_aes_ctx { |
---|
90 | 91 | /* Fallback cipher for XTS with unsupported unit sizes */ |
---|
91 | 92 | struct crypto_skcipher *tfm_skcipher; |
---|
92 | | - |
---|
93 | | - /* Cipher used to generate CMAC K1/K2 keys */ |
---|
94 | | - struct crypto_cipher *tfm_cipher; |
---|
95 | 93 | |
---|
96 | 94 | enum ccp_engine engine; |
---|
97 | 95 | enum ccp_aes_type type; |
---|
.. | .. |
---|
123 | 121 | u8 rfc3686_iv[AES_BLOCK_SIZE]; |
---|
124 | 122 | |
---|
125 | 123 | struct ccp_cmd cmd; |
---|
| 124 | + |
---|
| 125 | + struct skcipher_request fallback_req; // keep at the end |
---|
126 | 126 | }; |
---|
127 | 127 | |
---|
128 | 128 | struct ccp_aes_cmac_req_ctx { |
---|