Release 4.14 arch/s390/crypto/ghash_s390.c
/*
* Cryptographic API.
*
* s390 implementation of the GHASH algorithm for GCM (Galois/Counter Mode).
*
* Copyright IBM Corp. 2011
* Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
*/
#include <crypto/internal/hash.h>
#include <linux/module.h>
#include <linux/cpufeature.h>
#include <asm/cpacf.h>
#define GHASH_BLOCK_SIZE 16
#define GHASH_DIGEST_SIZE 16
struct ghash_ctx {
u8 key[GHASH_BLOCK_SIZE];
};
struct ghash_desc_ctx {
u8 icv[GHASH_BLOCK_SIZE];
u8 key[GHASH_BLOCK_SIZE];
u8 buffer[GHASH_BLOCK_SIZE];
u32 bytes;
};
static int ghash_init(struct shash_desc *desc)
{
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
memset(dctx, 0, sizeof(*dctx));
memcpy(dctx->key, ctx->key, GHASH_BLOCK_SIZE);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 37 | 59.68% | 1 | 50.00% |
Harald Freudenberger | 25 | 40.32% | 1 | 50.00% |
Total | 62 | 100.00% | 2 | 100.00% |
static int ghash_setkey(struct crypto_shash *tfm,
const u8 *key, unsigned int keylen)
{
struct ghash_ctx *ctx = crypto_shash_ctx(tfm);
if (keylen != GHASH_BLOCK_SIZE) {
crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
return -EINVAL;
}
memcpy(ctx->key, key, GHASH_BLOCK_SIZE);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 63 | 100.00% | 1 | 100.00% |
Total | 63 | 100.00% | 1 | 100.00% |
static int ghash_update(struct shash_desc *desc,
const u8 *src, unsigned int srclen)
{
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
unsigned int n;
u8 *buf = dctx->buffer;
if (dctx->bytes) {
u8 *pos = buf + (GHASH_BLOCK_SIZE - dctx->bytes);
n = min(srclen, dctx->bytes);
dctx->bytes -= n;
srclen -= n;
memcpy(pos, src, n);
src += n;
if (!dctx->bytes) {
cpacf_kimd(CPACF_KIMD_GHASH, dctx, buf,
GHASH_BLOCK_SIZE);
}
}
n = srclen & ~(GHASH_BLOCK_SIZE - 1);
if (n) {
cpacf_kimd(CPACF_KIMD_GHASH, dctx, src, n);
src += n;
srclen -= n;
}
if (srclen) {
dctx->bytes = GHASH_BLOCK_SIZE - srclen;
memcpy(buf, src, srclen);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 174 | 96.67% | 1 | 33.33% |
Martin Schwidefsky | 4 | 2.22% | 1 | 33.33% |
Harald Freudenberger | 2 | 1.11% | 1 | 33.33% |
Total | 180 | 100.00% | 3 | 100.00% |
static int ghash_flush(struct ghash_desc_ctx *dctx)
{
u8 *buf = dctx->buffer;
if (dctx->bytes) {
u8 *pos = buf + (GHASH_BLOCK_SIZE - dctx->bytes);
memset(pos, 0, dctx->bytes);
cpacf_kimd(CPACF_KIMD_GHASH, dctx, buf, GHASH_BLOCK_SIZE);
dctx->bytes = 0;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 64 | 88.89% | 1 | 25.00% |
Jan Glauber | 4 | 5.56% | 1 | 25.00% |
Harald Freudenberger | 2 | 2.78% | 1 | 25.00% |
Martin Schwidefsky | 2 | 2.78% | 1 | 25.00% |
Total | 72 | 100.00% | 4 | 100.00% |
static int ghash_final(struct shash_desc *desc, u8 *dst)
{
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
int ret;
ret = ghash_flush(dctx);
if (!ret)
memcpy(dst, dctx->icv, GHASH_BLOCK_SIZE);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 42 | 77.78% | 1 | 33.33% |
Jan Glauber | 11 | 20.37% | 1 | 33.33% |
Harald Freudenberger | 1 | 1.85% | 1 | 33.33% |
Total | 54 | 100.00% | 3 | 100.00% |
static struct shash_alg ghash_alg = {
.digestsize = GHASH_DIGEST_SIZE,
.init = ghash_init,
.update = ghash_update,
.final = ghash_final,
.setkey = ghash_setkey,
.descsize = sizeof(struct ghash_desc_ctx),
.base = {
.cra_name = "ghash",
.cra_driver_name = "ghash-s390",
.cra_priority = 300,
.cra_flags = CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize = GHASH_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct ghash_ctx),
.cra_module = THIS_MODULE,
},
};
static int __init ghash_mod_init(void)
{
if (!cpacf_query_func(CPACF_KIMD, CPACF_KIMD_GHASH))
return -EOPNOTSUPP;
return crypto_register_shash(&ghash_alg);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 27 | 90.00% | 1 | 33.33% |
Martin Schwidefsky | 3 | 10.00% | 2 | 66.67% |
Total | 30 | 100.00% | 3 | 100.00% |
static void __exit ghash_mod_exit(void)
{
crypto_unregister_shash(&ghash_alg);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 15 | 100.00% | 1 | 100.00% |
Total | 15 | 100.00% | 1 | 100.00% |
module_cpu_feature_match(MSA, ghash_mod_init);
module_exit(ghash_mod_exit);
MODULE_ALIAS_CRYPTO("ghash");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GHASH Message Digest Algorithm, s390 implementation");
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerald Schaefer | 570 | 88.24% | 1 | 14.29% |
Harald Freudenberger | 43 | 6.66% | 1 | 14.29% |
Jan Glauber | 15 | 2.32% | 1 | 14.29% |
Martin Schwidefsky | 11 | 1.70% | 2 | 28.57% |
Hendrik Brueckner | 6 | 0.93% | 1 | 14.29% |
Kees Cook | 1 | 0.15% | 1 | 14.29% |
Total | 646 | 100.00% | 7 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.