diff options
Diffstat (limited to 'arch/s390/crypto/ghash_s390.c')
-rw-r--r-- | arch/s390/crypto/ghash_s390.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c index 1ebd3a15cca4..d43485d142e9 100644 --- a/arch/s390/crypto/ghash_s390.c +++ b/arch/s390/crypto/ghash_s390.c | |||
@@ -72,14 +72,16 @@ static int ghash_update(struct shash_desc *desc, | |||
72 | if (!dctx->bytes) { | 72 | if (!dctx->bytes) { |
73 | ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, | 73 | ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, |
74 | GHASH_BLOCK_SIZE); | 74 | GHASH_BLOCK_SIZE); |
75 | BUG_ON(ret != GHASH_BLOCK_SIZE); | 75 | if (ret != GHASH_BLOCK_SIZE) |
76 | return -EIO; | ||
76 | } | 77 | } |
77 | } | 78 | } |
78 | 79 | ||
79 | n = srclen & ~(GHASH_BLOCK_SIZE - 1); | 80 | n = srclen & ~(GHASH_BLOCK_SIZE - 1); |
80 | if (n) { | 81 | if (n) { |
81 | ret = crypt_s390_kimd(KIMD_GHASH, ctx, src, n); | 82 | ret = crypt_s390_kimd(KIMD_GHASH, ctx, src, n); |
82 | BUG_ON(ret != n); | 83 | if (ret != n) |
84 | return -EIO; | ||
83 | src += n; | 85 | src += n; |
84 | srclen -= n; | 86 | srclen -= n; |
85 | } | 87 | } |
@@ -92,7 +94,7 @@ static int ghash_update(struct shash_desc *desc, | |||
92 | return 0; | 94 | return 0; |
93 | } | 95 | } |
94 | 96 | ||
95 | static void ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx) | 97 | static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx) |
96 | { | 98 | { |
97 | u8 *buf = dctx->buffer; | 99 | u8 *buf = dctx->buffer; |
98 | int ret; | 100 | int ret; |
@@ -103,21 +105,24 @@ static void ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx) | |||
103 | memset(pos, 0, dctx->bytes); | 105 | memset(pos, 0, dctx->bytes); |
104 | 106 | ||
105 | ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, GHASH_BLOCK_SIZE); | 107 | ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, GHASH_BLOCK_SIZE); |
106 | BUG_ON(ret != GHASH_BLOCK_SIZE); | 108 | if (ret != GHASH_BLOCK_SIZE) |
109 | return -EIO; | ||
107 | } | 110 | } |
108 | 111 | ||
109 | dctx->bytes = 0; | 112 | dctx->bytes = 0; |
113 | return 0; | ||
110 | } | 114 | } |
111 | 115 | ||
112 | static int ghash_final(struct shash_desc *desc, u8 *dst) | 116 | static int ghash_final(struct shash_desc *desc, u8 *dst) |
113 | { | 117 | { |
114 | struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); | 118 | struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); |
115 | struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); | 119 | struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); |
120 | int ret; | ||
116 | 121 | ||
117 | ghash_flush(ctx, dctx); | 122 | ret = ghash_flush(ctx, dctx); |
118 | memcpy(dst, ctx->icv, GHASH_BLOCK_SIZE); | 123 | if (!ret) |
119 | 124 | memcpy(dst, ctx->icv, GHASH_BLOCK_SIZE); | |
120 | return 0; | 125 | return ret; |
121 | } | 126 | } |
122 | 127 | ||
123 | static struct shash_alg ghash_alg = { | 128 | static struct shash_alg ghash_alg = { |