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

TOMOYO Linux Cross Reference
Linux/arch/x86/crypto/blowfish_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/x86/crypto/blowfish_glue.c (Architecture m68k) and /arch/mips/crypto/blowfish_glue.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * Glue Code for assembler optimized version o    
  4  *                                                
  5  * Copyright (c) 2011 Jussi Kivilinna <jussi.k    
  6  *                                                
  7  * CBC & ECB parts based on code (crypto/cbc.c    
  8  *   Copyright (c) 2006 Herbert Xu <herbert@go    
  9  */                                               
 10                                                   
 11 #include <crypto/algapi.h>                        
 12 #include <crypto/blowfish.h>                      
 13 #include <crypto/internal/skcipher.h>             
 14 #include <linux/crypto.h>                         
 15 #include <linux/init.h>                           
 16 #include <linux/module.h>                         
 17 #include <linux/types.h>                          
 18                                                   
 19 #include "ecb_cbc_helpers.h"                      
 20                                                   
 21 /* regular block cipher functions */              
 22 asmlinkage void blowfish_enc_blk(struct bf_ctx    
 23 asmlinkage void blowfish_dec_blk(struct bf_ctx    
 24                                                   
 25 /* 4-way parallel cipher functions */             
 26 asmlinkage void blowfish_enc_blk_4way(struct b    
 27                                       const u8    
 28 asmlinkage void __blowfish_dec_blk_4way(struct    
 29                                         const     
 30                                                   
 31 static inline void blowfish_dec_ecb_4way(struc    
 32                                              c    
 33 {                                                 
 34         return __blowfish_dec_blk_4way(ctx, ds    
 35 }                                                 
 36                                                   
 37 static inline void blowfish_dec_cbc_4way(struc    
 38                                              c    
 39 {                                                 
 40         return __blowfish_dec_blk_4way(ctx, ds    
 41 }                                                 
 42                                                   
 43 static void blowfish_encrypt(struct crypto_tfm    
 44 {                                                 
 45         blowfish_enc_blk(crypto_tfm_ctx(tfm),     
 46 }                                                 
 47                                                   
 48 static void blowfish_decrypt(struct crypto_tfm    
 49 {                                                 
 50         blowfish_dec_blk(crypto_tfm_ctx(tfm),     
 51 }                                                 
 52                                                   
 53 static int blowfish_setkey_skcipher(struct cry    
 54                                     const u8 *    
 55 {                                                 
 56         return blowfish_setkey(&tfm->base, key    
 57 }                                                 
 58                                                   
 59 static int ecb_encrypt(struct skcipher_request    
 60 {                                                 
 61         ECB_WALK_START(req, BF_BLOCK_SIZE, -1)    
 62         ECB_BLOCK(4, blowfish_enc_blk_4way);      
 63         ECB_BLOCK(1, blowfish_enc_blk);           
 64         ECB_WALK_END();                           
 65 }                                                 
 66                                                   
 67 static int ecb_decrypt(struct skcipher_request    
 68 {                                                 
 69         ECB_WALK_START(req, BF_BLOCK_SIZE, -1)    
 70         ECB_BLOCK(4, blowfish_dec_ecb_4way);      
 71         ECB_BLOCK(1, blowfish_dec_blk);           
 72         ECB_WALK_END();                           
 73 }                                                 
 74                                                   
 75 static int cbc_encrypt(struct skcipher_request    
 76 {                                                 
 77         CBC_WALK_START(req, BF_BLOCK_SIZE, -1)    
 78         CBC_ENC_BLOCK(blowfish_enc_blk);          
 79         CBC_WALK_END();                           
 80 }                                                 
 81                                                   
 82 static int cbc_decrypt(struct skcipher_request    
 83 {                                                 
 84         CBC_WALK_START(req, BF_BLOCK_SIZE, -1)    
 85         CBC_DEC_BLOCK(4, blowfish_dec_cbc_4way    
 86         CBC_DEC_BLOCK(1, blowfish_dec_blk);       
 87         CBC_WALK_END();                           
 88 }                                                 
 89                                                   
 90 static struct crypto_alg bf_cipher_alg = {        
 91         .cra_name               = "blowfish",     
 92         .cra_driver_name        = "blowfish-as    
 93         .cra_priority           = 200,            
 94         .cra_flags              = CRYPTO_ALG_T    
 95         .cra_blocksize          = BF_BLOCK_SIZ    
 96         .cra_ctxsize            = sizeof(struc    
 97         .cra_alignmask          = 0,              
 98         .cra_module             = THIS_MODULE,    
 99         .cra_u = {                                
100                 .cipher = {                       
101                         .cia_min_keysize          
102                         .cia_max_keysize          
103                         .cia_setkey               
104                         .cia_encrypt              
105                         .cia_decrypt              
106                 }                                 
107         }                                         
108 };                                                
109                                                   
110 static struct skcipher_alg bf_skcipher_algs[]     
111         {                                         
112                 .base.cra_name          = "ecb    
113                 .base.cra_driver_name   = "ecb    
114                 .base.cra_priority      = 300,    
115                 .base.cra_blocksize     = BF_B    
116                 .base.cra_ctxsize       = size    
117                 .base.cra_module        = THIS    
118                 .min_keysize            = BF_M    
119                 .max_keysize            = BF_M    
120                 .setkey                 = blow    
121                 .encrypt                = ecb_    
122                 .decrypt                = ecb_    
123         }, {                                      
124                 .base.cra_name          = "cbc    
125                 .base.cra_driver_name   = "cbc    
126                 .base.cra_priority      = 300,    
127                 .base.cra_blocksize     = BF_B    
128                 .base.cra_ctxsize       = size    
129                 .base.cra_module        = THIS    
130                 .min_keysize            = BF_M    
131                 .max_keysize            = BF_M    
132                 .ivsize                 = BF_B    
133                 .setkey                 = blow    
134                 .encrypt                = cbc_    
135                 .decrypt                = cbc_    
136         },                                        
137 };                                                
138                                                   
139 static bool is_blacklisted_cpu(void)              
140 {                                                 
141         if (boot_cpu_data.x86_vendor != X86_VE    
142                 return false;                     
143                                                   
144         if (boot_cpu_data.x86 == 0x0f) {          
145                 /*                                
146                  * On Pentium 4, blowfish-x86_    
147                  * implementation because use     
148                  * slow on P4). Therefore blac    
149                  */                               
150                 return true;                      
151         }                                         
152                                                   
153         return false;                             
154 }                                                 
155                                                   
156 static int force;                                 
157 module_param(force, int, 0);                      
158 MODULE_PARM_DESC(force, "Force module load, ig    
159                                                   
160 static int __init blowfish_init(void)             
161 {                                                 
162         int err;                                  
163                                                   
164         if (!force && is_blacklisted_cpu()) {     
165                 printk(KERN_INFO                  
166                         "blowfish-x86_64: perf    
167                         "would be suboptimal:     
168                         "blowfish-x86_64.\n");    
169                 return -ENODEV;                   
170         }                                         
171                                                   
172         err = crypto_register_alg(&bf_cipher_a    
173         if (err)                                  
174                 return err;                       
175                                                   
176         err = crypto_register_skciphers(bf_skc    
177                                         ARRAY_    
178         if (err)                                  
179                 crypto_unregister_alg(&bf_ciph    
180                                                   
181         return err;                               
182 }                                                 
183                                                   
184 static void __exit blowfish_fini(void)            
185 {                                                 
186         crypto_unregister_alg(&bf_cipher_alg);    
187         crypto_unregister_skciphers(bf_skciphe    
188                                     ARRAY_SIZE    
189 }                                                 
190                                                   
191 module_init(blowfish_init);                       
192 module_exit(blowfish_fini);                       
193                                                   
194 MODULE_LICENSE("GPL");                            
195 MODULE_DESCRIPTION("Blowfish Cipher Algorithm,    
196 MODULE_ALIAS_CRYPTO("blowfish");                  
197 MODULE_ALIAS_CRYPTO("blowfish-asm");              
198                                                   

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