4 * s390 implementation of the SHA1 Secure Hash Algorithm.
6 * Derived from cryptoapi implementation, adapted for in-place
7 * scatterlist interface. Originally based on the public domain
8 * implementation written by Steve Reid.
11 * Copyright IBM Corp. 2003,2007
12 * Author(s): Thomas Spatzier
13 * Jan Glauber (jan.glauber@de.ibm.com)
15 * Derived from "crypto/sha1_generic.c"
16 * Copyright (c) Alan Smithee.
17 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
18 * Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
20 * This program is free software; you can redistribute it and/or modify it
21 * under the terms of the GNU General Public License as published by the Free
22 * Software Foundation; either version 2 of the License, or (at your option)
26 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/crypto.h>
29 #include <crypto/sha.h>
31 #include "crypt_s390.h"
34 static void sha1_init(struct crypto_tfm *tfm)
36 struct s390_sha_ctx *sctx = crypto_tfm_ctx(tfm);
38 sctx->state[0] = SHA1_H0;
39 sctx->state[1] = SHA1_H1;
40 sctx->state[2] = SHA1_H2;
41 sctx->state[3] = SHA1_H3;
42 sctx->state[4] = SHA1_H4;
44 sctx->func = KIMD_SHA_1;
47 static struct crypto_alg alg = {
49 .cra_driver_name= "sha1-s390",
50 .cra_priority = CRYPT_S390_PRIORITY,
51 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
52 .cra_blocksize = SHA1_BLOCK_SIZE,
53 .cra_ctxsize = sizeof(struct s390_sha_ctx),
54 .cra_module = THIS_MODULE,
55 .cra_list = LIST_HEAD_INIT(alg.cra_list),
56 .cra_u = { .digest = {
57 .dia_digestsize = SHA1_DIGEST_SIZE,
58 .dia_init = sha1_init,
59 .dia_update = s390_sha_update,
60 .dia_final = s390_sha_final } }
63 static int __init sha1_s390_init(void)
65 if (!crypt_s390_func_available(KIMD_SHA_1))
67 return crypto_register_alg(&alg);
70 static void __exit sha1_s390_fini(void)
72 crypto_unregister_alg(&alg);
75 module_init(sha1_s390_init);
76 module_exit(sha1_s390_fini);
79 MODULE_LICENSE("GPL");
80 MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");