Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 1 | /** |
| 2 | * SHA-512 routines supporting the Power 7+ Nest Accelerators driver |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 International Business Machines Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 only. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | * |
| 19 | * Author: Kent Yoder <yoder1@us.ibm.com> |
| 20 | */ |
| 21 | |
| 22 | #include <crypto/internal/hash.h> |
| 23 | #include <crypto/sha.h> |
| 24 | #include <linux/module.h> |
| 25 | #include <asm/vio.h> |
| 26 | |
| 27 | #include "nx_csbcpb.h" |
| 28 | #include "nx.h" |
| 29 | |
| 30 | |
| 31 | static int nx_sha512_init(struct shash_desc *desc) |
| 32 | { |
| 33 | struct sha512_state *sctx = shash_desc_ctx(desc); |
| 34 | struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base); |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 35 | struct nx_sg *out_sg; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 36 | int len; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 37 | u32 max_sg_len; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 38 | |
| 39 | nx_ctx_init(nx_ctx, HCOP_FC_SHA); |
| 40 | |
| 41 | memset(sctx, 0, sizeof *sctx); |
| 42 | |
| 43 | nx_ctx->ap = &nx_ctx->props[NX_PROPS_SHA512]; |
| 44 | |
| 45 | NX_CPB_SET_DIGEST_SIZE(nx_ctx->csbcpb, NX_DS_SHA512); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 46 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 47 | max_sg_len = min_t(u64, nx_ctx->ap->sglen, |
| 48 | nx_driver.of.max_sg_len/sizeof(struct nx_sg)); |
| 49 | max_sg_len = min_t(u64, max_sg_len, |
| 50 | nx_ctx->ap->databytelen/NX_PAGE_SIZE); |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 51 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 52 | len = SHA512_DIGEST_SIZE; |
| 53 | out_sg = nx_build_sg_list(nx_ctx->out_sg, (u8 *)sctx->state, |
| 54 | &len, max_sg_len); |
| 55 | nx_ctx->op.outlen = (nx_ctx->out_sg - out_sg) * sizeof(struct nx_sg); |
| 56 | |
| 57 | if (len != SHA512_DIGEST_SIZE) |
| 58 | return -EINVAL; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 59 | |
| 60 | sctx->state[0] = __cpu_to_be64(SHA512_H0); |
| 61 | sctx->state[1] = __cpu_to_be64(SHA512_H1); |
| 62 | sctx->state[2] = __cpu_to_be64(SHA512_H2); |
| 63 | sctx->state[3] = __cpu_to_be64(SHA512_H3); |
| 64 | sctx->state[4] = __cpu_to_be64(SHA512_H4); |
| 65 | sctx->state[5] = __cpu_to_be64(SHA512_H5); |
| 66 | sctx->state[6] = __cpu_to_be64(SHA512_H6); |
| 67 | sctx->state[7] = __cpu_to_be64(SHA512_H7); |
| 68 | sctx->count[0] = 0; |
| 69 | |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static int nx_sha512_update(struct shash_desc *desc, const u8 *data, |
| 74 | unsigned int len) |
| 75 | { |
| 76 | struct sha512_state *sctx = shash_desc_ctx(desc); |
| 77 | struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base); |
| 78 | struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 79 | struct nx_sg *in_sg; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 80 | u64 to_process, leftover = 0, total; |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 81 | unsigned long irq_flags; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 82 | int rc = 0; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 83 | int data_len; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 84 | u32 max_sg_len; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 85 | u64 buf_len = (sctx->count[0] % SHA512_BLOCK_SIZE); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 86 | |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 87 | spin_lock_irqsave(&nx_ctx->lock, irq_flags); |
| 88 | |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 89 | /* 2 cases for total data len: |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 90 | * 1: < SHA512_BLOCK_SIZE: copy into state, return 0 |
| 91 | * 2: >= SHA512_BLOCK_SIZE: process X blocks, copy in leftover |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 92 | */ |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 93 | total = (sctx->count[0] % SHA512_BLOCK_SIZE) + len; |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 94 | if (total < SHA512_BLOCK_SIZE) { |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 95 | memcpy(sctx->buf + buf_len, data, len); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 96 | sctx->count[0] += len; |
| 97 | goto out; |
| 98 | } |
| 99 | |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 100 | memcpy(csbcpb->cpb.sha512.message_digest, sctx->state, SHA512_DIGEST_SIZE); |
| 101 | NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE; |
| 102 | NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 103 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 104 | in_sg = nx_ctx->in_sg; |
| 105 | max_sg_len = min_t(u64, nx_ctx->ap->sglen, |
| 106 | nx_driver.of.max_sg_len/sizeof(struct nx_sg)); |
| 107 | max_sg_len = min_t(u64, max_sg_len, |
| 108 | nx_ctx->ap->databytelen/NX_PAGE_SIZE); |
| 109 | |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 110 | do { |
| 111 | /* |
| 112 | * to_process: the SHA512_BLOCK_SIZE data chunk to process in |
| 113 | * this update. This value is also restricted by the sg list |
| 114 | * limits. |
| 115 | */ |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 116 | to_process = total - leftover; |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 117 | to_process = to_process & ~(SHA512_BLOCK_SIZE - 1); |
| 118 | leftover = total - to_process; |
| 119 | |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 120 | if (buf_len) { |
| 121 | data_len = buf_len; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 122 | in_sg = nx_build_sg_list(nx_ctx->in_sg, |
| 123 | (u8 *) sctx->buf, |
| 124 | &data_len, max_sg_len); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 125 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 126 | if (data_len != buf_len) { |
| 127 | rc = -EINVAL; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 128 | goto out; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 129 | } |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | data_len = to_process - buf_len; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 133 | in_sg = nx_build_sg_list(in_sg, (u8 *) data, |
| 134 | &data_len, max_sg_len); |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 135 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 136 | nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) * sizeof(struct nx_sg); |
| 137 | |
| 138 | if (data_len != (to_process - buf_len)) { |
| 139 | rc = -EINVAL; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 140 | goto out; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 141 | } |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 142 | |
| 143 | to_process = (data_len + buf_len); |
| 144 | leftover = total - to_process; |
| 145 | |
| 146 | /* |
| 147 | * we've hit the nx chip previously and we're updating |
| 148 | * again, so copy over the partial digest. |
| 149 | */ |
| 150 | memcpy(csbcpb->cpb.sha512.input_partial_digest, |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 151 | csbcpb->cpb.sha512.message_digest, |
| 152 | SHA512_DIGEST_SIZE); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 153 | |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 154 | if (!nx_ctx->op.inlen || !nx_ctx->op.outlen) { |
| 155 | rc = -EINVAL; |
| 156 | goto out; |
| 157 | } |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 158 | |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 159 | rc = nx_hcall_sync(nx_ctx, &nx_ctx->op, |
| 160 | desc->flags & CRYPTO_TFM_REQ_MAY_SLEEP); |
| 161 | if (rc) |
| 162 | goto out; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 163 | |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 164 | atomic_inc(&(nx_ctx->stats->sha512_ops)); |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 165 | |
| 166 | total -= to_process; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 167 | data += to_process - buf_len; |
| 168 | buf_len = 0; |
| 169 | |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 170 | } while (leftover >= SHA512_BLOCK_SIZE); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 171 | |
| 172 | /* copy the leftover back into the state struct */ |
Kent Yoder | 1ad936e | 2013-04-12 17:13:59 +0000 | [diff] [blame] | 173 | if (leftover) |
Marcelo Cerri | d311149 | 2013-08-02 12:09:52 +0000 | [diff] [blame] | 174 | memcpy(sctx->buf, data, leftover); |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 175 | sctx->count[0] += len; |
| 176 | memcpy(sctx->state, csbcpb->cpb.sha512.message_digest, SHA512_DIGEST_SIZE); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 177 | out: |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 178 | spin_unlock_irqrestore(&nx_ctx->lock, irq_flags); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 179 | return rc; |
| 180 | } |
| 181 | |
| 182 | static int nx_sha512_final(struct shash_desc *desc, u8 *out) |
| 183 | { |
| 184 | struct sha512_state *sctx = shash_desc_ctx(desc); |
| 185 | struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base); |
| 186 | struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 187 | struct nx_sg *in_sg, *out_sg; |
| 188 | u32 max_sg_len; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 189 | u64 count0; |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 190 | unsigned long irq_flags; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 191 | int rc = 0; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 192 | int len; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 193 | |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 194 | spin_lock_irqsave(&nx_ctx->lock, irq_flags); |
| 195 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 196 | max_sg_len = min_t(u64, nx_ctx->ap->sglen, |
| 197 | nx_driver.of.max_sg_len/sizeof(struct nx_sg)); |
| 198 | max_sg_len = min_t(u64, max_sg_len, |
| 199 | nx_ctx->ap->databytelen/NX_PAGE_SIZE); |
| 200 | |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 201 | /* final is represented by continuing the operation and indicating that |
| 202 | * this is not an intermediate operation */ |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 203 | if (sctx->count[0] >= SHA512_BLOCK_SIZE) { |
| 204 | /* we've hit the nx chip previously, now we're finalizing, |
| 205 | * so copy over the partial digest */ |
| 206 | memcpy(csbcpb->cpb.sha512.input_partial_digest, sctx->state, |
| 207 | SHA512_DIGEST_SIZE); |
| 208 | NX_CPB_FDM(csbcpb) &= ~NX_FDM_INTERMEDIATE; |
| 209 | NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION; |
| 210 | } else { |
| 211 | NX_CPB_FDM(csbcpb) &= ~NX_FDM_INTERMEDIATE; |
| 212 | NX_CPB_FDM(csbcpb) &= ~NX_FDM_CONTINUATION; |
| 213 | } |
| 214 | |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 215 | NX_CPB_FDM(csbcpb) &= ~NX_FDM_INTERMEDIATE; |
| 216 | |
| 217 | count0 = sctx->count[0] * 8; |
| 218 | |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 219 | csbcpb->cpb.sha512.message_bit_length_lo = count0; |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 220 | |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 221 | len = sctx->count[0] & (SHA512_BLOCK_SIZE - 1); |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 222 | in_sg = nx_build_sg_list(nx_ctx->in_sg, sctx->buf, &len, |
| 223 | max_sg_len); |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 224 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 225 | if (len != (sctx->count[0] & (SHA512_BLOCK_SIZE - 1))) { |
| 226 | rc = -EINVAL; |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 227 | goto out; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 228 | } |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 229 | |
| 230 | len = SHA512_DIGEST_SIZE; |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 231 | out_sg = nx_build_sg_list(nx_ctx->out_sg, out, &len, |
| 232 | max_sg_len); |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 233 | |
Leonidas Da Silva Barbosa | 10d87b7 | 2015-04-23 17:41:43 -0300 | [diff] [blame^] | 234 | nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) * sizeof(struct nx_sg); |
| 235 | nx_ctx->op.outlen = (nx_ctx->out_sg - out_sg) * sizeof(struct nx_sg); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 236 | |
| 237 | if (!nx_ctx->op.outlen) { |
| 238 | rc = -EINVAL; |
| 239 | goto out; |
| 240 | } |
| 241 | |
| 242 | rc = nx_hcall_sync(nx_ctx, &nx_ctx->op, |
| 243 | desc->flags & CRYPTO_TFM_REQ_MAY_SLEEP); |
| 244 | if (rc) |
| 245 | goto out; |
| 246 | |
| 247 | atomic_inc(&(nx_ctx->stats->sha512_ops)); |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 248 | atomic64_add(sctx->count[0], &(nx_ctx->stats->sha512_bytes)); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 249 | |
| 250 | memcpy(out, csbcpb->cpb.sha512.message_digest, SHA512_DIGEST_SIZE); |
| 251 | out: |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 252 | spin_unlock_irqrestore(&nx_ctx->lock, irq_flags); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 253 | return rc; |
| 254 | } |
| 255 | |
| 256 | static int nx_sha512_export(struct shash_desc *desc, void *out) |
| 257 | { |
| 258 | struct sha512_state *sctx = shash_desc_ctx(desc); |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 259 | |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 260 | memcpy(out, sctx, sizeof(*sctx)); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 261 | |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | static int nx_sha512_import(struct shash_desc *desc, const void *in) |
| 266 | { |
| 267 | struct sha512_state *sctx = shash_desc_ctx(desc); |
Marcelo Cerri | c849163 | 2013-08-12 18:49:37 -0300 | [diff] [blame] | 268 | |
Leonidas S. Barbosa | 0008511 | 2014-10-28 15:49:46 -0200 | [diff] [blame] | 269 | memcpy(sctx, in, sizeof(*sctx)); |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 270 | |
Kent Yoder | fc482a8 | 2012-05-14 11:06:31 +0000 | [diff] [blame] | 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | struct shash_alg nx_shash_sha512_alg = { |
| 275 | .digestsize = SHA512_DIGEST_SIZE, |
| 276 | .init = nx_sha512_init, |
| 277 | .update = nx_sha512_update, |
| 278 | .final = nx_sha512_final, |
| 279 | .export = nx_sha512_export, |
| 280 | .import = nx_sha512_import, |
| 281 | .descsize = sizeof(struct sha512_state), |
| 282 | .statesize = sizeof(struct sha512_state), |
| 283 | .base = { |
| 284 | .cra_name = "sha512", |
| 285 | .cra_driver_name = "sha512-nx", |
| 286 | .cra_priority = 300, |
| 287 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |
| 288 | .cra_blocksize = SHA512_BLOCK_SIZE, |
| 289 | .cra_module = THIS_MODULE, |
| 290 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
| 291 | .cra_init = nx_crypto_ctx_sha_init, |
| 292 | .cra_exit = nx_crypto_ctx_exit, |
| 293 | } |
| 294 | }; |