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

TOMOYO Linux Cross Reference
Linux/arch/s390/crypto/sha_common.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/sha_common.c (Architecture sparc) and /arch/mips/crypto/sha_common.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0+                1 
  2 /*                                                
  3  * Cryptographic API.                             
  4  *                                                
  5  * s390 generic implementation of the SHA Secu    
  6  *                                                
  7  * Copyright IBM Corp. 2007                       
  8  * Author(s): Jan Glauber (jang@de.ibm.com)       
  9  */                                               
 10                                                   
 11 #include <crypto/internal/hash.h>                 
 12 #include <linux/module.h>                         
 13 #include <asm/cpacf.h>                            
 14 #include "sha.h"                                  
 15                                                   
 16 int s390_sha_update(struct shash_desc *desc, c    
 17 {                                                 
 18         struct s390_sha_ctx *ctx = shash_desc_    
 19         unsigned int bsize = crypto_shash_bloc    
 20         unsigned int index, n;                    
 21         int fc;                                   
 22                                                   
 23         /* how much is already in the buffer?     
 24         index = ctx->count % bsize;               
 25         ctx->count += len;                        
 26                                                   
 27         if ((index + len) < bsize)                
 28                 goto store;                       
 29                                                   
 30         fc = ctx->func;                           
 31         if (ctx->first_message_part)              
 32                 fc |= test_facility(86) ? CPAC    
 33                                                   
 34         /* process one stored block */            
 35         if (index) {                              
 36                 memcpy(ctx->buf + index, data,    
 37                 cpacf_kimd(fc, ctx->state, ctx    
 38                 ctx->first_message_part = 0;      
 39                 fc &= ~CPACF_KIMD_NIP;            
 40                 data += bsize - index;            
 41                 len -= bsize - index;             
 42                 index = 0;                        
 43         }                                         
 44                                                   
 45         /* process as many blocks as possible     
 46         if (len >= bsize) {                       
 47                 n = (len / bsize) * bsize;        
 48                 cpacf_kimd(fc, ctx->state, dat    
 49                 ctx->first_message_part = 0;      
 50                 data += n;                        
 51                 len -= n;                         
 52         }                                         
 53 store:                                            
 54         if (len)                                  
 55                 memcpy(ctx->buf + index , data    
 56                                                   
 57         return 0;                                 
 58 }                                                 
 59 EXPORT_SYMBOL_GPL(s390_sha_update);               
 60                                                   
 61 static int s390_crypto_shash_parmsize(int func    
 62 {                                                 
 63         switch (func) {                           
 64         case CPACF_KLMD_SHA_1:                    
 65                 return 20;                        
 66         case CPACF_KLMD_SHA_256:                  
 67                 return 32;                        
 68         case CPACF_KLMD_SHA_512:                  
 69                 return 64;                        
 70         case CPACF_KLMD_SHA3_224:                 
 71         case CPACF_KLMD_SHA3_256:                 
 72         case CPACF_KLMD_SHA3_384:                 
 73         case CPACF_KLMD_SHA3_512:                 
 74                 return 200;                       
 75         default:                                  
 76                 return -EINVAL;                   
 77         }                                         
 78 }                                                 
 79                                                   
 80 int s390_sha_final(struct shash_desc *desc, u8    
 81 {                                                 
 82         struct s390_sha_ctx *ctx = shash_desc_    
 83         unsigned int bsize = crypto_shash_bloc    
 84         u64 bits;                                 
 85         unsigned int n;                           
 86         int mbl_offset, fc;                       
 87                                                   
 88         n = ctx->count % bsize;                   
 89         bits = ctx->count * 8;                    
 90         mbl_offset = s390_crypto_shash_parmsiz    
 91         if (mbl_offset < 0)                       
 92                 return -EINVAL;                   
 93                                                   
 94         mbl_offset = mbl_offset / sizeof(u32);    
 95                                                   
 96         /* set total msg bit length (mbl) in C    
 97         switch (ctx->func) {                      
 98         case CPACF_KLMD_SHA_1:                    
 99         case CPACF_KLMD_SHA_256:                  
100                 memcpy(ctx->state + mbl_offset    
101                 break;                            
102         case CPACF_KLMD_SHA_512:                  
103                 /*                                
104                  * the SHA512 parmblock has a     
105                  * high-order u64 field, copy     
106                  */                               
107                 memset(ctx->state + mbl_offset    
108                 mbl_offset += sizeof(u64) / si    
109                 memcpy(ctx->state + mbl_offset    
110                 break;                            
111         case CPACF_KLMD_SHA3_224:                 
112         case CPACF_KLMD_SHA3_256:                 
113         case CPACF_KLMD_SHA3_384:                 
114         case CPACF_KLMD_SHA3_512:                 
115                 break;                            
116         default:                                  
117                 return -EINVAL;                   
118         }                                         
119                                                   
120         fc = ctx->func;                           
121         fc |= test_facility(86) ? CPACF_KLMD_D    
122         if (ctx->first_message_part)              
123                 fc |= CPACF_KLMD_NIP;             
124         cpacf_klmd(fc, ctx->state, ctx->buf, n    
125                                                   
126         /* copy digest to out */                  
127         memcpy(out, ctx->state, crypto_shash_d    
128         /* wipe context */                        
129         memset(ctx, 0, sizeof *ctx);              
130                                                   
131         return 0;                                 
132 }                                                 
133 EXPORT_SYMBOL_GPL(s390_sha_final);                
134                                                   
135 MODULE_LICENSE("GPL");                            
136 MODULE_DESCRIPTION("s390 SHA cipher common fun    
137                                                   

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