summaryrefslogtreecommitdiffstats
path: root/crypto/sha3_generic.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2018-01-19 07:04:36 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2018-01-25 09:10:34 -0500
commit6657674b23b8a8458a3222ec3da2fd376c78ae79 (patch)
tree1ccc6f68efa9d6570a81337bcedede1cc5d575ed /crypto/sha3_generic.c
parentbeeb504adf3d08c0e916f43259e8e2ad6bdd30ee (diff)
crypto: sha3-generic - export init/update/final routines
To allow accelerated implementations to fall back to the generic routines, e.g., in contexts where a SIMD based implementation is not allowed to run, expose the generic SHA3 init/update/final routines to other modules. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/sha3_generic.c')
-rw-r--r--crypto/sha3_generic.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c
index c7084a24eaf9..a965b9d80559 100644
--- a/crypto/sha3_generic.c
+++ b/crypto/sha3_generic.c
@@ -145,7 +145,7 @@ static void __attribute__((__optimize__("O3"))) keccakf(u64 st[25])
145 } 145 }
146} 146}
147 147
148static int sha3_init(struct shash_desc *desc) 148int crypto_sha3_init(struct shash_desc *desc)
149{ 149{
150 struct sha3_state *sctx = shash_desc_ctx(desc); 150 struct sha3_state *sctx = shash_desc_ctx(desc);
151 unsigned int digest_size = crypto_shash_digestsize(desc->tfm); 151 unsigned int digest_size = crypto_shash_digestsize(desc->tfm);
@@ -157,8 +157,9 @@ static int sha3_init(struct shash_desc *desc)
157 memset(sctx->st, 0, sizeof(sctx->st)); 157 memset(sctx->st, 0, sizeof(sctx->st));
158 return 0; 158 return 0;
159} 159}
160EXPORT_SYMBOL(crypto_sha3_init);
160 161
161static int sha3_update(struct shash_desc *desc, const u8 *data, 162int crypto_sha3_update(struct shash_desc *desc, const u8 *data,
162 unsigned int len) 163 unsigned int len)
163{ 164{
164 struct sha3_state *sctx = shash_desc_ctx(desc); 165 struct sha3_state *sctx = shash_desc_ctx(desc);
@@ -194,8 +195,9 @@ static int sha3_update(struct shash_desc *desc, const u8 *data,
194 195
195 return 0; 196 return 0;
196} 197}
198EXPORT_SYMBOL(crypto_sha3_update);
197 199
198static int sha3_final(struct shash_desc *desc, u8 *out) 200int crypto_sha3_final(struct shash_desc *desc, u8 *out)
199{ 201{
200 struct sha3_state *sctx = shash_desc_ctx(desc); 202 struct sha3_state *sctx = shash_desc_ctx(desc);
201 unsigned int i, inlen = sctx->partial; 203 unsigned int i, inlen = sctx->partial;
@@ -220,12 +222,13 @@ static int sha3_final(struct shash_desc *desc, u8 *out)
220 memset(sctx, 0, sizeof(*sctx)); 222 memset(sctx, 0, sizeof(*sctx));
221 return 0; 223 return 0;
222} 224}
225EXPORT_SYMBOL(crypto_sha3_final);
223 226
224static struct shash_alg algs[] = { { 227static struct shash_alg algs[] = { {
225 .digestsize = SHA3_224_DIGEST_SIZE, 228 .digestsize = SHA3_224_DIGEST_SIZE,
226 .init = sha3_init, 229 .init = crypto_sha3_init,
227 .update = sha3_update, 230 .update = crypto_sha3_update,
228 .final = sha3_final, 231 .final = crypto_sha3_final,
229 .descsize = sizeof(struct sha3_state), 232 .descsize = sizeof(struct sha3_state),
230 .base.cra_name = "sha3-224", 233 .base.cra_name = "sha3-224",
231 .base.cra_driver_name = "sha3-224-generic", 234 .base.cra_driver_name = "sha3-224-generic",
@@ -234,9 +237,9 @@ static struct shash_alg algs[] = { {
234 .base.cra_module = THIS_MODULE, 237 .base.cra_module = THIS_MODULE,
235}, { 238}, {
236 .digestsize = SHA3_256_DIGEST_SIZE, 239 .digestsize = SHA3_256_DIGEST_SIZE,
237 .init = sha3_init, 240 .init = crypto_sha3_init,
238 .update = sha3_update, 241 .update = crypto_sha3_update,
239 .final = sha3_final, 242 .final = crypto_sha3_final,
240 .descsize = sizeof(struct sha3_state), 243 .descsize = sizeof(struct sha3_state),
241 .base.cra_name = "sha3-256", 244 .base.cra_name = "sha3-256",
242 .base.cra_driver_name = "sha3-256-generic", 245 .base.cra_driver_name = "sha3-256-generic",
@@ -245,9 +248,9 @@ static struct shash_alg algs[] = { {
245 .base.cra_module = THIS_MODULE, 248 .base.cra_module = THIS_MODULE,
246}, { 249}, {
247 .digestsize = SHA3_384_DIGEST_SIZE, 250 .digestsize = SHA3_384_DIGEST_SIZE,
248 .init = sha3_init, 251 .init = crypto_sha3_init,
249 .update = sha3_update, 252 .update = crypto_sha3_update,
250 .final = sha3_final, 253 .final = crypto_sha3_final,
251 .descsize = sizeof(struct sha3_state), 254 .descsize = sizeof(struct sha3_state),
252 .base.cra_name = "sha3-384", 255 .base.cra_name = "sha3-384",
253 .base.cra_driver_name = "sha3-384-generic", 256 .base.cra_driver_name = "sha3-384-generic",
@@ -256,9 +259,9 @@ static struct shash_alg algs[] = { {
256 .base.cra_module = THIS_MODULE, 259 .base.cra_module = THIS_MODULE,
257}, { 260}, {
258 .digestsize = SHA3_512_DIGEST_SIZE, 261 .digestsize = SHA3_512_DIGEST_SIZE,
259 .init = sha3_init, 262 .init = crypto_sha3_init,
260 .update = sha3_update, 263 .update = crypto_sha3_update,
261 .final = sha3_final, 264 .final = crypto_sha3_final,
262 .descsize = sizeof(struct sha3_state), 265 .descsize = sizeof(struct sha3_state),
263 .base.cra_name = "sha3-512", 266 .base.cra_name = "sha3-512",
264 .base.cra_driver_name = "sha3-512-generic", 267 .base.cra_driver_name = "sha3-512-generic",