Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Glue code for SHA-256 implementation for SPE instructions (PPC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Based on generic implementation. The assembler module takes care 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * about the SPE registers so it can run from interrupt context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (c) 2015 Markus Stockhausen <stockhausen@collogia.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <crypto/sha.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/switch_to.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/hardirq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * MAX_BYTES defines the number of bytes that are allowed to be processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * between preempt_disable() and preempt_enable(). SHA256 takes ~2,000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * operations per 64 bytes. e500 cores can issue two arithmetic instructions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * per clock cycle using one 32/64 bit unit (SU1) and one 32 bit unit (SU2).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * Thus 1KB of input data will need an estimated maximum of 18,000 cycles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * Headroom for cache misses included. Even with the low end model clocked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * at 667 MHz this equals to a critical time window of less than 27us.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define MAX_BYTES 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) extern void ppc_spe_sha256_transform(u32 *state, const u8 *src, u32 blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static void spe_begin(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	/* We just start SPE operations and will save SPE registers later. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	preempt_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	enable_kernel_spe();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static void spe_end(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	disable_kernel_spe();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	/* reenable preemption */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	preempt_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static inline void ppc_sha256_clear_context(struct sha256_state *sctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	int count = sizeof(struct sha256_state) >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u32 *ptr = (u32 *)sctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	/* make sure we can clear the fast way */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	BUILD_BUG_ON(sizeof(struct sha256_state) % 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	do { *ptr++ = 0; } while (--count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static int ppc_spe_sha256_init(struct shash_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	sctx->state[0] = SHA256_H0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	sctx->state[1] = SHA256_H1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	sctx->state[2] = SHA256_H2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	sctx->state[3] = SHA256_H3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	sctx->state[4] = SHA256_H4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	sctx->state[5] = SHA256_H5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	sctx->state[6] = SHA256_H6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	sctx->state[7] = SHA256_H7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	sctx->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static int ppc_spe_sha224_init(struct shash_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	sctx->state[0] = SHA224_H0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	sctx->state[1] = SHA224_H1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	sctx->state[2] = SHA224_H2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	sctx->state[3] = SHA224_H3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	sctx->state[4] = SHA224_H4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	sctx->state[5] = SHA224_H5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	sctx->state[6] = SHA224_H6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	sctx->state[7] = SHA224_H7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	sctx->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static int ppc_spe_sha256_update(struct shash_desc *desc, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	const unsigned int offset = sctx->count & 0x3f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	const unsigned int avail = 64 - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	unsigned int bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	const u8 *src = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (avail > len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		sctx->count += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		memcpy((char *)sctx->buf + offset, src, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	sctx->count += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		memcpy((char *)sctx->buf + offset, src, avail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		spe_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		ppc_spe_sha256_transform(sctx->state, (const u8 *)sctx->buf, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		spe_end();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		len -= avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		src += avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	while (len > 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		/* cut input data into smaller blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		bytes = (len > MAX_BYTES) ? MAX_BYTES : len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		bytes = bytes & ~0x3f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		spe_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		ppc_spe_sha256_transform(sctx->state, src, bytes >> 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		spe_end();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		src += bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		len -= bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	memcpy((char *)sctx->buf, src, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static int ppc_spe_sha256_final(struct shash_desc *desc, u8 *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	const unsigned int offset = sctx->count & 0x3f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	char *p = (char *)sctx->buf + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	int padlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	__be64 *pbits = (__be64 *)(((char *)&sctx->buf) + 56);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	__be32 *dst = (__be32 *)out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	padlen = 55 - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	*p++ = 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	spe_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (padlen < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		memset(p, 0x00, padlen + sizeof (u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		ppc_spe_sha256_transform(sctx->state, sctx->buf, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		p = (char *)sctx->buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		padlen = 56;
^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) 	memset(p, 0, padlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	*pbits = cpu_to_be64(sctx->count << 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	ppc_spe_sha256_transform(sctx->state, sctx->buf, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	spe_end();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	dst[0] = cpu_to_be32(sctx->state[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	dst[1] = cpu_to_be32(sctx->state[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	dst[2] = cpu_to_be32(sctx->state[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	dst[3] = cpu_to_be32(sctx->state[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	dst[4] = cpu_to_be32(sctx->state[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	dst[5] = cpu_to_be32(sctx->state[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	dst[6] = cpu_to_be32(sctx->state[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	dst[7] = cpu_to_be32(sctx->state[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	ppc_sha256_clear_context(sctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static int ppc_spe_sha224_final(struct shash_desc *desc, u8 *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	u32 D[SHA256_DIGEST_SIZE >> 2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	__be32 *dst = (__be32 *)out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	ppc_spe_sha256_final(desc, (u8 *)D);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	/* avoid bytewise memcpy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	dst[0] = D[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	dst[1] = D[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	dst[2] = D[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	dst[3] = D[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	dst[4] = D[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	dst[5] = D[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	dst[6] = D[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	/* clear sensitive data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	memzero_explicit(D, SHA256_DIGEST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static int ppc_spe_sha256_export(struct shash_desc *desc, void *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	memcpy(out, sctx, sizeof(*sctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) static int ppc_spe_sha256_import(struct shash_desc *desc, const void *in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	struct sha256_state *sctx = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	memcpy(sctx, in, sizeof(*sctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static struct shash_alg algs[2] = { {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	.digestsize	=	SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.init		=	ppc_spe_sha256_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.update		=	ppc_spe_sha256_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.final		=	ppc_spe_sha256_final,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.export		=	ppc_spe_sha256_export,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.import		=	ppc_spe_sha256_import,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	.descsize	=	sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	.statesize	=	sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	.base		=	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		.cra_name	=	"sha256",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		.cra_driver_name=	"sha256-ppc-spe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		.cra_priority	=	300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		.cra_blocksize	=	SHA256_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		.cra_module	=	THIS_MODULE,
^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) 	.digestsize	=	SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	.init		=	ppc_spe_sha224_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	.update		=	ppc_spe_sha256_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	.final		=	ppc_spe_sha224_final,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	.export		=	ppc_spe_sha256_export,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	.import		=	ppc_spe_sha256_import,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	.descsize	=	sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	.statesize	=	sizeof(struct sha256_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.base		=	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		.cra_name	=	"sha224",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		.cra_driver_name=	"sha224-ppc-spe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		.cra_priority	=	300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		.cra_blocksize	=	SHA224_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		.cra_module	=	THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) } };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static int __init ppc_spe_sha256_mod_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static void __exit ppc_spe_sha256_mod_fini(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) module_init(ppc_spe_sha256_mod_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) module_exit(ppc_spe_sha256_mod_fini);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) MODULE_DESCRIPTION("SHA-224 and SHA-256 Secure Hash Algorithm, SPE optimized");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) MODULE_ALIAS_CRYPTO("sha224");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) MODULE_ALIAS_CRYPTO("sha224-ppc-spe");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) MODULE_ALIAS_CRYPTO("sha256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) MODULE_ALIAS_CRYPTO("sha256-ppc-spe");