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

TOMOYO Linux Cross Reference
Linux/arch/arm64/crypto/sha2-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/sha2-ce-glue.c (Version linux-6.12-rc7) and /arch/ppc/crypto/sha2-ce-glue.c (Version linux-4.12.14)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * sha2-ce-glue.c - SHA-224/SHA-256 using ARMv    
  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/sha2.h>                          
 14 #include <crypto/sha256_base.h>                   
 15 #include <linux/cpufeature.h>                     
 16 #include <linux/crypto.h>                         
 17 #include <linux/module.h>                         
 18                                                   
 19 MODULE_DESCRIPTION("SHA-224/SHA-256 secure has    
 20 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@    
 21 MODULE_LICENSE("GPL v2");                         
 22 MODULE_ALIAS_CRYPTO("sha224");                    
 23 MODULE_ALIAS_CRYPTO("sha256");                    
 24                                                   
 25 struct sha256_ce_state {                          
 26         struct sha256_state     sst;              
 27         u32                     finalize;         
 28 };                                                
 29                                                   
 30 extern const u32 sha256_ce_offsetof_count;        
 31 extern const u32 sha256_ce_offsetof_finalize;     
 32                                                   
 33 asmlinkage int __sha256_ce_transform(struct sh    
 34                                      int block    
 35                                                   
 36 static void sha256_ce_transform(struct sha256_    
 37                                 int blocks)       
 38 {                                                 
 39         while (blocks) {                          
 40                 int rem;                          
 41                                                   
 42                 kernel_neon_begin();              
 43                 rem = __sha256_ce_transform(co    
 44                                                   
 45                                                   
 46                 kernel_neon_end();                
 47                 src += (blocks - rem) * SHA256    
 48                 blocks = rem;                     
 49         }                                         
 50 }                                                 
 51                                                   
 52 const u32 sha256_ce_offsetof_count = offsetof(    
 53                                                   
 54 const u32 sha256_ce_offsetof_finalize = offset    
 55                                                   
 56                                                   
 57 asmlinkage void sha256_block_data_order(u32 *d    
 58                                                   
 59 static void sha256_arm64_transform(struct sha2    
 60                                    int blocks)    
 61 {                                                 
 62         sha256_block_data_order(sst->state, sr    
 63 }                                                 
 64                                                   
 65 static int sha256_ce_update(struct shash_desc     
 66                             unsigned int len)     
 67 {                                                 
 68         struct sha256_ce_state *sctx = shash_d    
 69                                                   
 70         if (!crypto_simd_usable())                
 71                 return sha256_base_do_update(d    
 72                                              s    
 73                                                   
 74         sctx->finalize = 0;                       
 75         sha256_base_do_update(desc, data, len,    
 76                                                   
 77         return 0;                                 
 78 }                                                 
 79                                                   
 80 static int sha256_ce_finup(struct shash_desc *    
 81                            unsigned int len, u    
 82 {                                                 
 83         struct sha256_ce_state *sctx = shash_d    
 84         bool finalize = !sctx->sst.count && !(    
 85                                                   
 86         if (!crypto_simd_usable()) {              
 87                 if (len)                          
 88                         sha256_base_do_update(    
 89                                                   
 90                 sha256_base_do_finalize(desc,     
 91                 return sha256_base_finish(desc    
 92         }                                         
 93                                                   
 94         /*                                        
 95          * Allow the asm code to perform the f    
 96          * partial data and the input is a rou    
 97          */                                       
 98         sctx->finalize = finalize;                
 99                                                   
100         sha256_base_do_update(desc, data, len,    
101         if (!finalize)                            
102                 sha256_base_do_finalize(desc,     
103         return sha256_base_finish(desc, out);     
104 }                                                 
105                                                   
106 static int sha256_ce_final(struct shash_desc *    
107 {                                                 
108         struct sha256_ce_state *sctx = shash_d    
109                                                   
110         if (!crypto_simd_usable()) {              
111                 sha256_base_do_finalize(desc,     
112                 return sha256_base_finish(desc    
113         }                                         
114                                                   
115         sctx->finalize = 0;                       
116         sha256_base_do_finalize(desc, sha256_c    
117         return sha256_base_finish(desc, out);     
118 }                                                 
119                                                   
120 static int sha256_ce_digest(struct shash_desc     
121                             unsigned int len,     
122 {                                                 
123         sha256_base_init(desc);                   
124         return sha256_ce_finup(desc, data, len    
125 }                                                 
126                                                   
127 static int sha256_ce_export(struct shash_desc     
128 {                                                 
129         struct sha256_ce_state *sctx = shash_d    
130                                                   
131         memcpy(out, &sctx->sst, sizeof(struct     
132         return 0;                                 
133 }                                                 
134                                                   
135 static int sha256_ce_import(struct shash_desc     
136 {                                                 
137         struct sha256_ce_state *sctx = shash_d    
138                                                   
139         memcpy(&sctx->sst, in, sizeof(struct s    
140         sctx->finalize = 0;                       
141         return 0;                                 
142 }                                                 
143                                                   
144 static struct shash_alg algs[] = { {              
145         .init                   = sha224_base_    
146         .update                 = sha256_ce_up    
147         .final                  = sha256_ce_fi    
148         .finup                  = sha256_ce_fi    
149         .export                 = sha256_ce_ex    
150         .import                 = sha256_ce_im    
151         .descsize               = sizeof(struc    
152         .statesize              = sizeof(struc    
153         .digestsize             = SHA224_DIGES    
154         .base                   = {               
155                 .cra_name               = "sha    
156                 .cra_driver_name        = "sha    
157                 .cra_priority           = 200,    
158                 .cra_blocksize          = SHA2    
159                 .cra_module             = THIS    
160         }                                         
161 }, {                                              
162         .init                   = sha256_base_    
163         .update                 = sha256_ce_up    
164         .final                  = sha256_ce_fi    
165         .finup                  = sha256_ce_fi    
166         .digest                 = sha256_ce_di    
167         .export                 = sha256_ce_ex    
168         .import                 = sha256_ce_im    
169         .descsize               = sizeof(struc    
170         .statesize              = sizeof(struc    
171         .digestsize             = SHA256_DIGES    
172         .base                   = {               
173                 .cra_name               = "sha    
174                 .cra_driver_name        = "sha    
175                 .cra_priority           = 200,    
176                 .cra_blocksize          = SHA2    
177                 .cra_module             = THIS    
178         }                                         
179 } };                                              
180                                                   
181 static int __init sha2_ce_mod_init(void)          
182 {                                                 
183         return crypto_register_shashes(algs, A    
184 }                                                 
185                                                   
186 static void __exit sha2_ce_mod_fini(void)         
187 {                                                 
188         crypto_unregister_shashes(algs, ARRAY_    
189 }                                                 
190                                                   
191 module_cpu_feature_match(SHA2, sha2_ce_mod_ini    
192 module_exit(sha2_ce_mod_fini);                    
193                                                   

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