drm/panel: samsung-s6e88a0-ams452ef01: transition to mipi_dsi wrapped functions
[drm/drm-misc.git] / arch / arm / crypto / sha512-glue.c
blob1be5bd498af36fb710d671228326af983e811903
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * sha512-glue.c - accelerated SHA-384/512 for ARM
5 * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
6 */
8 #include <crypto/internal/hash.h>
9 #include <crypto/sha2.h>
10 #include <crypto/sha512_base.h>
11 #include <linux/crypto.h>
12 #include <linux/module.h>
14 #include <asm/hwcap.h>
15 #include <asm/neon.h>
17 #include "sha512.h"
19 MODULE_DESCRIPTION("Accelerated SHA-384/SHA-512 secure hash for ARM");
20 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
21 MODULE_LICENSE("GPL v2");
23 MODULE_ALIAS_CRYPTO("sha384");
24 MODULE_ALIAS_CRYPTO("sha512");
25 MODULE_ALIAS_CRYPTO("sha384-arm");
26 MODULE_ALIAS_CRYPTO("sha512-arm");
28 asmlinkage void sha512_block_data_order(struct sha512_state *state,
29 u8 const *src, int blocks);
31 int sha512_arm_update(struct shash_desc *desc, const u8 *data,
32 unsigned int len)
34 return sha512_base_do_update(desc, data, len, sha512_block_data_order);
37 static int sha512_arm_final(struct shash_desc *desc, u8 *out)
39 sha512_base_do_finalize(desc, sha512_block_data_order);
40 return sha512_base_finish(desc, out);
43 int sha512_arm_finup(struct shash_desc *desc, const u8 *data,
44 unsigned int len, u8 *out)
46 sha512_base_do_update(desc, data, len, sha512_block_data_order);
47 return sha512_arm_final(desc, out);
50 static struct shash_alg sha512_arm_algs[] = { {
51 .init = sha384_base_init,
52 .update = sha512_arm_update,
53 .final = sha512_arm_final,
54 .finup = sha512_arm_finup,
55 .descsize = sizeof(struct sha512_state),
56 .digestsize = SHA384_DIGEST_SIZE,
57 .base = {
58 .cra_name = "sha384",
59 .cra_driver_name = "sha384-arm",
60 .cra_priority = 250,
61 .cra_blocksize = SHA512_BLOCK_SIZE,
62 .cra_module = THIS_MODULE,
64 }, {
65 .init = sha512_base_init,
66 .update = sha512_arm_update,
67 .final = sha512_arm_final,
68 .finup = sha512_arm_finup,
69 .descsize = sizeof(struct sha512_state),
70 .digestsize = SHA512_DIGEST_SIZE,
71 .base = {
72 .cra_name = "sha512",
73 .cra_driver_name = "sha512-arm",
74 .cra_priority = 250,
75 .cra_blocksize = SHA512_BLOCK_SIZE,
76 .cra_module = THIS_MODULE,
78 } };
80 static int __init sha512_arm_mod_init(void)
82 int err;
84 err = crypto_register_shashes(sha512_arm_algs,
85 ARRAY_SIZE(sha512_arm_algs));
86 if (err)
87 return err;
89 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && cpu_has_neon()) {
90 err = crypto_register_shashes(sha512_neon_algs,
91 ARRAY_SIZE(sha512_neon_algs));
92 if (err)
93 goto err_unregister;
95 return 0;
97 err_unregister:
98 crypto_unregister_shashes(sha512_arm_algs,
99 ARRAY_SIZE(sha512_arm_algs));
101 return err;
104 static void __exit sha512_arm_mod_fini(void)
106 crypto_unregister_shashes(sha512_arm_algs,
107 ARRAY_SIZE(sha512_arm_algs));
108 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && cpu_has_neon())
109 crypto_unregister_shashes(sha512_neon_algs,
110 ARRAY_SIZE(sha512_neon_algs));
113 module_init(sha512_arm_mod_init);
114 module_exit(sha512_arm_mod_fini);