crypto: shash - Add crypto_shash_blocksize
[deliverable/linux.git] / arch / s390 / crypto / sha256_s390.c
CommitLineData
0a497c17
JG
1/*
2 * Cryptographic API.
3 *
4 * s390 implementation of the SHA256 Secure Hash Algorithm.
5 *
6 * s390 Version:
86aa9fc2 7 * Copyright IBM Corp. 2005,2007
0a497c17
JG
8 * Author(s): Jan Glauber (jang@de.ibm.com)
9 *
ad5d2789 10 * Derived from "crypto/sha256_generic.c"
0a497c17
JG
11 * and "arch/s390/crypto/sha1_s390.c"
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 *
18 */
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/crypto.h>
5265eeb2 22#include <crypto/sha.h>
0a497c17
JG
23
24#include "crypt_s390.h"
604973f1 25#include "sha.h"
0a497c17 26
6c2bb98b 27static void sha256_init(struct crypto_tfm *tfm)
0a497c17 28{
604973f1 29 struct s390_sha_ctx *sctx = crypto_tfm_ctx(tfm);
0a497c17 30
5265eeb2
JG
31 sctx->state[0] = SHA256_H0;
32 sctx->state[1] = SHA256_H1;
33 sctx->state[2] = SHA256_H2;
34 sctx->state[3] = SHA256_H3;
35 sctx->state[4] = SHA256_H4;
36 sctx->state[5] = SHA256_H5;
37 sctx->state[6] = SHA256_H6;
38 sctx->state[7] = SHA256_H7;
0a497c17 39 sctx->count = 0;
604973f1 40 sctx->func = KIMD_SHA_256;
0a497c17
JG
41}
42
43static struct crypto_alg alg = {
44 .cra_name = "sha256",
65b75c36
HX
45 .cra_driver_name = "sha256-s390",
46 .cra_priority = CRYPT_S390_PRIORITY,
0a497c17
JG
47 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
48 .cra_blocksize = SHA256_BLOCK_SIZE,
604973f1 49 .cra_ctxsize = sizeof(struct s390_sha_ctx),
0a497c17
JG
50 .cra_module = THIS_MODULE,
51 .cra_list = LIST_HEAD_INIT(alg.cra_list),
52 .cra_u = { .digest = {
53 .dia_digestsize = SHA256_DIGEST_SIZE,
7ffbc9da 54 .dia_init = sha256_init,
604973f1
JG
55 .dia_update = s390_sha_update,
56 .dia_final = s390_sha_final } }
0a497c17
JG
57};
58
9f7819c1 59static int sha256_s390_init(void)
0a497c17 60{
0a497c17 61 if (!crypt_s390_func_available(KIMD_SHA_256))
86aa9fc2 62 return -EOPNOTSUPP;
0a497c17 63
86aa9fc2 64 return crypto_register_alg(&alg);
0a497c17
JG
65}
66
9f7819c1 67static void __exit sha256_s390_fini(void)
0a497c17
JG
68{
69 crypto_unregister_alg(&alg);
70}
71
9f7819c1
HC
72module_init(sha256_s390_init);
73module_exit(sha256_s390_fini);
0a497c17
JG
74
75MODULE_ALIAS("sha256");
0a497c17
JG
76MODULE_LICENSE("GPL");
77MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm");
This page took 0.330411 seconds and 5 git commands to generate.