2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Cryptographic API.
|
|
|
|
*
|
2006-01-06 16:19:17 +08:00
|
|
|
* s390 implementation of the SHA1 Secure Hash Algorithm.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Derived from cryptoapi implementation, adapted for in-place
|
|
|
|
* scatterlist interface. Originally based on the public domain
|
|
|
|
* implementation written by Steve Reid.
|
|
|
|
*
|
|
|
|
* s390 Version:
|
2007-02-06 04:18:14 +08:00
|
|
|
* Copyright IBM Corp. 2003,2007
|
|
|
|
* Author(s): Thomas Spatzier
|
|
|
|
* Jan Glauber (jan.glauber@de.ibm.com)
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2007-10-08 11:45:10 +08:00
|
|
|
* Derived from "crypto/sha1_generic.c"
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (c) Alan Smithee.
|
|
|
|
* Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
|
|
|
|
* Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/crypto.h>
|
2007-10-09 22:43:13 +08:00
|
|
|
#include <crypto/sha.h>
|
2007-04-27 22:01:54 +08:00
|
|
|
|
2006-01-06 16:19:17 +08:00
|
|
|
#include "crypt_s390.h"
|
2008-03-06 19:50:20 +08:00
|
|
|
#include "sha.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-05-16 20:09:29 +08:00
|
|
|
static void sha1_init(struct crypto_tfm *tfm)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-03-06 19:50:20 +08:00
|
|
|
struct s390_sha_ctx *sctx = crypto_tfm_ctx(tfm);
|
2007-04-27 22:01:54 +08:00
|
|
|
|
2007-10-09 22:43:13 +08:00
|
|
|
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;
|
2007-04-27 22:01:54 +08:00
|
|
|
sctx->count = 0;
|
2008-03-06 19:50:20 +08:00
|
|
|
sctx->func = KIMD_SHA_1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct crypto_alg alg = {
|
|
|
|
.cra_name = "sha1",
|
2007-02-06 04:18:14 +08:00
|
|
|
.cra_driver_name= "sha1-s390",
|
2006-08-21 19:18:50 +08:00
|
|
|
.cra_priority = CRYPT_S390_PRIORITY,
|
2005-04-17 06:20:36 +08:00
|
|
|
.cra_flags = CRYPTO_ALG_TYPE_DIGEST,
|
|
|
|
.cra_blocksize = SHA1_BLOCK_SIZE,
|
2008-03-06 19:50:20 +08:00
|
|
|
.cra_ctxsize = sizeof(struct s390_sha_ctx),
|
2005-04-17 06:20:36 +08:00
|
|
|
.cra_module = THIS_MODULE,
|
2007-02-06 04:18:14 +08:00
|
|
|
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
2005-04-17 06:20:36 +08:00
|
|
|
.cra_u = { .digest = {
|
|
|
|
.dia_digestsize = SHA1_DIGEST_SIZE,
|
2007-02-06 04:18:14 +08:00
|
|
|
.dia_init = sha1_init,
|
2008-03-06 19:50:20 +08:00
|
|
|
.dia_update = s390_sha_update,
|
|
|
|
.dia_final = s390_sha_final } }
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2008-04-17 13:46:17 +08:00
|
|
|
static int __init sha1_s390_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-06 04:18:14 +08:00
|
|
|
if (!crypt_s390_func_available(KIMD_SHA_1))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
return crypto_register_alg(&alg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-04-17 13:46:17 +08:00
|
|
|
static void __exit sha1_s390_fini(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
crypto_unregister_alg(&alg);
|
|
|
|
}
|
|
|
|
|
2008-04-17 13:46:17 +08:00
|
|
|
module_init(sha1_s390_init);
|
|
|
|
module_exit(sha1_s390_fini);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
MODULE_ALIAS("sha1");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");
|