diff options
Diffstat (limited to 'arch/s390/crypto/sha512_s390.c')
| -rw-r--r-- | arch/s390/crypto/sha512_s390.c | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/arch/s390/crypto/sha512_s390.c b/arch/s390/crypto/sha512_s390.c index 23c7861f6aeb..83192bfc8048 100644 --- a/arch/s390/crypto/sha512_s390.c +++ b/arch/s390/crypto/sha512_s390.c | |||
| @@ -12,16 +12,16 @@ | |||
| 12 | * any later version. | 12 | * any later version. |
| 13 | * | 13 | * |
| 14 | */ | 14 | */ |
| 15 | #include <crypto/internal/hash.h> | ||
| 15 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| 16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 17 | #include <linux/crypto.h> | ||
| 18 | 18 | ||
| 19 | #include "sha.h" | 19 | #include "sha.h" |
| 20 | #include "crypt_s390.h" | 20 | #include "crypt_s390.h" |
| 21 | 21 | ||
| 22 | static void sha512_init(struct crypto_tfm *tfm) | 22 | static int sha512_init(struct shash_desc *desc) |
| 23 | { | 23 | { |
| 24 | struct s390_sha_ctx *ctx = crypto_tfm_ctx(tfm); | 24 | struct s390_sha_ctx *ctx = shash_desc_ctx(desc); |
| 25 | 25 | ||
| 26 | *(__u64 *)&ctx->state[0] = 0x6a09e667f3bcc908ULL; | 26 | *(__u64 *)&ctx->state[0] = 0x6a09e667f3bcc908ULL; |
| 27 | *(__u64 *)&ctx->state[2] = 0xbb67ae8584caa73bULL; | 27 | *(__u64 *)&ctx->state[2] = 0xbb67ae8584caa73bULL; |
| @@ -33,29 +33,31 @@ static void sha512_init(struct crypto_tfm *tfm) | |||
| 33 | *(__u64 *)&ctx->state[14] = 0x5be0cd19137e2179ULL; | 33 | *(__u64 *)&ctx->state[14] = 0x5be0cd19137e2179ULL; |
| 34 | ctx->count = 0; | 34 | ctx->count = 0; |
| 35 | ctx->func = KIMD_SHA_512; | 35 | ctx->func = KIMD_SHA_512; |
| 36 | |||
| 37 | return 0; | ||
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | static struct crypto_alg sha512_alg = { | 40 | static struct shash_alg sha512_alg = { |
| 39 | .cra_name = "sha512", | 41 | .digestsize = SHA512_DIGEST_SIZE, |
| 40 | .cra_driver_name = "sha512-s390", | 42 | .init = sha512_init, |
| 41 | .cra_priority = CRYPT_S390_PRIORITY, | 43 | .update = s390_sha_update, |
| 42 | .cra_flags = CRYPTO_ALG_TYPE_DIGEST, | 44 | .final = s390_sha_final, |
| 43 | .cra_blocksize = SHA512_BLOCK_SIZE, | 45 | .descsize = sizeof(struct s390_sha_ctx), |
| 44 | .cra_ctxsize = sizeof(struct s390_sha_ctx), | 46 | .base = { |
| 45 | .cra_module = THIS_MODULE, | 47 | .cra_name = "sha512", |
| 46 | .cra_list = LIST_HEAD_INIT(sha512_alg.cra_list), | 48 | .cra_driver_name= "sha512-s390", |
| 47 | .cra_u = { .digest = { | 49 | .cra_priority = CRYPT_S390_PRIORITY, |
| 48 | .dia_digestsize = SHA512_DIGEST_SIZE, | 50 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |
| 49 | .dia_init = sha512_init, | 51 | .cra_blocksize = SHA512_BLOCK_SIZE, |
| 50 | .dia_update = s390_sha_update, | 52 | .cra_module = THIS_MODULE, |
| 51 | .dia_final = s390_sha_final } } | 53 | } |
| 52 | }; | 54 | }; |
| 53 | 55 | ||
| 54 | MODULE_ALIAS("sha512"); | 56 | MODULE_ALIAS("sha512"); |
| 55 | 57 | ||
| 56 | static void sha384_init(struct crypto_tfm *tfm) | 58 | static int sha384_init(struct shash_desc *desc) |
| 57 | { | 59 | { |
| 58 | struct s390_sha_ctx *ctx = crypto_tfm_ctx(tfm); | 60 | struct s390_sha_ctx *ctx = shash_desc_ctx(desc); |
| 59 | 61 | ||
| 60 | *(__u64 *)&ctx->state[0] = 0xcbbb9d5dc1059ed8ULL; | 62 | *(__u64 *)&ctx->state[0] = 0xcbbb9d5dc1059ed8ULL; |
| 61 | *(__u64 *)&ctx->state[2] = 0x629a292a367cd507ULL; | 63 | *(__u64 *)&ctx->state[2] = 0x629a292a367cd507ULL; |
| @@ -67,22 +69,25 @@ static void sha384_init(struct crypto_tfm *tfm) | |||
| 67 | *(__u64 *)&ctx->state[14] = 0x47b5481dbefa4fa4ULL; | 69 | *(__u64 *)&ctx->state[14] = 0x47b5481dbefa4fa4ULL; |
| 68 | ctx->count = 0; | 70 | ctx->count = 0; |
| 69 | ctx->func = KIMD_SHA_512; | 71 | ctx->func = KIMD_SHA_512; |
| 72 | |||
| 73 | return 0; | ||
| 70 | } | 74 | } |
| 71 | 75 | ||
| 72 | static struct crypto_alg sha384_alg = { | 76 | static struct shash_alg sha384_alg = { |
| 73 | .cra_name = "sha384", | 77 | .digestsize = SHA384_DIGEST_SIZE, |
| 74 | .cra_driver_name = "sha384-s390", | 78 | .init = sha384_init, |
| 75 | .cra_priority = CRYPT_S390_PRIORITY, | 79 | .update = s390_sha_update, |
| 76 | .cra_flags = CRYPTO_ALG_TYPE_DIGEST, | 80 | .final = s390_sha_final, |
| 77 | .cra_blocksize = SHA384_BLOCK_SIZE, | 81 | .descsize = sizeof(struct s390_sha_ctx), |
| 78 | .cra_ctxsize = sizeof(struct s390_sha_ctx), | 82 | .base = { |
| 79 | .cra_module = THIS_MODULE, | 83 | .cra_name = "sha384", |
| 80 | .cra_list = LIST_HEAD_INIT(sha384_alg.cra_list), | 84 | .cra_driver_name= "sha384-s390", |
| 81 | .cra_u = { .digest = { | 85 | .cra_priority = CRYPT_S390_PRIORITY, |
| 82 | .dia_digestsize = SHA384_DIGEST_SIZE, | 86 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |
| 83 | .dia_init = sha384_init, | 87 | .cra_blocksize = SHA384_BLOCK_SIZE, |
| 84 | .dia_update = s390_sha_update, | 88 | .cra_ctxsize = sizeof(struct s390_sha_ctx), |
| 85 | .dia_final = s390_sha_final } } | 89 | .cra_module = THIS_MODULE, |
| 90 | } | ||
| 86 | }; | 91 | }; |
| 87 | 92 | ||
| 88 | MODULE_ALIAS("sha384"); | 93 | MODULE_ALIAS("sha384"); |
| @@ -93,18 +98,18 @@ static int __init init(void) | |||
| 93 | 98 | ||
| 94 | if (!crypt_s390_func_available(KIMD_SHA_512)) | 99 | if (!crypt_s390_func_available(KIMD_SHA_512)) |
| 95 | return -EOPNOTSUPP; | 100 | return -EOPNOTSUPP; |
| 96 | if ((ret = crypto_register_alg(&sha512_alg)) < 0) | 101 | if ((ret = crypto_register_shash(&sha512_alg)) < 0) |
| 97 | goto out; | 102 | goto out; |
| 98 | if ((ret = crypto_register_alg(&sha384_alg)) < 0) | 103 | if ((ret = crypto_register_shash(&sha384_alg)) < 0) |
| 99 | crypto_unregister_alg(&sha512_alg); | 104 | crypto_unregister_shash(&sha512_alg); |
| 100 | out: | 105 | out: |
| 101 | return ret; | 106 | return ret; |
| 102 | } | 107 | } |
| 103 | 108 | ||
| 104 | static void __exit fini(void) | 109 | static void __exit fini(void) |
| 105 | { | 110 | { |
| 106 | crypto_unregister_alg(&sha512_alg); | 111 | crypto_unregister_shash(&sha512_alg); |
| 107 | crypto_unregister_alg(&sha384_alg); | 112 | crypto_unregister_shash(&sha384_alg); |
| 108 | } | 113 | } |
| 109 | 114 | ||
| 110 | module_init(init); | 115 | module_init(init); |
