Merge tag 'firewire-updates-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-block.git] / arch / arm / crypto / sha1_glue.c
CommitLineData
2874c5fd 1// SPDX-License-Identifier: GPL-2.0-or-later
f0be44f4
DM
2/*
3 * Cryptographic API.
4 * Glue code for the SHA1 Secure Hash Algorithm assembler implementation
5 *
6 * This file is based on sha1_generic.c and sha1_ssse3_glue.c
7 *
8 * Copyright (c) Alan Smithee.
9 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
10 * Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
11 * Copyright (c) Mathias Krause <minipli@googlemail.com>
f0be44f4
DM
12 */
13
14#include <crypto/internal/hash.h>
15#include <linux/init.h>
16#include <linux/module.h>
f0be44f4 17#include <linux/types.h>
a24d22b2 18#include <crypto/sha1.h>
90451d6b 19#include <crypto/sha1_base.h>
f0be44f4
DM
20#include <asm/byteorder.h>
21
90451d6b 22#include "sha1.h"
f0be44f4 23
b517b0fb
HX
24asmlinkage void sha1_block_data_order(struct sha1_state *digest,
25 const u8 *data, int rounds);
f0be44f4 26
60468255
JK
27int sha1_update_arm(struct shash_desc *desc, const u8 *data,
28 unsigned int len)
f0be44f4 29{
b517b0fb 30 /* make sure signature matches sha1_block_fn() */
90451d6b 31 BUILD_BUG_ON(offsetof(struct sha1_state, state) != 0);
f0be44f4 32
b517b0fb 33 return sha1_base_do_update(desc, data, len, sha1_block_data_order);
f0be44f4 34}
60468255 35EXPORT_SYMBOL_GPL(sha1_update_arm);
f0be44f4 36
f0be44f4
DM
37static int sha1_final(struct shash_desc *desc, u8 *out)
38{
b517b0fb 39 sha1_base_do_finalize(desc, sha1_block_data_order);
90451d6b 40 return sha1_base_finish(desc, out);
f0be44f4
DM
41}
42
90451d6b
AB
43int sha1_finup_arm(struct shash_desc *desc, const u8 *data,
44 unsigned int len, u8 *out)
f0be44f4 45{
b517b0fb 46 sha1_base_do_update(desc, data, len, sha1_block_data_order);
90451d6b 47 return sha1_final(desc, out);
f0be44f4 48}
90451d6b 49EXPORT_SYMBOL_GPL(sha1_finup_arm);
f0be44f4
DM
50
51static struct shash_alg alg = {
52 .digestsize = SHA1_DIGEST_SIZE,
90451d6b 53 .init = sha1_base_init,
60468255 54 .update = sha1_update_arm,
f0be44f4 55 .final = sha1_final,
90451d6b 56 .finup = sha1_finup_arm,
1f8673d3 57 .descsize = sizeof(struct sha1_state),
f0be44f4
DM
58 .base = {
59 .cra_name = "sha1",
60 .cra_driver_name= "sha1-asm",
61 .cra_priority = 150,
f0be44f4
DM
62 .cra_blocksize = SHA1_BLOCK_SIZE,
63 .cra_module = THIS_MODULE,
64 }
65};
66
67
68static int __init sha1_mod_init(void)
69{
70 return crypto_register_shash(&alg);
71}
72
73
74static void __exit sha1_mod_fini(void)
75{
76 crypto_unregister_shash(&alg);
77}
78
79
80module_init(sha1_mod_init);
81module_exit(sha1_mod_fini);
82
83MODULE_LICENSE("GPL");
84MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm (ARM)");
5d26a105 85MODULE_ALIAS_CRYPTO("sha1");
f0be44f4 86MODULE_AUTHOR("David McCullough <ucdevel@gmail.com>");