11 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/module.h>
18 #include <linux/types.h>
19 #include <crypto/sha.h>
31 struct sha1_state *sctx = shash_desc_ctx(desc);
41 unsigned int len,
unsigned int partial)
43 unsigned int done = 0;
64 struct sha1_state *sctx = shash_desc_ctx(desc);
72 __sha1_sparc64_update(sctx, data, len, partial);
80 struct sha1_state *sctx = shash_desc_ctx(desc);
81 unsigned int i,
index, padlen;
94 sctx->
count += padlen;
97 __sha1_sparc64_update(sctx, padding, padlen, index);
99 __sha1_sparc64_update(sctx, (
const u8 *)&bits,
sizeof(bits), 56);
102 for (i = 0; i < 5; i++)
106 memset(sctx, 0,
sizeof(*sctx));
111 static int sha1_sparc64_export(
struct shash_desc *desc,
void *out)
113 struct sha1_state *sctx = shash_desc_ctx(desc);
115 memcpy(out, sctx,
sizeof(*sctx));
120 static int sha1_sparc64_import(
struct shash_desc *desc,
const void *
in)
122 struct sha1_state *sctx = shash_desc_ctx(desc);
124 memcpy(sctx, in,
sizeof(*sctx));
131 .init = sha1_sparc64_init,
132 .update = sha1_sparc64_update,
133 .final = sha1_sparc64_final,
134 .export = sha1_sparc64_export,
135 .import = sha1_sparc64_import,
140 .cra_driver_name=
"sha1-sparc64",
148 static bool __init sparc64_has_sha1_opcode(
void)
155 __asm__ __volatile__(
"rd %%asr26, %0" :
"=r" (cfr));
162 static int __init sha1_sparc64_mod_init(
void)
164 if (sparc64_has_sha1_opcode()) {
165 pr_info(
"Using sparc64 sha1 opcode optimized SHA-1 implementation\n");
168 pr_info(
"sparc64 sha1 opcode not available.\n");
172 static void __exit sha1_sparc64_mod_fini(
void)