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

TOMOYO Linux Cross Reference
Linux/arch/arm/crypto/sha1-ce-glue.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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  * sha1-ce-glue.c - SHA-1 secure hash using ARMv8 Crypto Extensions
  4  *
  5  * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
  6  */
  7 
  8 #include <crypto/internal/hash.h>
  9 #include <crypto/internal/simd.h>
 10 #include <crypto/sha1.h>
 11 #include <crypto/sha1_base.h>
 12 #include <linux/cpufeature.h>
 13 #include <linux/crypto.h>
 14 #include <linux/module.h>
 15 
 16 #include <asm/hwcap.h>
 17 #include <asm/neon.h>
 18 #include <asm/simd.h>
 19 
 20 #include "sha1.h"
 21 
 22 MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
 23 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 24 MODULE_LICENSE("GPL v2");
 25 
 26 asmlinkage void sha1_ce_transform(struct sha1_state *sst, u8 const *src,
 27                                   int blocks);
 28 
 29 static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
 30                           unsigned int len)
 31 {
 32         struct sha1_state *sctx = shash_desc_ctx(desc);
 33 
 34         if (!crypto_simd_usable() ||
 35             (sctx->count % SHA1_BLOCK_SIZE) + len < SHA1_BLOCK_SIZE)
 36                 return sha1_update_arm(desc, data, len);
 37 
 38         kernel_neon_begin();
 39         sha1_base_do_update(desc, data, len, sha1_ce_transform);
 40         kernel_neon_end();
 41 
 42         return 0;
 43 }
 44 
 45 static int sha1_ce_finup(struct shash_desc *desc, const u8 *data,
 46                          unsigned int len, u8 *out)
 47 {
 48         if (!crypto_simd_usable())
 49                 return sha1_finup_arm(desc, data, len, out);
 50 
 51         kernel_neon_begin();
 52         if (len)
 53                 sha1_base_do_update(desc, data, len, sha1_ce_transform);
 54         sha1_base_do_finalize(desc, sha1_ce_transform);
 55         kernel_neon_end();
 56 
 57         return sha1_base_finish(desc, out);
 58 }
 59 
 60 static int sha1_ce_final(struct shash_desc *desc, u8 *out)
 61 {
 62         return sha1_ce_finup(desc, NULL, 0, out);
 63 }
 64 
 65 static struct shash_alg alg = {
 66         .init                   = sha1_base_init,
 67         .update                 = sha1_ce_update,
 68         .final                  = sha1_ce_final,
 69         .finup                  = sha1_ce_finup,
 70         .descsize               = sizeof(struct sha1_state),
 71         .digestsize             = SHA1_DIGEST_SIZE,
 72         .base                   = {
 73                 .cra_name               = "sha1",
 74                 .cra_driver_name        = "sha1-ce",
 75                 .cra_priority           = 200,
 76                 .cra_blocksize          = SHA1_BLOCK_SIZE,
 77                 .cra_module             = THIS_MODULE,
 78         }
 79 };
 80 
 81 static int __init sha1_ce_mod_init(void)
 82 {
 83         return crypto_register_shash(&alg);
 84 }
 85 
 86 static void __exit sha1_ce_mod_fini(void)
 87 {
 88         crypto_unregister_shash(&alg);
 89 }
 90 
 91 module_cpu_feature_match(SHA1, sha1_ce_mod_init);
 92 module_exit(sha1_ce_mod_fini);
 93 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php