Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: arm64/sm3-neon - Use API partial block handling

Use the Crypto API partial block handling.

Also remove the unnecessary SIMD fallback path.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+8 -40
+8 -40
arch/arm64/crypto/sm3-neon-glue.c
··· 6 6 */ 7 7 8 8 #include <asm/neon.h> 9 - #include <asm/simd.h> 10 - #include <linux/unaligned.h> 11 9 #include <crypto/internal/hash.h> 12 - #include <crypto/internal/simd.h> 13 10 #include <crypto/sm3.h> 14 11 #include <crypto/sm3_base.h> 15 12 #include <linux/cpufeature.h> 16 - #include <linux/crypto.h> 13 + #include <linux/kernel.h> 17 14 #include <linux/module.h> 18 15 19 16 ··· 20 23 static int sm3_neon_update(struct shash_desc *desc, const u8 *data, 21 24 unsigned int len) 22 25 { 23 - if (!crypto_simd_usable()) { 24 - sm3_update(shash_desc_ctx(desc), data, len); 25 - return 0; 26 - } 26 + int remain; 27 27 28 28 kernel_neon_begin(); 29 - sm3_base_do_update(desc, data, len, sm3_neon_transform); 29 + remain = sm3_base_do_update_blocks(desc, data, len, sm3_neon_transform); 30 30 kernel_neon_end(); 31 - 32 - return 0; 33 - } 34 - 35 - static int sm3_neon_final(struct shash_desc *desc, u8 *out) 36 - { 37 - if (!crypto_simd_usable()) { 38 - sm3_final(shash_desc_ctx(desc), out); 39 - return 0; 40 - } 41 - 42 - kernel_neon_begin(); 43 - sm3_base_do_finalize(desc, sm3_neon_transform); 44 - kernel_neon_end(); 45 - 46 - return sm3_base_finish(desc, out); 31 + return remain; 47 32 } 48 33 49 34 static int sm3_neon_finup(struct shash_desc *desc, const u8 *data, 50 35 unsigned int len, u8 *out) 51 36 { 52 - if (!crypto_simd_usable()) { 53 - struct sm3_state *sctx = shash_desc_ctx(desc); 54 - 55 - if (len) 56 - sm3_update(sctx, data, len); 57 - sm3_final(sctx, out); 58 - return 0; 59 - } 60 - 61 37 kernel_neon_begin(); 62 - if (len) 63 - sm3_base_do_update(desc, data, len, sm3_neon_transform); 64 - sm3_base_do_finalize(desc, sm3_neon_transform); 38 + sm3_base_do_finup(desc, data, len, sm3_neon_transform); 65 39 kernel_neon_end(); 66 - 67 40 return sm3_base_finish(desc, out); 68 41 } 69 42 ··· 41 74 .digestsize = SM3_DIGEST_SIZE, 42 75 .init = sm3_base_init, 43 76 .update = sm3_neon_update, 44 - .final = sm3_neon_final, 45 77 .finup = sm3_neon_finup, 46 - .descsize = sizeof(struct sm3_state), 78 + .descsize = SM3_STATE_SIZE, 47 79 .base.cra_name = "sm3", 48 80 .base.cra_driver_name = "sm3-neon", 81 + .base.cra_flags = CRYPTO_AHASH_ALG_BLOCK_ONLY | 82 + CRYPTO_AHASH_ALG_FINUP_MAX, 49 83 .base.cra_blocksize = SM3_BLOCK_SIZE, 50 84 .base.cra_module = THIS_MODULE, 51 85 .base.cra_priority = 200,