2 * sha512-neon-glue.c - accelerated SHA-384/512 for ARM NEON
4 * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <crypto/internal/hash.h>
12 #include <crypto/sha.h>
13 #include <crypto/sha512_base.h>
14 #include <linux/crypto.h>
15 #include <linux/module.h>
22 MODULE_ALIAS_CRYPTO("sha384-neon");
23 MODULE_ALIAS_CRYPTO("sha512-neon");
25 asmlinkage
void sha512_block_data_order_neon(u64
*state
, u8
const *src
,
28 static int sha512_neon_update(struct shash_desc
*desc
, const u8
*data
,
31 struct sha512_state
*sctx
= shash_desc_ctx(desc
);
33 if (!may_use_simd() ||
34 (sctx
->count
[0] % SHA512_BLOCK_SIZE
) + len
< SHA512_BLOCK_SIZE
)
35 return sha512_arm_update(desc
, data
, len
);
38 sha512_base_do_update(desc
, data
, len
,
39 (sha512_block_fn
*)sha512_block_data_order_neon
);
45 static int sha512_neon_finup(struct shash_desc
*desc
, const u8
*data
,
46 unsigned int len
, u8
*out
)
49 return sha512_arm_finup(desc
, data
, len
, out
);
53 sha512_base_do_update(desc
, data
, len
,
54 (sha512_block_fn
*)sha512_block_data_order_neon
);
55 sha512_base_do_finalize(desc
,
56 (sha512_block_fn
*)sha512_block_data_order_neon
);
59 return sha512_base_finish(desc
, out
);
62 static int sha512_neon_final(struct shash_desc
*desc
, u8
*out
)
64 return sha512_neon_finup(desc
, NULL
, 0, out
);
67 struct shash_alg sha512_neon_algs
[] = { {
68 .init
= sha384_base_init
,
69 .update
= sha512_neon_update
,
70 .final
= sha512_neon_final
,
71 .finup
= sha512_neon_finup
,
72 .descsize
= sizeof(struct sha512_state
),
73 .digestsize
= SHA384_DIGEST_SIZE
,
76 .cra_driver_name
= "sha384-neon",
78 .cra_flags
= CRYPTO_ALG_TYPE_SHASH
,
79 .cra_blocksize
= SHA384_BLOCK_SIZE
,
80 .cra_module
= THIS_MODULE
,
84 .init
= sha512_base_init
,
85 .update
= sha512_neon_update
,
86 .final
= sha512_neon_final
,
87 .finup
= sha512_neon_finup
,
88 .descsize
= sizeof(struct sha512_state
),
89 .digestsize
= SHA512_DIGEST_SIZE
,
92 .cra_driver_name
= "sha512-neon",
94 .cra_flags
= CRYPTO_ALG_TYPE_SHASH
,
95 .cra_blocksize
= SHA512_BLOCK_SIZE
,
96 .cra_module
= THIS_MODULE
,