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

TOMOYO Linux Cross Reference
Linux/arch/riscv/crypto/aes-macros.S

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/riscv/crypto/aes-macros.S (Version linux-6.12-rc7) and /arch/m68k/crypto/aes-macros.S (Version linux-5.19.17)


  1 /* SPDX-License-Identifier: Apache-2.0 OR BSD-    
  2 //                                                
  3 // This file is dual-licensed, meaning that yo    
  4 // choice of either of the following two licen    
  5 //                                                
  6 // Copyright 2023 The OpenSSL Project Authors.    
  7 //                                                
  8 // Licensed under the Apache License 2.0 (the     
  9 // a copy in the file LICENSE in the source di    
 10 // https://www.openssl.org/source/license.html    
 11 //                                                
 12 // or                                             
 13 //                                                
 14 // Copyright (c) 2023, Christoph Müllner <chri    
 15 // Copyright (c) 2023, Phoebe Chen <phoebe.chen    
 16 // Copyright (c) 2023, Jerry Shih <jerry.shih@s    
 17 // Copyright 2024 Google LLC                      
 18 // All rights reserved.                           
 19 //                                                
 20 // Redistribution and use in source and binary    
 21 // modification, are permitted provided that t    
 22 // are met:                                       
 23 // 1. Redistributions of source code must reta    
 24 //    notice, this list of conditions and the     
 25 // 2. Redistributions in binary form must repr    
 26 //    notice, this list of conditions and the     
 27 //    documentation and/or other materials pro    
 28 //                                                
 29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT     
 30 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTI    
 31 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCH    
 32 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO     
 33 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIR    
 34 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGE    
 35 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS    
 36 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION)    
 37 // THEORY OF LIABILITY, WHETHER IN CONTRACT, S    
 38 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING    
 39 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE PO    
 40                                                   
 41 // This file contains macros that are shared b    
 42 // generated code of these macros depends on t    
 43 // - RV64I                                        
 44 // - RISC-V Vector ('V') with VLEN >= 128         
 45 // - RISC-V Vector AES block cipher extension     
 46                                                   
 47 // Loads the AES round keys from \keyp into ve    
 48 // specific to the length of the key.  Specifi    
 49 //   - If AES-128, loads round keys into v1-v1    
 50 //   - If AES-192, loads round keys into v1-v1    
 51 //   - If AES-256, loads round keys into v1-v1    
 52 //                                                
 53 // Also sets vl=4 and vtype=e32,m1,ta,ma.  Clo    
 54 .macro  aes_begin       keyp, label128, label1    
 55         lwu             t0, 480(\keyp)  // t0     
 56         li              t1, 24          // t1     
 57         vsetivli        zero, 4, e32, m1, ta,     
 58         vle32.v         v1, (\keyp)               
 59         addi            \keyp, \keyp, 16          
 60         vle32.v         v2, (\keyp)               
 61         addi            \keyp, \keyp, 16          
 62         vle32.v         v3, (\keyp)               
 63         addi            \keyp, \keyp, 16          
 64         vle32.v         v4, (\keyp)               
 65         addi            \keyp, \keyp, 16          
 66         vle32.v         v5, (\keyp)               
 67         addi            \keyp, \keyp, 16          
 68         vle32.v         v6, (\keyp)               
 69         addi            \keyp, \keyp, 16          
 70         vle32.v         v7, (\keyp)               
 71         addi            \keyp, \keyp, 16          
 72         vle32.v         v8, (\keyp)               
 73         addi            \keyp, \keyp, 16          
 74         vle32.v         v9, (\keyp)               
 75         addi            \keyp, \keyp, 16          
 76         vle32.v         v10, (\keyp)              
 77         addi            \keyp, \keyp, 16          
 78         vle32.v         v11, (\keyp)              
 79         blt             t0, t1, \label128         
 80         addi            \keyp, \keyp, 16          
 81         vle32.v         v12, (\keyp)              
 82         addi            \keyp, \keyp, 16          
 83         vle32.v         v13, (\keyp)              
 84         beq             t0, t1, \label192         
 85         // Else, it's AES-256.                    
 86         addi            \keyp, \keyp, 16          
 87         vle32.v         v14, (\keyp)              
 88         addi            \keyp, \keyp, 16          
 89         vle32.v         v15, (\keyp)              
 90 .endm                                             
 91                                                   
 92 // Encrypts \data using zvkned instructions, u    
 93 // v1-v11 (for AES-128), v1-v13 (for AES-192),    
 94 // is the AES key length in bits.  vl and vtyp    
 95 // appropriately.  Note that if vl > 4, multip    
 96 .macro  aes_encrypt     data, keylen              
 97         vaesz.vs        \data, v1                 
 98         vaesem.vs       \data, v2                 
 99         vaesem.vs       \data, v3                 
100         vaesem.vs       \data, v4                 
101         vaesem.vs       \data, v5                 
102         vaesem.vs       \data, v6                 
103         vaesem.vs       \data, v7                 
104         vaesem.vs       \data, v8                 
105         vaesem.vs       \data, v9                 
106         vaesem.vs       \data, v10                
107 .if \keylen == 128                                
108         vaesef.vs       \data, v11                
109 .elseif \keylen == 192                            
110         vaesem.vs       \data, v11                
111         vaesem.vs       \data, v12                
112         vaesef.vs       \data, v13                
113 .else                                             
114         vaesem.vs       \data, v11                
115         vaesem.vs       \data, v12                
116         vaesem.vs       \data, v13                
117         vaesem.vs       \data, v14                
118         vaesef.vs       \data, v15                
119 .endif                                            
120 .endm                                             
121                                                   
122 // Same as aes_encrypt, but decrypts instead o    
123 .macro  aes_decrypt     data, keylen              
124 .if \keylen == 128                                
125         vaesz.vs        \data, v11                
126 .elseif \keylen == 192                            
127         vaesz.vs        \data, v13                
128         vaesdm.vs       \data, v12                
129         vaesdm.vs       \data, v11                
130 .else                                             
131         vaesz.vs        \data, v15                
132         vaesdm.vs       \data, v14                
133         vaesdm.vs       \data, v13                
134         vaesdm.vs       \data, v12                
135         vaesdm.vs       \data, v11                
136 .endif                                            
137         vaesdm.vs       \data, v10                
138         vaesdm.vs       \data, v9                 
139         vaesdm.vs       \data, v8                 
140         vaesdm.vs       \data, v7                 
141         vaesdm.vs       \data, v6                 
142         vaesdm.vs       \data, v5                 
143         vaesdm.vs       \data, v4                 
144         vaesdm.vs       \data, v3                 
145         vaesdm.vs       \data, v2                 
146         vaesdf.vs       \data, v1                 
147 .endm                                             
148                                                   
149 // Expands to aes_encrypt or aes_decrypt accor    
150 .macro  aes_crypt       data, enc, keylen         
151 .if \enc                                          
152         aes_encrypt     \data, \keylen            
153 .else                                             
154         aes_decrypt     \data, \keylen            
155 .endif                                            
156 .endm                                             
                                                      

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