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-ce - 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-ce-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 MODULE_DESCRIPTION("SM3 secure hash using ARMv8 Crypto Extensions"); ··· 23 26 static int sm3_ce_update(struct shash_desc *desc, const u8 *data, 24 27 unsigned int len) 25 28 { 26 - if (!crypto_simd_usable()) { 27 - sm3_update(shash_desc_ctx(desc), data, len); 28 - return 0; 29 - } 29 + int remain; 30 30 31 31 kernel_neon_begin(); 32 - sm3_base_do_update(desc, data, len, sm3_ce_transform); 32 + remain = sm3_base_do_update_blocks(desc, data, len, sm3_ce_transform); 33 33 kernel_neon_end(); 34 - 35 - return 0; 36 - } 37 - 38 - static int sm3_ce_final(struct shash_desc *desc, u8 *out) 39 - { 40 - if (!crypto_simd_usable()) { 41 - sm3_final(shash_desc_ctx(desc), out); 42 - return 0; 43 - } 44 - 45 - kernel_neon_begin(); 46 - sm3_base_do_finalize(desc, sm3_ce_transform); 47 - kernel_neon_end(); 48 - 49 - return sm3_base_finish(desc, out); 34 + return remain; 50 35 } 51 36 52 37 static int sm3_ce_finup(struct shash_desc *desc, const u8 *data, 53 38 unsigned int len, u8 *out) 54 39 { 55 - if (!crypto_simd_usable()) { 56 - struct sm3_state *sctx = shash_desc_ctx(desc); 57 - 58 - if (len) 59 - sm3_update(sctx, data, len); 60 - sm3_final(sctx, out); 61 - return 0; 62 - } 63 - 64 40 kernel_neon_begin(); 65 - if (len) 66 - sm3_base_do_update(desc, data, len, sm3_ce_transform); 67 - sm3_base_do_finalize(desc, sm3_ce_transform); 41 + sm3_base_do_finup(desc, data, len, sm3_ce_transform); 68 42 kernel_neon_end(); 69 - 70 43 return sm3_base_finish(desc, out); 71 44 } 72 45 ··· 44 77 .digestsize = SM3_DIGEST_SIZE, 45 78 .init = sm3_base_init, 46 79 .update = sm3_ce_update, 47 - .final = sm3_ce_final, 48 80 .finup = sm3_ce_finup, 49 - .descsize = sizeof(struct sm3_state), 81 + .descsize = SM3_STATE_SIZE, 50 82 .base.cra_name = "sm3", 51 83 .base.cra_driver_name = "sm3-ce", 84 + .base.cra_flags = CRYPTO_AHASH_ALG_BLOCK_ONLY | 85 + CRYPTO_AHASH_ALG_FINUP_MAX, 52 86 .base.cra_blocksize = SM3_BLOCK_SIZE, 53 87 .base.cra_module = THIS_MODULE, 54 88 .base.cra_priority = 400,