Blame view
arch/s390/crypto/sha1_s390.c
2.55 KB
9fa1db4c7 s390: add a few m... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 |
/* * Cryptographic API. * |
c1e26e1ef [PATCH] s390: in-... |
5 |
* s390 implementation of the SHA1 Secure Hash Algorithm. |
1da177e4c Linux-2.6.12-rc2 |
6 7 8 9 10 11 |
* * Derived from cryptoapi implementation, adapted for in-place * scatterlist interface. Originally based on the public domain * implementation written by Steve Reid. * * s390 Version: |
a53c8fab3 s390/comments: un... |
12 |
* Copyright IBM Corp. 2003, 2007 |
86aa9fc24 [S390] move crypt... |
13 14 |
* Author(s): Thomas Spatzier * Jan Glauber (jan.glauber@de.ibm.com) |
1da177e4c Linux-2.6.12-rc2 |
15 |
* |
ad5d27899 [CRYPTO] sha: Loa... |
16 |
* Derived from "crypto/sha1_generic.c" |
1da177e4c Linux-2.6.12-rc2 |
17 18 19 |
* Copyright (c) Alan Smithee. * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk> * Copyright (c) Jean-Francois Dive <jef@linuxbe.org> |
1da177e4c Linux-2.6.12-rc2 |
20 |
*/ |
563f346d0 crypto: sha-s390 ... |
21 |
#include <crypto/internal/hash.h> |
1da177e4c Linux-2.6.12-rc2 |
22 23 |
#include <linux/init.h> #include <linux/module.h> |
d05377c12 s390/crypto: add ... |
24 |
#include <linux/cpufeature.h> |
5265eeb2b [CRYPTO] sha: Add... |
25 |
#include <crypto/sha.h> |
c7d4d259b s390/crypto: clea... |
26 |
#include <asm/cpacf.h> |
131a395c1 [S390] crypto: cl... |
27 |
|
604973f1f [CRYPTO] s390: Ge... |
28 |
#include "sha.h" |
1da177e4c Linux-2.6.12-rc2 |
29 |
|
4d21e5945 crypto: s390/sha1... |
30 |
static int s390_sha1_init(struct shash_desc *desc) |
1da177e4c Linux-2.6.12-rc2 |
31 |
{ |
563f346d0 crypto: sha-s390 ... |
32 |
struct s390_sha_ctx *sctx = shash_desc_ctx(desc); |
131a395c1 [S390] crypto: cl... |
33 |
|
5265eeb2b [CRYPTO] sha: Add... |
34 35 36 37 38 |
sctx->state[0] = SHA1_H0; sctx->state[1] = SHA1_H1; sctx->state[2] = SHA1_H2; sctx->state[3] = SHA1_H3; sctx->state[4] = SHA1_H4; |
131a395c1 [S390] crypto: cl... |
39 |
sctx->count = 0; |
c7d4d259b s390/crypto: clea... |
40 |
sctx->func = CPACF_KIMD_SHA_1; |
563f346d0 crypto: sha-s390 ... |
41 42 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
43 |
} |
4d21e5945 crypto: s390/sha1... |
44 |
static int s390_sha1_export(struct shash_desc *desc, void *out) |
406f104b4 crypto: sha1-s390... |
45 46 47 48 49 50 51 52 53 |
{ struct s390_sha_ctx *sctx = shash_desc_ctx(desc); struct sha1_state *octx = out; octx->count = sctx->count; memcpy(octx->state, sctx->state, sizeof(octx->state)); memcpy(octx->buffer, sctx->buf, sizeof(octx->buffer)); return 0; } |
4d21e5945 crypto: s390/sha1... |
54 |
static int s390_sha1_import(struct shash_desc *desc, const void *in) |
406f104b4 crypto: sha1-s390... |
55 |
{ |
2a549c364 crypto: s390 - Fi... |
56 |
struct s390_sha_ctx *sctx = shash_desc_ctx(desc); |
81bd5f6c9 crypto: sha-s390 ... |
57 |
const struct sha1_state *ictx = in; |
406f104b4 crypto: sha1-s390... |
58 59 60 61 |
sctx->count = ictx->count; memcpy(sctx->state, ictx->state, sizeof(ictx->state)); memcpy(sctx->buf, ictx->buffer, sizeof(ictx->buffer)); |
c7d4d259b s390/crypto: clea... |
62 |
sctx->func = CPACF_KIMD_SHA_1; |
406f104b4 crypto: sha1-s390... |
63 64 |
return 0; } |
563f346d0 crypto: sha-s390 ... |
65 66 |
static struct shash_alg alg = { .digestsize = SHA1_DIGEST_SIZE, |
4d21e5945 crypto: s390/sha1... |
67 |
.init = s390_sha1_init, |
563f346d0 crypto: sha-s390 ... |
68 69 |
.update = s390_sha_update, .final = s390_sha_final, |
4d21e5945 crypto: s390/sha1... |
70 71 |
.export = s390_sha1_export, .import = s390_sha1_import, |
563f346d0 crypto: sha-s390 ... |
72 |
.descsize = sizeof(struct s390_sha_ctx), |
406f104b4 crypto: sha1-s390... |
73 |
.statesize = sizeof(struct sha1_state), |
563f346d0 crypto: sha-s390 ... |
74 75 76 |
.base = { .cra_name = "sha1", .cra_driver_name= "sha1-s390", |
c7d4d259b s390/crypto: clea... |
77 |
.cra_priority = 300, |
563f346d0 crypto: sha-s390 ... |
78 79 80 |
.cra_blocksize = SHA1_BLOCK_SIZE, .cra_module = THIS_MODULE, } |
1da177e4c Linux-2.6.12-rc2 |
81 |
}; |
9f7819c1e [S390] crypto: us... |
82 |
static int __init sha1_s390_init(void) |
1da177e4c Linux-2.6.12-rc2 |
83 |
{ |
69c0e360f s390/crypto: cpac... |
84 |
if (!cpacf_query_func(CPACF_KIMD, CPACF_KIMD_SHA_1)) |
45488c48e s390/crypto: sha:... |
85 |
return -ENODEV; |
563f346d0 crypto: sha-s390 ... |
86 |
return crypto_register_shash(&alg); |
1da177e4c Linux-2.6.12-rc2 |
87 |
} |
9f7819c1e [S390] crypto: us... |
88 |
static void __exit sha1_s390_fini(void) |
1da177e4c Linux-2.6.12-rc2 |
89 |
{ |
563f346d0 crypto: sha-s390 ... |
90 |
crypto_unregister_shash(&alg); |
1da177e4c Linux-2.6.12-rc2 |
91 |
} |
d05377c12 s390/crypto: add ... |
92 |
module_cpu_feature_match(MSA, sha1_s390_init); |
9f7819c1e [S390] crypto: us... |
93 |
module_exit(sha1_s390_fini); |
1da177e4c Linux-2.6.12-rc2 |
94 |
|
5d26a105b crypto: prefix mo... |
95 |
MODULE_ALIAS_CRYPTO("sha1"); |
1da177e4c Linux-2.6.12-rc2 |
96 97 |
MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm"); |