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

TOMOYO Linux Cross Reference
Linux/arch/arm/crypto/sha256_neon_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-or-later
  2 /*
  3  * Glue code for the SHA256 Secure Hash Algorithm assembly implementation
  4  * using NEON instructions.
  5  *
  6  * Copyright © 2015 Google Inc.
  7  *
  8  * This file is based on sha512_neon_glue.c:
  9  *   Copyright © 2014 Jussi Kivilinna <jussi.kivilinna@iki.fi>
 10  */
 11 
 12 #include <crypto/internal/hash.h>
 13 #include <crypto/internal/simd.h>
 14 #include <linux/types.h>
 15 #include <linux/string.h>
 16 #include <crypto/sha2.h>
 17 #include <crypto/sha256_base.h>
 18 #include <asm/byteorder.h>
 19 #include <asm/simd.h>
 20 #include <asm/neon.h>
 21 
 22 #include "sha256_glue.h"
 23 
 24 asmlinkage void sha256_block_data_order_neon(struct sha256_state *digest,
 25                                              const u8 *data, int num_blks);
 26 
 27 static int crypto_sha256_neon_update(struct shash_desc *desc, const u8 *data,
 28                                      unsigned int len)
 29 {
 30         struct sha256_state *sctx = shash_desc_ctx(desc);
 31 
 32         if (!crypto_simd_usable() ||
 33             (sctx->count % SHA256_BLOCK_SIZE) + len < SHA256_BLOCK_SIZE)
 34                 return crypto_sha256_arm_update(desc, data, len);
 35 
 36         kernel_neon_begin();
 37         sha256_base_do_update(desc, data, len, sha256_block_data_order_neon);
 38         kernel_neon_end();
 39 
 40         return 0;
 41 }
 42 
 43 static int crypto_sha256_neon_finup(struct shash_desc *desc, const u8 *data,
 44                                     unsigned int len, u8 *out)
 45 {
 46         if (!crypto_simd_usable())
 47                 return crypto_sha256_arm_finup(desc, data, len, out);
 48 
 49         kernel_neon_begin();
 50         if (len)
 51                 sha256_base_do_update(desc, data, len,
 52                                       sha256_block_data_order_neon);
 53         sha256_base_do_finalize(desc, sha256_block_data_order_neon);
 54         kernel_neon_end();
 55 
 56         return sha256_base_finish(desc, out);
 57 }
 58 
 59 static int crypto_sha256_neon_final(struct shash_desc *desc, u8 *out)
 60 {
 61         return crypto_sha256_neon_finup(desc, NULL, 0, out);
 62 }
 63 
 64 struct shash_alg sha256_neon_algs[] = { {
 65         .digestsize     =       SHA256_DIGEST_SIZE,
 66         .init           =       sha256_base_init,
 67         .update         =       crypto_sha256_neon_update,
 68         .final          =       crypto_sha256_neon_final,
 69         .finup          =       crypto_sha256_neon_finup,
 70         .descsize       =       sizeof(struct sha256_state),
 71         .base           =       {
 72                 .cra_name       =       "sha256",
 73                 .cra_driver_name =      "sha256-neon",
 74                 .cra_priority   =       250,
 75                 .cra_blocksize  =       SHA256_BLOCK_SIZE,
 76                 .cra_module     =       THIS_MODULE,
 77         }
 78 }, {
 79         .digestsize     =       SHA224_DIGEST_SIZE,
 80         .init           =       sha224_base_init,
 81         .update         =       crypto_sha256_neon_update,
 82         .final          =       crypto_sha256_neon_final,
 83         .finup          =       crypto_sha256_neon_finup,
 84         .descsize       =       sizeof(struct sha256_state),
 85         .base           =       {
 86                 .cra_name       =       "sha224",
 87                 .cra_driver_name =      "sha224-neon",
 88                 .cra_priority   =       250,
 89                 .cra_blocksize  =       SHA224_BLOCK_SIZE,
 90                 .cra_module     =       THIS_MODULE,
 91         }
 92 } };
 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