^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Glue code for SHA256 hashing optimized for sparc64 crypto opcodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This is based largely upon crypto/sha256_generic.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * SHA224 Support Copyright 2007 Intel Corporation <jonathan.lynch@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <crypto/sha.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/pstate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "opcodes.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) asmlinkage void sha256_sparc64_transform(u32 *digest, const char *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) unsigned int rounds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static int sha224_sparc64_init(struct shash_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) sctx->state[0] = SHA224_H0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) sctx->state[1] = SHA224_H1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) sctx->state[2] = SHA224_H2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) sctx->state[3] = SHA224_H3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) sctx->state[4] = SHA224_H4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) sctx->state[5] = SHA224_H5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) sctx->state[6] = SHA224_H6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) sctx->state[7] = SHA224_H7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) sctx->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static int sha256_sparc64_init(struct shash_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) sctx->state[0] = SHA256_H0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) sctx->state[1] = SHA256_H1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) sctx->state[2] = SHA256_H2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) sctx->state[3] = SHA256_H3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) sctx->state[4] = SHA256_H4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) sctx->state[5] = SHA256_H5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) sctx->state[6] = SHA256_H6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) sctx->state[7] = SHA256_H7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) sctx->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static void __sha256_sparc64_update(struct sha256_state *sctx, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) unsigned int len, unsigned int partial)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned int done = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) sctx->count += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (partial) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) done = SHA256_BLOCK_SIZE - partial;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) memcpy(sctx->buf + partial, data, done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) sha256_sparc64_transform(sctx->state, sctx->buf, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (len - done >= SHA256_BLOCK_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) const unsigned int rounds = (len - done) / SHA256_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) sha256_sparc64_transform(sctx->state, data + done, rounds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) done += rounds * SHA256_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) memcpy(sctx->buf, data + done, len - done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static int sha256_sparc64_update(struct shash_desc *desc, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned int partial = sctx->count % SHA256_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* Handle the fast case right here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (partial + len < SHA256_BLOCK_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) sctx->count += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) memcpy(sctx->buf + partial, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) __sha256_sparc64_update(sctx, data, len, partial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static int sha256_sparc64_final(struct shash_desc *desc, u8 *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) unsigned int i, index, padlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) __be32 *dst = (__be32 *)out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) __be64 bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static const u8 padding[SHA256_BLOCK_SIZE] = { 0x80, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) bits = cpu_to_be64(sctx->count << 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* Pad out to 56 mod 64 and append length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) index = sctx->count % SHA256_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) padlen = (index < 56) ? (56 - index) : ((SHA256_BLOCK_SIZE+56) - index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* We need to fill a whole block for __sha256_sparc64_update() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (padlen <= 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) sctx->count += padlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) memcpy(sctx->buf + index, padding, padlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) __sha256_sparc64_update(sctx, padding, padlen, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) __sha256_sparc64_update(sctx, (const u8 *)&bits, sizeof(bits), 56);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* Store state in digest */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) for (i = 0; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) dst[i] = cpu_to_be32(sctx->state[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* Wipe context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) memset(sctx, 0, sizeof(*sctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static int sha224_sparc64_final(struct shash_desc *desc, u8 *hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) u8 D[SHA256_DIGEST_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) sha256_sparc64_final(desc, D);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) memcpy(hash, D, SHA224_DIGEST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) memzero_explicit(D, SHA256_DIGEST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int sha256_sparc64_export(struct shash_desc *desc, void *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) memcpy(out, sctx, sizeof(*sctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static int sha256_sparc64_import(struct shash_desc *desc, const void *in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) memcpy(sctx, in, sizeof(*sctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static struct shash_alg sha256_alg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) .digestsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) .init = sha256_sparc64_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) .update = sha256_sparc64_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) .final = sha256_sparc64_final,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) .export = sha256_sparc64_export,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) .import = sha256_sparc64_import,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) .descsize = sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) .statesize = sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) .base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) .cra_name = "sha256",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) .cra_driver_name= "sha256-sparc64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) .cra_priority = SPARC_CR_OPCODE_PRIORITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) .cra_blocksize = SHA256_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) .cra_module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static struct shash_alg sha224_alg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) .digestsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) .init = sha224_sparc64_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) .update = sha256_sparc64_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) .final = sha224_sparc64_final,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) .descsize = sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) .base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) .cra_name = "sha224",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) .cra_driver_name= "sha224-sparc64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) .cra_priority = SPARC_CR_OPCODE_PRIORITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) .cra_blocksize = SHA224_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) .cra_module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static bool __init sparc64_has_sha256_opcode(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) unsigned long cfr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (!(sparc64_elf_hwcap & HWCAP_SPARC_CRYPTO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) __asm__ __volatile__("rd %%asr26, %0" : "=r" (cfr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (!(cfr & CFR_SHA256))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) static int __init sha256_sparc64_mod_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (sparc64_has_sha256_opcode()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int ret = crypto_register_shash(&sha224_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ret = crypto_register_shash(&sha256_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) crypto_unregister_shash(&sha224_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) pr_info("Using sparc64 sha256 opcode optimized SHA-256/SHA-224 implementation\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) pr_info("sparc64 sha256 opcode not available.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static void __exit sha256_sparc64_mod_fini(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) crypto_unregister_shash(&sha224_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) crypto_unregister_shash(&sha256_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) module_init(sha256_sparc64_mod_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) module_exit(sha256_sparc64_mod_fini);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) MODULE_DESCRIPTION("SHA-224 and SHA-256 Secure Hash Algorithm, sparc64 sha256 opcode accelerated");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) MODULE_ALIAS_CRYPTO("sha224");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) MODULE_ALIAS_CRYPTO("sha256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #include "crop_devid.c"