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

TOMOYO Linux Cross Reference
Linux/arch/arm/crypto/sha1_neon_glue.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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-or-later
  2 /*
  3  * Glue code for the SHA1 Secure Hash Algorithm assembler implementation using
  4  * ARM NEON instructions.
  5  *
  6  * Copyright © 2014 Jussi Kivilinna <jussi.kivilinna@iki.fi>
  7  *
  8  * This file is based on sha1_generic.c and sha1_ssse3_glue.c:
  9  *  Copyright (c) Alan Smithee.
 10  *  Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
 11  *  Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
 12  *  Copyright (c) Mathias Krause <minipli@googlemail.com>
 13  *  Copyright (c) Chandramouli Narayanan <mouli@linux.intel.com>
 14  */
 15 
 16 #include <crypto/internal/hash.h>
 17 #include <crypto/internal/simd.h>
 18 #include <linux/init.h>
 19 #include <linux/module.h>
 20 #include <linux/mm.h>
 21 #include <linux/types.h>
 22 #include <crypto/sha1.h>
 23 #include <crypto/sha1_base.h>
 24 #include <asm/neon.h>
 25 #include <asm/simd.h>
 26 
 27 #include "sha1.h"
 28 
 29 asmlinkage void sha1_transform_neon(struct sha1_state *state_h,
 30                                     const u8 *data, int rounds);
 31 
 32 static int sha1_neon_update(struct shash_desc *desc, const u8 *data,
 33                           unsigned int len)
 34 {
 35         struct sha1_state *sctx = shash_desc_ctx(desc);
 36 
 37         if (!crypto_simd_usable() ||
 38             (sctx->count % SHA1_BLOCK_SIZE) + len < SHA1_BLOCK_SIZE)
 39                 return sha1_update_arm(desc, data, len);
 40 
 41         kernel_neon_begin();
 42         sha1_base_do_update(desc, data, len, sha1_transform_neon);
 43         kernel_neon_end();
 44 
 45         return 0;
 46 }
 47 
 48 static int sha1_neon_finup(struct shash_desc *desc, const u8 *data,
 49                            unsigned int len, u8 *out)
 50 {
 51         if (!crypto_simd_usable())
 52                 return sha1_finup_arm(desc, data, len, out);
 53 
 54         kernel_neon_begin();
 55         if (len)
 56                 sha1_base_do_update(desc, data, len, sha1_transform_neon);
 57         sha1_base_do_finalize(desc, sha1_transform_neon);
 58         kernel_neon_end();
 59 
 60         return sha1_base_finish(desc, out);
 61 }
 62 
 63 static int sha1_neon_final(struct shash_desc *desc, u8 *out)
 64 {
 65         return sha1_neon_finup(desc, NULL, 0, out);
 66 }
 67 
 68 static struct shash_alg alg = {
 69         .digestsize     =       SHA1_DIGEST_SIZE,
 70         .init           =       sha1_base_init,
 71         .update         =       sha1_neon_update,
 72         .final          =       sha1_neon_final,
 73         .finup          =       sha1_neon_finup,
 74         .descsize       =       sizeof(struct sha1_state),
 75         .base           =       {
 76                 .cra_name               = "sha1",
 77                 .cra_driver_name        = "sha1-neon",
 78                 .cra_priority           = 250,
 79                 .cra_blocksize          = SHA1_BLOCK_SIZE,
 80                 .cra_module             = THIS_MODULE,
 81         }
 82 };
 83 
 84 static int __init sha1_neon_mod_init(void)
 85 {
 86         if (!cpu_has_neon())
 87                 return -ENODEV;
 88 
 89         return crypto_register_shash(&alg);
 90 }
 91 
 92 static void __exit sha1_neon_mod_fini(void)
 93 {
 94         crypto_unregister_shash(&alg);
 95 }
 96 
 97 module_init(sha1_neon_mod_init);
 98 module_exit(sha1_neon_mod_fini);
 99 
100 MODULE_LICENSE("GPL");
101 MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, NEON accelerated");
102 MODULE_ALIAS_CRYPTO("sha1");
103 

~ [ 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