~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/crypto/sm3-ce-glue.c

Version: ~ [ linux-5.18-rc6 ] ~ [ linux-5.17.6 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.38 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.114 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.192 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.241 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.277 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.312 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * sm3-ce-glue.c - SM3 secure hash using ARMv8.2 Crypto Extensions
  4  *
  5  * Copyright (C) 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
  6  */
  7 
  8 #include <asm/neon.h>
  9 #include <asm/simd.h>
 10 #include <asm/unaligned.h>
 11 #include <crypto/internal/hash.h>
 12 #include <crypto/internal/simd.h>
 13 #include <crypto/sm3.h>
 14 #include <crypto/sm3_base.h>
 15 #include <linux/cpufeature.h>
 16 #include <linux/crypto.h>
 17 #include <linux/module.h>
 18 
 19 MODULE_DESCRIPTION("SM3 secure hash using ARMv8 Crypto Extensions");
 20 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 21 MODULE_LICENSE("GPL v2");
 22 
 23 asmlinkage void sm3_ce_transform(struct sm3_state *sst, u8 const *src,
 24                                  int blocks);
 25 
 26 static int sm3_ce_update(struct shash_desc *desc, const u8 *data,
 27                          unsigned int len)
 28 {
 29         if (!crypto_simd_usable())
 30                 return crypto_sm3_update(desc, data, len);
 31 
 32         kernel_neon_begin();
 33         sm3_base_do_update(desc, data, len, sm3_ce_transform);
 34         kernel_neon_end();
 35 
 36         return 0;
 37 }
 38 
 39 static int sm3_ce_final(struct shash_desc *desc, u8 *out)
 40 {
 41         if (!crypto_simd_usable())
 42                 return crypto_sm3_finup(desc, NULL, 0, out);
 43 
 44         kernel_neon_begin();
 45         sm3_base_do_finalize(desc, sm3_ce_transform);
 46         kernel_neon_end();
 47 
 48         return sm3_base_finish(desc, out);
 49 }
 50 
 51 static int sm3_ce_finup(struct shash_desc *desc, const u8 *data,
 52                         unsigned int len, u8 *out)
 53 {
 54         if (!crypto_simd_usable())
 55                 return crypto_sm3_finup(desc, data, len, out);
 56 
 57         kernel_neon_begin();
 58         sm3_base_do_update(desc, data, len, sm3_ce_transform);
 59         kernel_neon_end();
 60 
 61         return sm3_ce_final(desc, out);
 62 }
 63 
 64 static struct shash_alg sm3_alg = {
 65         .digestsize             = SM3_DIGEST_SIZE,
 66         .init                   = sm3_base_init,
 67         .update                 = sm3_ce_update,
 68         .final                  = sm3_ce_final,
 69         .finup                  = sm3_ce_finup,
 70         .descsize               = sizeof(struct sm3_state),
 71         .base.cra_name          = "sm3",
 72         .base.cra_driver_name   = "sm3-ce",
 73         .base.cra_blocksize     = SM3_BLOCK_SIZE,
 74         .base.cra_module        = THIS_MODULE,
 75         .base.cra_priority      = 200,
 76 };
 77 
 78 static int __init sm3_ce_mod_init(void)
 79 {
 80         return crypto_register_shash(&sm3_alg);
 81 }
 82 
 83 static void __exit sm3_ce_mod_fini(void)
 84 {
 85         crypto_unregister_shash(&sm3_alg);
 86 }
 87 
 88 module_cpu_feature_match(SM3, sm3_ce_mod_init);
 89 module_exit(sm3_ce_mod_fini);
 90 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp