11 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/module.h>
18 #include <linux/types.h>
19 #include <crypto/sha.h>
62 unsigned int len,
unsigned int partial)
64 unsigned int done = 0;
79 memcpy(sctx->
buf, data + done, len - done);
93 __sha256_sparc64_update(sctx, data, len, partial);
101 unsigned int i,
index, padlen;
114 sctx->
count += padlen;
115 memcpy(sctx->
buf + index, padding, padlen);
117 __sha256_sparc64_update(sctx, padding, padlen, index);
119 __sha256_sparc64_update(sctx, (
const u8 *)&bits,
sizeof(bits), 56);
122 for (i = 0; i < 8; i++)
126 memset(sctx, 0,
sizeof(*sctx));
135 sha256_sparc64_final(desc, D);
143 static int sha256_sparc64_export(
struct shash_desc *desc,
void *out)
147 memcpy(out, sctx,
sizeof(*sctx));
151 static int sha256_sparc64_import(
struct shash_desc *desc,
const void *
in)
155 memcpy(sctx, in,
sizeof(*sctx));
161 .init = sha256_sparc64_init,
162 .update = sha256_sparc64_update,
163 .final = sha256_sparc64_final,
164 .export = sha256_sparc64_export,
165 .import = sha256_sparc64_import,
169 .cra_name =
"sha256",
170 .cra_driver_name=
"sha256-sparc64",
180 .init = sha224_sparc64_init,
181 .update = sha256_sparc64_update,
182 .final = sha224_sparc64_final,
185 .cra_name =
"sha224",
186 .cra_driver_name=
"sha224-sparc64",
194 static bool __init sparc64_has_sha256_opcode(
void)
201 __asm__ __volatile__(
"rd %%asr26, %0" :
"=r" (cfr));
208 static int __init sha256_sparc64_mod_init(
void)
210 if (sparc64_has_sha256_opcode()) {
221 pr_info(
"Using sparc64 sha256 opcode optimized SHA-256/SHA-224 implementation\n");
224 pr_info(
"sparc64 sha256 opcode not available.\n");
228 static void __exit sha256_sparc64_mod_fini(
void)
238 MODULE_DESCRIPTION(
"SHA-224 and SHA-256 Secure Hash Algorithm, sparc64 sha256 opcode accelerated");