Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 46175
b: refs/heads/master
c: 86aa9fc
h: refs/heads/master
i:
  46173: ccec9b7
  46171: bd4ccbe
  46167: 382ef3f
  46159: 2fd6ada
  46143: b56e0b5
v: v3
  • Loading branch information
Jan Glauber authored and Martin Schwidefsky committed Feb 5, 2007
1 parent 541e8cf commit 2b93910
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 411 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 347d59d7e9739ff2acbaa751b6225ecb335c3f29
refs/heads/master: 86aa9fc2456d8a662f299a70bdb70987209170f0
60 changes: 60 additions & 0 deletions trunk/arch/s390/crypto/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
config CRYPTO_SHA1_S390
tristate "SHA1 digest algorithm"
depends on S390
select CRYPTO_ALGAPI
help
This is the s390 hardware accelerated implementation of the
SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).

config CRYPTO_SHA256_S390
tristate "SHA256 digest algorithm"
depends on S390
select CRYPTO_ALGAPI
help
This is the s390 hardware accelerated implementation of the
SHA256 secure hash standard (DFIPS 180-2).

This version of SHA implements a 256 bit hash with 128 bits of
security against collision attacks.

config CRYPTO_DES_S390
tristate "DES and Triple DES cipher algorithms"
depends on S390
select CRYPTO_ALGAPI
select CRYPTO_BLKCIPHER
help
This us the s390 hardware accelerated implementation of the
DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).

config CRYPTO_AES_S390
tristate "AES cipher algorithms"
depends on S390
select CRYPTO_ALGAPI
select CRYPTO_BLKCIPHER
help
This is the s390 hardware accelerated implementation of the
AES cipher algorithms (FIPS-197). AES uses the Rijndael
algorithm.

Rijndael appears to be consistently a very good performer in
both hardware and software across a wide range of computing
environments regardless of its use in feedback or non-feedback
modes. Its key setup time is excellent, and its key agility is
good. Rijndael's very low memory requirements make it very well
suited for restricted-space environments, in which it also
demonstrates excellent performance. Rijndael's operations are
among the easiest to defend against power and timing attacks.

On s390 the System z9-109 currently only supports the key size
of 128 bit.

config S390_PRNG
tristate "Pseudo random number generator device driver"
depends on S390
default "m"
help
Select this option if you want to use the s390 pseudo random number
generator. The PRNG is part of the cryptograhic processor functions
and uses triple-DES to generate secure random numbers like the
ANSI X9.17 standard. The PRNG is usable via the char device
/dev/prandom.
2 changes: 0 additions & 2 deletions trunk/arch/s390/crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o
obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o
obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o
obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o

obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o
47 changes: 23 additions & 24 deletions trunk/arch/s390/crypto/aes_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* s390 implementation of the AES Cipher Algorithm.
*
* s390 Version:
* Copyright (C) 2005 IBM Deutschland GmbH, IBM Corporation
* Copyright IBM Corp. 2005,2007
* Author(s): Jan Glauber (jang@de.ibm.com)
*
* Derived from "crypto/aes.c"
Expand All @@ -27,9 +27,11 @@
/* data block size for all key lengths */
#define AES_BLOCK_SIZE 16

static int has_aes_128 = 0;
static int has_aes_192 = 0;
static int has_aes_256 = 0;
#define AES_KEYLEN_128 1
#define AES_KEYLEN_192 2
#define AES_KEYLEN_256 4

static char keylen_flag = 0;

struct s390_aes_ctx {
u8 iv[AES_BLOCK_SIZE];
Expand All @@ -47,20 +49,19 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,

switch (key_len) {
case 16:
if (!has_aes_128)
if (!(keylen_flag & AES_KEYLEN_128))
goto fail;
break;
case 24:
if (!has_aes_192)
if (!(keylen_flag & AES_KEYLEN_192))
goto fail;

break;
case 32:
if (!has_aes_256)
if (!(keylen_flag & AES_KEYLEN_256))
goto fail;
break;
default:
/* invalid key length */
goto fail;
break;
}
Expand Down Expand Up @@ -322,34 +323,32 @@ static int __init aes_init(void)
int ret;

if (crypt_s390_func_available(KM_AES_128_ENCRYPT))
has_aes_128 = 1;
keylen_flag |= AES_KEYLEN_128;
if (crypt_s390_func_available(KM_AES_192_ENCRYPT))
has_aes_192 = 1;
keylen_flag |= AES_KEYLEN_192;
if (crypt_s390_func_available(KM_AES_256_ENCRYPT))
has_aes_256 = 1;
keylen_flag |= AES_KEYLEN_256;

if (!keylen_flag)
return -EOPNOTSUPP;

if (!has_aes_128 && !has_aes_192 && !has_aes_256)
return -ENOSYS;
/* z9 109 and z9 BC/EC only support 128 bit key length */
if (keylen_flag == AES_KEYLEN_128)
printk(KERN_INFO
"aes_s390: hardware acceleration only available for"
"128 bit keys\n");

ret = crypto_register_alg(&aes_alg);
if (ret != 0) {
printk(KERN_INFO "crypt_s390: aes-s390 couldn't be loaded.\n");
if (ret)
goto aes_err;
}

ret = crypto_register_alg(&ecb_aes_alg);
if (ret != 0) {
printk(KERN_INFO
"crypt_s390: ecb-aes-s390 couldn't be loaded.\n");
if (ret)
goto ecb_aes_err;
}

ret = crypto_register_alg(&cbc_aes_alg);
if (ret != 0) {
printk(KERN_INFO
"crypt_s390: cbc-aes-s390 couldn't be loaded.\n");
if (ret)
goto cbc_aes_err;
}

out:
return ret;
Expand Down
Loading

0 comments on commit 2b93910

Please sign in to comment.