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

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

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm64/crypto/sha1-ce-glue.c (Version linux-6.12-rc7) and /arch/m68k/crypto/sha1-ce-glue.c (Version linux-6.1.116)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * sha1-ce-glue.c - SHA-1 secure hash using AR    
  4  *                                                
  5  * Copyright (C) 2014 - 2017 Linaro Ltd <ard.b    
  6  */                                               
  7                                                   
  8 #include <asm/neon.h>                             
  9 #include <asm/simd.h>                             
 10 #include <linux/unaligned.h>                      
 11 #include <crypto/internal/hash.h>                 
 12 #include <crypto/internal/simd.h>                 
 13 #include <crypto/sha1.h>                          
 14 #include <crypto/sha1_base.h>                     
 15 #include <linux/cpufeature.h>                     
 16 #include <linux/crypto.h>                         
 17 #include <linux/module.h>                         
 18                                                   
 19 MODULE_DESCRIPTION("SHA1 secure hash using ARM    
 20 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@    
 21 MODULE_LICENSE("GPL v2");                         
 22 MODULE_ALIAS_CRYPTO("sha1");                      
 23                                                   
 24 struct sha1_ce_state {                            
 25         struct sha1_state       sst;              
 26         u32                     finalize;         
 27 };                                                
 28                                                   
 29 extern const u32 sha1_ce_offsetof_count;          
 30 extern const u32 sha1_ce_offsetof_finalize;       
 31                                                   
 32 asmlinkage int __sha1_ce_transform(struct sha1    
 33                                    int blocks)    
 34                                                   
 35 static void sha1_ce_transform(struct sha1_stat    
 36                               int blocks)         
 37 {                                                 
 38         while (blocks) {                          
 39                 int rem;                          
 40                                                   
 41                 kernel_neon_begin();              
 42                 rem = __sha1_ce_transform(cont    
 43                                                   
 44                                                   
 45                 kernel_neon_end();                
 46                 src += (blocks - rem) * SHA1_B    
 47                 blocks = rem;                     
 48         }                                         
 49 }                                                 
 50                                                   
 51 const u32 sha1_ce_offsetof_count = offsetof(st    
 52 const u32 sha1_ce_offsetof_finalize = offsetof    
 53                                                   
 54 static int sha1_ce_update(struct shash_desc *d    
 55                           unsigned int len)       
 56 {                                                 
 57         struct sha1_ce_state *sctx = shash_des    
 58                                                   
 59         if (!crypto_simd_usable())                
 60                 return crypto_sha1_update(desc    
 61                                                   
 62         sctx->finalize = 0;                       
 63         sha1_base_do_update(desc, data, len, s    
 64                                                   
 65         return 0;                                 
 66 }                                                 
 67                                                   
 68 static int sha1_ce_finup(struct shash_desc *de    
 69                          unsigned int len, u8     
 70 {                                                 
 71         struct sha1_ce_state *sctx = shash_des    
 72         bool finalize = !sctx->sst.count && !(    
 73                                                   
 74         if (!crypto_simd_usable())                
 75                 return crypto_sha1_finup(desc,    
 76                                                   
 77         /*                                        
 78          * Allow the asm code to perform the f    
 79          * partial data and the input is a rou    
 80          */                                       
 81         sctx->finalize = finalize;                
 82                                                   
 83         sha1_base_do_update(desc, data, len, s    
 84         if (!finalize)                            
 85                 sha1_base_do_finalize(desc, sh    
 86         return sha1_base_finish(desc, out);       
 87 }                                                 
 88                                                   
 89 static int sha1_ce_final(struct shash_desc *de    
 90 {                                                 
 91         struct sha1_ce_state *sctx = shash_des    
 92                                                   
 93         if (!crypto_simd_usable())                
 94                 return crypto_sha1_finup(desc,    
 95                                                   
 96         sctx->finalize = 0;                       
 97         sha1_base_do_finalize(desc, sha1_ce_tr    
 98         return sha1_base_finish(desc, out);       
 99 }                                                 
100                                                   
101 static int sha1_ce_export(struct shash_desc *d    
102 {                                                 
103         struct sha1_ce_state *sctx = shash_des    
104                                                   
105         memcpy(out, &sctx->sst, sizeof(struct     
106         return 0;                                 
107 }                                                 
108                                                   
109 static int sha1_ce_import(struct shash_desc *d    
110 {                                                 
111         struct sha1_ce_state *sctx = shash_des    
112                                                   
113         memcpy(&sctx->sst, in, sizeof(struct s    
114         sctx->finalize = 0;                       
115         return 0;                                 
116 }                                                 
117                                                   
118 static struct shash_alg alg = {                   
119         .init                   = sha1_base_in    
120         .update                 = sha1_ce_upda    
121         .final                  = sha1_ce_fina    
122         .finup                  = sha1_ce_finu    
123         .import                 = sha1_ce_impo    
124         .export                 = sha1_ce_expo    
125         .descsize               = sizeof(struc    
126         .statesize              = sizeof(struc    
127         .digestsize             = SHA1_DIGEST_    
128         .base                   = {               
129                 .cra_name               = "sha    
130                 .cra_driver_name        = "sha    
131                 .cra_priority           = 200,    
132                 .cra_blocksize          = SHA1    
133                 .cra_module             = THIS    
134         }                                         
135 };                                                
136                                                   
137 static int __init sha1_ce_mod_init(void)          
138 {                                                 
139         return crypto_register_shash(&alg);       
140 }                                                 
141                                                   
142 static void __exit sha1_ce_mod_fini(void)         
143 {                                                 
144         crypto_unregister_shash(&alg);            
145 }                                                 
146                                                   
147 module_cpu_feature_match(SHA1, sha1_ce_mod_ini    
148 module_exit(sha1_ce_mod_fini);                    
149                                                   

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