2 * sha512-glue.c - accelerated SHA-384/512 for ARM
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>
17 #include <asm/hwcap.h>
22 MODULE_DESCRIPTION("Accelerated SHA-384/SHA-512 secure hash for ARM");
23 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
24 MODULE_LICENSE("GPL v2");
26 MODULE_ALIAS_CRYPTO("sha384");
27 MODULE_ALIAS_CRYPTO("sha512");
28 MODULE_ALIAS_CRYPTO("sha384-arm");
29 MODULE_ALIAS_CRYPTO("sha512-arm");
31 asmlinkage
void sha512_block_data_order(u64
*state
, u8
const *src
, int blocks
);
33 int sha512_arm_update(struct shash_desc
*desc
, const u8
*data
,
36 return sha512_base_do_update(desc
, data
, len
,
37 (sha512_block_fn
*)sha512_block_data_order
);
40 int sha512_arm_final(struct shash_desc
*desc
, u8
*out
)
42 sha512_base_do_finalize(desc
,
43 (sha512_block_fn
*)sha512_block_data_order
);
44 return sha512_base_finish(desc
, out
);
47 int sha512_arm_finup(struct shash_desc
*desc
, const u8
*data
,
48 unsigned int len
, u8
*out
)
50 sha512_base_do_update(desc
, data
, len
,
51 (sha512_block_fn
*)sha512_block_data_order
);
52 return sha512_arm_final(desc
, out
);
55 static struct shash_alg sha512_arm_algs
[] = { {
56 .init
= sha384_base_init
,
57 .update
= sha512_arm_update
,
58 .final
= sha512_arm_final
,
59 .finup
= sha512_arm_finup
,
60 .descsize
= sizeof(struct sha512_state
),
61 .digestsize
= SHA384_DIGEST_SIZE
,
64 .cra_driver_name
= "sha384-arm",
66 .cra_blocksize
= SHA512_BLOCK_SIZE
,
67 .cra_module
= THIS_MODULE
,
70 .init
= sha512_base_init
,
71 .update
= sha512_arm_update
,
72 .final
= sha512_arm_final
,
73 .finup
= sha512_arm_finup
,
74 .descsize
= sizeof(struct sha512_state
),
75 .digestsize
= SHA512_DIGEST_SIZE
,
78 .cra_driver_name
= "sha512-arm",
80 .cra_blocksize
= SHA512_BLOCK_SIZE
,
81 .cra_module
= THIS_MODULE
,
85 static int __init
sha512_arm_mod_init(void)
89 err
= crypto_register_shashes(sha512_arm_algs
,
90 ARRAY_SIZE(sha512_arm_algs
));
94 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON
) && cpu_has_neon()) {
95 err
= crypto_register_shashes(sha512_neon_algs
,
96 ARRAY_SIZE(sha512_neon_algs
));
103 crypto_unregister_shashes(sha512_arm_algs
,
104 ARRAY_SIZE(sha512_arm_algs
));
109 static void __exit
sha512_arm_mod_fini(void)
111 crypto_unregister_shashes(sha512_arm_algs
,
112 ARRAY_SIZE(sha512_arm_algs
));
113 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON
) && cpu_has_neon())
114 crypto_unregister_shashes(sha512_neon_algs
,
115 ARRAY_SIZE(sha512_neon_algs
));
118 module_init(sha512_arm_mod_init
);
119 module_exit(sha512_arm_mod_fini
);