hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/crypto/ccp/ccp-crypto.h
....@@ -1,13 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * AMD Cryptographic Coprocessor (CCP) crypto API support
34 *
45 * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
56 *
67 * 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.
118 */
129
1310 #ifndef __CCP_CRYPTO_H__
....@@ -15,7 +12,6 @@
1512
1613 #include <linux/list.h>
1714 #include <linux/wait.h>
18
-#include <linux/pci.h>
1915 #include <linux/ccp.h>
2016 #include <crypto/algapi.h>
2117 #include <crypto/aes.h>
....@@ -25,18 +21,23 @@
2521 #include <crypto/hash.h>
2622 #include <crypto/sha.h>
2723 #include <crypto/akcipher.h>
24
+#include <crypto/skcipher.h>
2825 #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
2930
3031 #define CCP_LOG_LEVEL KERN_INFO
3132
3233 #define CCP_CRA_PRIORITY 300
3334
34
-struct ccp_crypto_ablkcipher_alg {
35
+struct ccp_crypto_skcipher_alg {
3536 struct list_head entry;
3637
3738 u32 mode;
3839
39
- struct crypto_alg alg;
40
+ struct skcipher_alg alg;
4041 };
4142
4243 struct ccp_crypto_aead {
....@@ -66,12 +67,12 @@
6667 struct akcipher_alg alg;
6768 };
6869
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)
7172 {
72
- struct crypto_alg *alg = tfm->__crt_alg;
73
+ struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
7374
74
- return container_of(alg, struct ccp_crypto_ablkcipher_alg, alg);
75
+ return container_of(alg, struct ccp_crypto_skcipher_alg, alg);
7576 }
7677
7778 static inline struct ccp_crypto_ahash_alg *
....@@ -89,9 +90,6 @@
8990 struct ccp_aes_ctx {
9091 /* Fallback cipher for XTS with unsupported unit sizes */
9192 struct crypto_skcipher *tfm_skcipher;
92
-
93
- /* Cipher used to generate CMAC K1/K2 keys */
94
- struct crypto_cipher *tfm_cipher;
9593
9694 enum ccp_engine engine;
9795 enum ccp_aes_type type;
....@@ -123,6 +121,8 @@
123121 u8 rfc3686_iv[AES_BLOCK_SIZE];
124122
125123 struct ccp_cmd cmd;
124
+
125
+ struct skcipher_request fallback_req; // keep at the end
126126 };
127127
128128 struct ccp_aes_cmac_req_ctx {