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

TOMOYO Linux Cross Reference
Linux/arch/s390/crypto/sha256_s390.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/s390/crypto/sha256_s390.c (Architecture ppc) and /arch/sparc/crypto/sha256_s390.c (Architecture sparc)


  1 // SPDX-License-Identifier: GPL-2.0+                1 
  2 /*                                                
  3  * Cryptographic API.                             
  4  *                                                
  5  * s390 implementation of the SHA256 and SHA22    
  6  *                                                
  7  * s390 Version:                                  
  8  *   Copyright IBM Corp. 2005, 2011               
  9  *   Author(s): Jan Glauber (jang@de.ibm.com)     
 10  */                                               
 11 #include <crypto/internal/hash.h>                 
 12 #include <linux/init.h>                           
 13 #include <linux/module.h>                         
 14 #include <linux/cpufeature.h>                     
 15 #include <crypto/sha2.h>                          
 16 #include <asm/cpacf.h>                            
 17                                                   
 18 #include "sha.h"                                  
 19                                                   
 20 static int s390_sha256_init(struct shash_desc     
 21 {                                                 
 22         struct s390_sha_ctx *sctx = shash_desc    
 23                                                   
 24         sctx->state[0] = SHA256_H0;               
 25         sctx->state[1] = SHA256_H1;               
 26         sctx->state[2] = SHA256_H2;               
 27         sctx->state[3] = SHA256_H3;               
 28         sctx->state[4] = SHA256_H4;               
 29         sctx->state[5] = SHA256_H5;               
 30         sctx->state[6] = SHA256_H6;               
 31         sctx->state[7] = SHA256_H7;               
 32         sctx->count = 0;                          
 33         sctx->func = CPACF_KIMD_SHA_256;          
 34                                                   
 35         return 0;                                 
 36 }                                                 
 37                                                   
 38 static int sha256_export(struct shash_desc *de    
 39 {                                                 
 40         struct s390_sha_ctx *sctx = shash_desc    
 41         struct sha256_state *octx = out;          
 42                                                   
 43         octx->count = sctx->count;                
 44         memcpy(octx->state, sctx->state, sizeo    
 45         memcpy(octx->buf, sctx->buf, sizeof(oc    
 46         return 0;                                 
 47 }                                                 
 48                                                   
 49 static int sha256_import(struct shash_desc *de    
 50 {                                                 
 51         struct s390_sha_ctx *sctx = shash_desc    
 52         const struct sha256_state *ictx = in;     
 53                                                   
 54         sctx->count = ictx->count;                
 55         memcpy(sctx->state, ictx->state, sizeo    
 56         memcpy(sctx->buf, ictx->buf, sizeof(ic    
 57         sctx->func = CPACF_KIMD_SHA_256;          
 58         return 0;                                 
 59 }                                                 
 60                                                   
 61 static struct shash_alg sha256_alg = {            
 62         .digestsize     =       SHA256_DIGEST_    
 63         .init           =       s390_sha256_in    
 64         .update         =       s390_sha_updat    
 65         .final          =       s390_sha_final    
 66         .export         =       sha256_export,    
 67         .import         =       sha256_import,    
 68         .descsize       =       sizeof(struct     
 69         .statesize      =       sizeof(struct     
 70         .base           =       {                 
 71                 .cra_name       =       "sha25    
 72                 .cra_driver_name=       "sha25    
 73                 .cra_priority   =       300,      
 74                 .cra_blocksize  =       SHA256    
 75                 .cra_module     =       THIS_M    
 76         }                                         
 77 };                                                
 78                                                   
 79 static int s390_sha224_init(struct shash_desc     
 80 {                                                 
 81         struct s390_sha_ctx *sctx = shash_desc    
 82                                                   
 83         sctx->state[0] = SHA224_H0;               
 84         sctx->state[1] = SHA224_H1;               
 85         sctx->state[2] = SHA224_H2;               
 86         sctx->state[3] = SHA224_H3;               
 87         sctx->state[4] = SHA224_H4;               
 88         sctx->state[5] = SHA224_H5;               
 89         sctx->state[6] = SHA224_H6;               
 90         sctx->state[7] = SHA224_H7;               
 91         sctx->count = 0;                          
 92         sctx->func = CPACF_KIMD_SHA_256;          
 93                                                   
 94         return 0;                                 
 95 }                                                 
 96                                                   
 97 static struct shash_alg sha224_alg = {            
 98         .digestsize     =       SHA224_DIGEST_    
 99         .init           =       s390_sha224_in    
100         .update         =       s390_sha_updat    
101         .final          =       s390_sha_final    
102         .export         =       sha256_export,    
103         .import         =       sha256_import,    
104         .descsize       =       sizeof(struct     
105         .statesize      =       sizeof(struct     
106         .base           =       {                 
107                 .cra_name       =       "sha22    
108                 .cra_driver_name=       "sha22    
109                 .cra_priority   =       300,      
110                 .cra_blocksize  =       SHA224    
111                 .cra_module     =       THIS_M    
112         }                                         
113 };                                                
114                                                   
115 static int __init sha256_s390_init(void)          
116 {                                                 
117         int ret;                                  
118                                                   
119         if (!cpacf_query_func(CPACF_KIMD, CPAC    
120                 return -ENODEV;                   
121         ret = crypto_register_shash(&sha256_al    
122         if (ret < 0)                              
123                 goto out;                         
124         ret = crypto_register_shash(&sha224_al    
125         if (ret < 0)                              
126                 crypto_unregister_shash(&sha25    
127 out:                                              
128         return ret;                               
129 }                                                 
130                                                   
131 static void __exit sha256_s390_fini(void)         
132 {                                                 
133         crypto_unregister_shash(&sha224_alg);     
134         crypto_unregister_shash(&sha256_alg);     
135 }                                                 
136                                                   
137 module_cpu_feature_match(S390_CPU_FEATURE_MSA,    
138 module_exit(sha256_s390_fini);                    
139                                                   
140 MODULE_ALIAS_CRYPTO("sha256");                    
141 MODULE_ALIAS_CRYPTO("sha224");                    
142 MODULE_LICENSE("GPL");                            
143 MODULE_DESCRIPTION("SHA256 and SHA224 Secure H    
144                                                   

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