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

TOMOYO Linux Cross Reference
Linux/arch/s390/crypto/chacha-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/s390/crypto/chacha-glue.c (Version linux-6.12-rc7) and /arch/alpha/crypto/chacha-glue.c (Version linux-6.9.12)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * s390 ChaCha stream cipher.                     
  4  *                                                
  5  * Copyright IBM Corp. 2021                       
  6  */                                               
  7                                                   
  8 #define KMSG_COMPONENT "chacha_s390"              
  9 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt       
 10                                                   
 11 #include <crypto/internal/chacha.h>               
 12 #include <crypto/internal/skcipher.h>             
 13 #include <crypto/algapi.h>                        
 14 #include <linux/cpufeature.h>                     
 15 #include <linux/kernel.h>                         
 16 #include <linux/module.h>                         
 17 #include <linux/sizes.h>                          
 18 #include <asm/fpu.h>                              
 19 #include "chacha-s390.h"                          
 20                                                   
 21 static void chacha20_crypt_s390(u32 *state, u8    
 22                                 unsigned int n    
 23                                 u32 *counter)     
 24 {                                                 
 25         DECLARE_KERNEL_FPU_ONSTACK32(vxstate);    
 26                                                   
 27         kernel_fpu_begin(&vxstate, KERNEL_VXR)    
 28         chacha20_vx(dst, src, nbytes, key, cou    
 29         kernel_fpu_end(&vxstate, KERNEL_VXR);     
 30                                                   
 31         *counter += round_up(nbytes, CHACHA_BL    
 32 }                                                 
 33                                                   
 34 static int chacha20_s390(struct skcipher_reque    
 35 {                                                 
 36         struct crypto_skcipher *tfm = crypto_s    
 37         struct chacha_ctx *ctx = crypto_skciph    
 38         u32 state[CHACHA_STATE_WORDS] __aligne    
 39         struct skcipher_walk walk;                
 40         unsigned int nbytes;                      
 41         int rc;                                   
 42                                                   
 43         rc = skcipher_walk_virt(&walk, req, fa    
 44         chacha_init_generic(state, ctx->key, r    
 45                                                   
 46         while (walk.nbytes > 0) {                 
 47                 nbytes = walk.nbytes;             
 48                 if (nbytes < walk.total)          
 49                         nbytes = round_down(nb    
 50                                                   
 51                 if (nbytes <= CHACHA_BLOCK_SIZ    
 52                         chacha_crypt_generic(s    
 53                                              w    
 54                                              c    
 55                 } else {                          
 56                         chacha20_crypt_s390(st    
 57                                             wa    
 58                                             &s    
 59                 }                                 
 60                 rc = skcipher_walk_done(&walk,    
 61         }                                         
 62         return rc;                                
 63 }                                                 
 64                                                   
 65 void hchacha_block_arch(const u32 *state, u32     
 66 {                                                 
 67         /* TODO: implement hchacha_block_arch(    
 68         hchacha_block_generic(state, stream, n    
 69 }                                                 
 70 EXPORT_SYMBOL(hchacha_block_arch);                
 71                                                   
 72 void chacha_init_arch(u32 *state, const u32 *k    
 73 {                                                 
 74         chacha_init_generic(state, key, iv);      
 75 }                                                 
 76 EXPORT_SYMBOL(chacha_init_arch);                  
 77                                                   
 78 void chacha_crypt_arch(u32 *state, u8 *dst, co    
 79                        unsigned int bytes, int    
 80 {                                                 
 81         /* s390 chacha20 implementation has 20    
 82          * it cannot handle a block of data or    
 83          * it can handle data of arbitrary siz    
 84          */                                       
 85         if (bytes <= CHACHA_BLOCK_SIZE || nrou    
 86                 chacha_crypt_generic(state, ds    
 87         else                                      
 88                 chacha20_crypt_s390(state, dst    
 89                                     &state[4],    
 90 }                                                 
 91 EXPORT_SYMBOL(chacha_crypt_arch);                 
 92                                                   
 93 static struct skcipher_alg chacha_algs[] = {      
 94         {                                         
 95                 .base.cra_name          = "cha    
 96                 .base.cra_driver_name   = "cha    
 97                 .base.cra_priority      = 900,    
 98                 .base.cra_blocksize     = 1,      
 99                 .base.cra_ctxsize       = size    
100                 .base.cra_module        = THIS    
101                                                   
102                 .min_keysize            = CHAC    
103                 .max_keysize            = CHAC    
104                 .ivsize                 = CHAC    
105                 .chunksize              = CHAC    
106                 .setkey                 = chac    
107                 .encrypt                = chac    
108                 .decrypt                = chac    
109         }                                         
110 };                                                
111                                                   
112 static int __init chacha_mod_init(void)           
113 {                                                 
114         return IS_REACHABLE(CONFIG_CRYPTO_SKCI    
115                 crypto_register_skciphers(chac    
116 }                                                 
117                                                   
118 static void __exit chacha_mod_fini(void)          
119 {                                                 
120         if (IS_REACHABLE(CONFIG_CRYPTO_SKCIPHE    
121                 crypto_unregister_skciphers(ch    
122 }                                                 
123                                                   
124 module_cpu_feature_match(S390_CPU_FEATURE_VXRS    
125 module_exit(chacha_mod_fini);                     
126                                                   
127 MODULE_DESCRIPTION("ChaCha20 stream cipher");     
128 MODULE_LICENSE("GPL v2");                         
129                                                   
130 MODULE_ALIAS_CRYPTO("chacha20");                  
131                                                   

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