23 #include <crypto/sha.h>
24 #include <linux/module.h>
39 memset(sctx, 0,
sizeof *sctx);
46 nx_ctx->
op.outlen = (nx_ctx->
out_sg - out_sg) *
sizeof(
struct nx_sg);
58 u64 to_process, leftover;
64 memcpy(csbcpb->
cpb.sha256.input_partial_digest,
85 sctx->
count, nx_ctx->
ap->sglen);
87 to_process - sctx->
count,
89 nx_ctx->
op.inlen = (nx_ctx->
in_sg - in_sg) *
93 to_process, nx_ctx->
ap->sglen);
94 nx_ctx->
op.inlen = (nx_ctx->
in_sg - in_sg) *
100 if (!nx_ctx->
op.inlen || !nx_ctx->
op.outlen) {
113 memcpy(sctx->
buf, data + len - leftover, leftover);
114 sctx->
count = leftover;
116 csbcpb->
cpb.sha256.message_bit_length += (
u64)
117 (csbcpb->
cpb.sha256.spbc * 8);
130 struct nx_sg *in_sg, *out_sg;
136 memcpy(csbcpb->
cpb.sha256.input_partial_digest,
144 csbcpb->
cpb.sha256.message_bit_length += (
u64)(sctx->
count * 8);
147 sctx->
count, nx_ctx->
ap->sglen);
150 nx_ctx->
op.inlen = (nx_ctx->
in_sg - in_sg) *
sizeof(
struct nx_sg);
151 nx_ctx->
op.outlen = (nx_ctx->
out_sg - out_sg) *
sizeof(
struct nx_sg);
153 if (!nx_ctx->
op.outlen) {
166 &(nx_ctx->
stats->sha256_bytes));
172 static int nx_sha256_export(
struct shash_desc *desc,
void *out)
180 (csbcpb->
cpb.sha256.message_bit_length / 8);
181 memcpy(octx->buf, sctx->
buf,
sizeof(octx->buf));
186 if (csbcpb->
cpb.sha256.message_bit_length)
187 memcpy(octx->state, csbcpb->
cpb.sha256.message_digest,
203 static int nx_sha256_import(
struct shash_desc *desc,
const void *
in)
210 memcpy(sctx->
buf, ictx->buf,
sizeof(ictx->buf));
212 sctx->
count = ictx->count & 0x3f;
213 csbcpb->
cpb.sha256.message_bit_length = (ictx->count & ~0x3f) * 8;
215 if (csbcpb->
cpb.sha256.message_bit_length) {
216 memcpy(csbcpb->
cpb.sha256.message_digest, ictx->state,
228 .init = nx_sha256_init,
229 .update = nx_sha256_update,
230 .final = nx_sha256_final,
231 .export = nx_sha256_export,
232 .import = nx_sha256_import,
236 .cra_name =
"sha256",
237 .cra_driver_name =
"sha256-nx",