hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/powerpc/crypto/sha1.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Cryptographic API.
34 *
....@@ -10,25 +11,18 @@
1011 * Copyright (c) Alan Smithee.
1112 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
1213 * Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
13
- *
14
- * This program is free software; you can redistribute it and/or modify it
15
- * under the terms of the GNU General Public License as published by the Free
16
- * Software Foundation; either version 2 of the License, or (at your option)
17
- * any later version.
18
- *
1914 */
2015 #include <crypto/internal/hash.h>
2116 #include <linux/init.h>
2217 #include <linux/module.h>
2318 #include <linux/mm.h>
24
-#include <linux/cryptohash.h>
2519 #include <linux/types.h>
2620 #include <crypto/sha.h>
2721 #include <asm/byteorder.h>
2822
29
-extern void powerpc_sha_transform(u32 *state, const u8 *src, u32 *temp);
23
+void powerpc_sha_transform(u32 *state, const u8 *src);
3024
31
-static int sha1_init(struct shash_desc *desc)
25
+static int powerpc_sha1_init(struct shash_desc *desc)
3226 {
3327 struct sha1_state *sctx = shash_desc_ctx(desc);
3428
....@@ -39,8 +33,8 @@
3933 return 0;
4034 }
4135
42
-static int sha1_update(struct shash_desc *desc, const u8 *data,
43
- unsigned int len)
36
+static int powerpc_sha1_update(struct shash_desc *desc, const u8 *data,
37
+ unsigned int len)
4438 {
4539 struct sha1_state *sctx = shash_desc_ctx(desc);
4640 unsigned int partial, done;
....@@ -52,7 +46,6 @@
5246 src = data;
5347
5448 if ((partial + len) > 63) {
55
- u32 temp[SHA_WORKSPACE_WORDS];
5649
5750 if (partial) {
5851 done = -partial;
....@@ -61,12 +54,11 @@
6154 }
6255
6356 do {
64
- powerpc_sha_transform(sctx->state, src, temp);
57
+ powerpc_sha_transform(sctx->state, src);
6558 done += 64;
6659 src = data + done;
6760 } while (done + 63 < len);
6861
69
- memzero_explicit(temp, sizeof(temp));
7062 partial = 0;
7163 }
7264 memcpy(sctx->buffer + partial, src, len - done);
....@@ -76,7 +68,7 @@
7668
7769
7870 /* Add padding and return the message digest. */
79
-static int sha1_final(struct shash_desc *desc, u8 *out)
71
+static int powerpc_sha1_final(struct shash_desc *desc, u8 *out)
8072 {
8173 struct sha1_state *sctx = shash_desc_ctx(desc);
8274 __be32 *dst = (__be32 *)out;
....@@ -89,10 +81,10 @@
8981 /* Pad out to 56 mod 64 */
9082 index = sctx->count & 0x3f;
9183 padlen = (index < 56) ? (56 - index) : ((64+56) - index);
92
- sha1_update(desc, padding, padlen);
84
+ powerpc_sha1_update(desc, padding, padlen);
9385
9486 /* Append length */
95
- sha1_update(desc, (const u8 *)&bits, sizeof(bits));
87
+ powerpc_sha1_update(desc, (const u8 *)&bits, sizeof(bits));
9688
9789 /* Store state in digest */
9890 for (i = 0; i < 5; i++)
....@@ -104,7 +96,7 @@
10496 return 0;
10597 }
10698
107
-static int sha1_export(struct shash_desc *desc, void *out)
99
+static int powerpc_sha1_export(struct shash_desc *desc, void *out)
108100 {
109101 struct sha1_state *sctx = shash_desc_ctx(desc);
110102
....@@ -112,7 +104,7 @@
112104 return 0;
113105 }
114106
115
-static int sha1_import(struct shash_desc *desc, const void *in)
107
+static int powerpc_sha1_import(struct shash_desc *desc, const void *in)
116108 {
117109 struct sha1_state *sctx = shash_desc_ctx(desc);
118110
....@@ -122,11 +114,11 @@
122114
123115 static struct shash_alg alg = {
124116 .digestsize = SHA1_DIGEST_SIZE,
125
- .init = sha1_init,
126
- .update = sha1_update,
127
- .final = sha1_final,
128
- .export = sha1_export,
129
- .import = sha1_import,
117
+ .init = powerpc_sha1_init,
118
+ .update = powerpc_sha1_update,
119
+ .final = powerpc_sha1_final,
120
+ .export = powerpc_sha1_export,
121
+ .import = powerpc_sha1_import,
130122 .descsize = sizeof(struct sha1_state),
131123 .statesize = sizeof(struct sha1_state),
132124 .base = {