David S. Miller | c5aac2d | 2012-08-25 22:37:23 -0700 | [diff] [blame] | 1 | #include <linux/linkage.h> |
| 2 | #include <asm/visasm.h> |
| 3 | |
David S. Miller | 7cff82f | 2012-08-31 12:11:51 -0700 | [diff] [blame] | 4 | #include "opcodes.h" |
David S. Miller | c5aac2d | 2012-08-25 22:37:23 -0700 | [diff] [blame] | 5 | |
| 6 | .align 32 |
| 7 | ENTRY(des_sparc64_key_expand) |
| 8 | /* %o0=input_key, %o1=output_key */ |
| 9 | VISEntryHalf |
| 10 | ld [%o0 + 0x00], %f0 |
| 11 | ld [%o0 + 0x04], %f1 |
| 12 | DES_KEXPAND(0, 0, 0) |
| 13 | DES_KEXPAND(0, 1, 2) |
| 14 | DES_KEXPAND(2, 3, 6) |
| 15 | DES_KEXPAND(2, 2, 4) |
| 16 | DES_KEXPAND(6, 3, 10) |
| 17 | DES_KEXPAND(6, 2, 8) |
| 18 | DES_KEXPAND(10, 3, 14) |
| 19 | DES_KEXPAND(10, 2, 12) |
| 20 | DES_KEXPAND(14, 1, 16) |
| 21 | DES_KEXPAND(16, 3, 20) |
| 22 | DES_KEXPAND(16, 2, 18) |
| 23 | DES_KEXPAND(20, 3, 24) |
| 24 | DES_KEXPAND(20, 2, 22) |
| 25 | DES_KEXPAND(24, 3, 28) |
| 26 | DES_KEXPAND(24, 2, 26) |
| 27 | DES_KEXPAND(28, 1, 30) |
| 28 | std %f0, [%o1 + 0x00] |
| 29 | std %f2, [%o1 + 0x08] |
| 30 | std %f4, [%o1 + 0x10] |
| 31 | std %f6, [%o1 + 0x18] |
| 32 | std %f8, [%o1 + 0x20] |
| 33 | std %f10, [%o1 + 0x28] |
| 34 | std %f12, [%o1 + 0x30] |
| 35 | std %f14, [%o1 + 0x38] |
| 36 | std %f16, [%o1 + 0x40] |
| 37 | std %f18, [%o1 + 0x48] |
| 38 | std %f20, [%o1 + 0x50] |
| 39 | std %f22, [%o1 + 0x58] |
| 40 | std %f24, [%o1 + 0x60] |
| 41 | std %f26, [%o1 + 0x68] |
| 42 | std %f28, [%o1 + 0x70] |
| 43 | std %f30, [%o1 + 0x78] |
| 44 | retl |
| 45 | VISExitHalf |
| 46 | ENDPROC(des_sparc64_key_expand) |
| 47 | |
| 48 | .align 32 |
| 49 | ENTRY(des_sparc64_crypt) |
| 50 | /* %o0=key, %o1=input, %o2=output */ |
| 51 | VISEntry |
| 52 | ldd [%o1 + 0x00], %f32 |
| 53 | ldd [%o0 + 0x00], %f0 |
| 54 | ldd [%o0 + 0x08], %f2 |
| 55 | ldd [%o0 + 0x10], %f4 |
| 56 | ldd [%o0 + 0x18], %f6 |
| 57 | ldd [%o0 + 0x20], %f8 |
| 58 | ldd [%o0 + 0x28], %f10 |
| 59 | ldd [%o0 + 0x30], %f12 |
| 60 | ldd [%o0 + 0x38], %f14 |
| 61 | ldd [%o0 + 0x40], %f16 |
| 62 | ldd [%o0 + 0x48], %f18 |
| 63 | ldd [%o0 + 0x50], %f20 |
| 64 | ldd [%o0 + 0x58], %f22 |
| 65 | ldd [%o0 + 0x60], %f24 |
| 66 | ldd [%o0 + 0x68], %f26 |
| 67 | ldd [%o0 + 0x70], %f28 |
| 68 | ldd [%o0 + 0x78], %f30 |
| 69 | DES_IP(32, 32) |
| 70 | DES_ROUND(0, 2, 32, 32) |
| 71 | DES_ROUND(4, 6, 32, 32) |
| 72 | DES_ROUND(8, 10, 32, 32) |
| 73 | DES_ROUND(12, 14, 32, 32) |
| 74 | DES_ROUND(16, 18, 32, 32) |
| 75 | DES_ROUND(20, 22, 32, 32) |
| 76 | DES_ROUND(24, 26, 32, 32) |
| 77 | DES_ROUND(28, 30, 32, 32) |
| 78 | DES_IIP(32, 32) |
| 79 | std %f32, [%o2 + 0x00] |
| 80 | retl |
| 81 | VISExit |
| 82 | ENDPROC(des_sparc64_crypt) |
| 83 | |
| 84 | .align 32 |
| 85 | ENTRY(des_sparc64_load_keys) |
| 86 | /* %o0=key */ |
| 87 | VISEntry |
| 88 | ldd [%o0 + 0x00], %f0 |
| 89 | ldd [%o0 + 0x08], %f2 |
| 90 | ldd [%o0 + 0x10], %f4 |
| 91 | ldd [%o0 + 0x18], %f6 |
| 92 | ldd [%o0 + 0x20], %f8 |
| 93 | ldd [%o0 + 0x28], %f10 |
| 94 | ldd [%o0 + 0x30], %f12 |
| 95 | ldd [%o0 + 0x38], %f14 |
| 96 | ldd [%o0 + 0x40], %f16 |
| 97 | ldd [%o0 + 0x48], %f18 |
| 98 | ldd [%o0 + 0x50], %f20 |
| 99 | ldd [%o0 + 0x58], %f22 |
| 100 | ldd [%o0 + 0x60], %f24 |
| 101 | ldd [%o0 + 0x68], %f26 |
| 102 | ldd [%o0 + 0x70], %f28 |
| 103 | retl |
| 104 | ldd [%o0 + 0x78], %f30 |
| 105 | ENDPROC(des_sparc64_load_keys) |
| 106 | |
| 107 | .align 32 |
| 108 | ENTRY(des_sparc64_ecb_crypt) |
| 109 | /* %o0=input, %o1=output, %o2=len */ |
| 110 | 1: ldd [%o0 + 0x00], %f32 |
| 111 | add %o0, 0x08, %o0 |
| 112 | DES_IP(32, 32) |
| 113 | DES_ROUND(0, 2, 32, 32) |
| 114 | DES_ROUND(4, 6, 32, 32) |
| 115 | DES_ROUND(8, 10, 32, 32) |
| 116 | DES_ROUND(12, 14, 32, 32) |
| 117 | DES_ROUND(16, 18, 32, 32) |
| 118 | DES_ROUND(20, 22, 32, 32) |
| 119 | DES_ROUND(24, 26, 32, 32) |
| 120 | DES_ROUND(28, 30, 32, 32) |
| 121 | DES_IIP(32, 32) |
| 122 | std %f32, [%o1 + 0x00] |
| 123 | subcc %o2, 0x08, %o2 |
| 124 | bne,pt %icc, 1b |
| 125 | add %o1, 0x08, %o1 |
| 126 | retl |
| 127 | nop |
| 128 | ENDPROC(des_sparc64_ecb_crypt) |
| 129 | |
| 130 | .align 32 |
| 131 | ENTRY(des_sparc64_cbc_encrypt) |
| 132 | /* %o0=input, %o1=output, %o2=len, %o3=IV */ |
| 133 | ldd [%o3 + 0x00], %f32 |
| 134 | 1: ldd [%o0 + 0x00], %f34 |
| 135 | fxor %f32, %f34, %f32 |
| 136 | DES_IP(32, 32) |
| 137 | DES_ROUND(0, 2, 32, 32) |
| 138 | DES_ROUND(4, 6, 32, 32) |
| 139 | DES_ROUND(8, 10, 32, 32) |
| 140 | DES_ROUND(12, 14, 32, 32) |
| 141 | DES_ROUND(16, 18, 32, 32) |
| 142 | DES_ROUND(20, 22, 32, 32) |
| 143 | DES_ROUND(24, 26, 32, 32) |
| 144 | DES_ROUND(28, 30, 32, 32) |
| 145 | DES_IIP(32, 32) |
| 146 | std %f32, [%o1 + 0x00] |
| 147 | add %o0, 0x08, %o0 |
| 148 | subcc %o2, 0x08, %o2 |
| 149 | bne,pt %icc, 1b |
| 150 | add %o1, 0x08, %o1 |
| 151 | retl |
| 152 | std %f32, [%o3 + 0x00] |
| 153 | ENDPROC(des_sparc64_cbc_encrypt) |
| 154 | |
| 155 | .align 32 |
| 156 | ENTRY(des_sparc64_cbc_decrypt) |
| 157 | /* %o0=input, %o1=output, %o2=len, %o3=IV */ |
| 158 | ldd [%o3 + 0x00], %f34 |
| 159 | 1: ldd [%o0 + 0x00], %f36 |
| 160 | DES_IP(36, 32) |
| 161 | DES_ROUND(0, 2, 32, 32) |
| 162 | DES_ROUND(4, 6, 32, 32) |
| 163 | DES_ROUND(8, 10, 32, 32) |
| 164 | DES_ROUND(12, 14, 32, 32) |
| 165 | DES_ROUND(16, 18, 32, 32) |
| 166 | DES_ROUND(20, 22, 32, 32) |
| 167 | DES_ROUND(24, 26, 32, 32) |
| 168 | DES_ROUND(28, 30, 32, 32) |
| 169 | DES_IIP(32, 32) |
| 170 | fxor %f32, %f34, %f32 |
David S. Miller | 65d5fcf | 2012-09-17 19:57:30 -0700 | [diff] [blame] | 171 | fsrc2 %f36, %f34 |
David S. Miller | c5aac2d | 2012-08-25 22:37:23 -0700 | [diff] [blame] | 172 | std %f32, [%o1 + 0x00] |
| 173 | add %o0, 0x08, %o0 |
| 174 | subcc %o2, 0x08, %o2 |
| 175 | bne,pt %icc, 1b |
| 176 | add %o1, 0x08, %o1 |
| 177 | retl |
| 178 | std %f36, [%o3 + 0x00] |
| 179 | ENDPROC(des_sparc64_cbc_decrypt) |
| 180 | |
| 181 | .align 32 |
| 182 | ENTRY(des3_ede_sparc64_crypt) |
| 183 | /* %o0=key, %o1=input, %o2=output */ |
| 184 | VISEntry |
| 185 | ldd [%o1 + 0x00], %f32 |
| 186 | ldd [%o0 + 0x00], %f0 |
| 187 | ldd [%o0 + 0x08], %f2 |
| 188 | ldd [%o0 + 0x10], %f4 |
| 189 | ldd [%o0 + 0x18], %f6 |
| 190 | ldd [%o0 + 0x20], %f8 |
| 191 | ldd [%o0 + 0x28], %f10 |
| 192 | ldd [%o0 + 0x30], %f12 |
| 193 | ldd [%o0 + 0x38], %f14 |
| 194 | ldd [%o0 + 0x40], %f16 |
| 195 | ldd [%o0 + 0x48], %f18 |
| 196 | ldd [%o0 + 0x50], %f20 |
| 197 | ldd [%o0 + 0x58], %f22 |
| 198 | ldd [%o0 + 0x60], %f24 |
| 199 | ldd [%o0 + 0x68], %f26 |
| 200 | ldd [%o0 + 0x70], %f28 |
| 201 | ldd [%o0 + 0x78], %f30 |
| 202 | DES_IP(32, 32) |
| 203 | DES_ROUND(0, 2, 32, 32) |
| 204 | ldd [%o0 + 0x80], %f0 |
| 205 | ldd [%o0 + 0x88], %f2 |
| 206 | DES_ROUND(4, 6, 32, 32) |
| 207 | ldd [%o0 + 0x90], %f4 |
| 208 | ldd [%o0 + 0x98], %f6 |
| 209 | DES_ROUND(8, 10, 32, 32) |
| 210 | ldd [%o0 + 0xa0], %f8 |
| 211 | ldd [%o0 + 0xa8], %f10 |
| 212 | DES_ROUND(12, 14, 32, 32) |
| 213 | ldd [%o0 + 0xb0], %f12 |
| 214 | ldd [%o0 + 0xb8], %f14 |
| 215 | DES_ROUND(16, 18, 32, 32) |
| 216 | ldd [%o0 + 0xc0], %f16 |
| 217 | ldd [%o0 + 0xc8], %f18 |
| 218 | DES_ROUND(20, 22, 32, 32) |
| 219 | ldd [%o0 + 0xd0], %f20 |
| 220 | ldd [%o0 + 0xd8], %f22 |
| 221 | DES_ROUND(24, 26, 32, 32) |
| 222 | ldd [%o0 + 0xe0], %f24 |
| 223 | ldd [%o0 + 0xe8], %f26 |
| 224 | DES_ROUND(28, 30, 32, 32) |
| 225 | ldd [%o0 + 0xf0], %f28 |
| 226 | ldd [%o0 + 0xf8], %f30 |
| 227 | DES_IIP(32, 32) |
| 228 | DES_IP(32, 32) |
| 229 | DES_ROUND(0, 2, 32, 32) |
| 230 | ldd [%o0 + 0x100], %f0 |
| 231 | ldd [%o0 + 0x108], %f2 |
| 232 | DES_ROUND(4, 6, 32, 32) |
| 233 | ldd [%o0 + 0x110], %f4 |
| 234 | ldd [%o0 + 0x118], %f6 |
| 235 | DES_ROUND(8, 10, 32, 32) |
| 236 | ldd [%o0 + 0x120], %f8 |
| 237 | ldd [%o0 + 0x128], %f10 |
| 238 | DES_ROUND(12, 14, 32, 32) |
| 239 | ldd [%o0 + 0x130], %f12 |
| 240 | ldd [%o0 + 0x138], %f14 |
| 241 | DES_ROUND(16, 18, 32, 32) |
| 242 | ldd [%o0 + 0x140], %f16 |
| 243 | ldd [%o0 + 0x148], %f18 |
| 244 | DES_ROUND(20, 22, 32, 32) |
| 245 | ldd [%o0 + 0x150], %f20 |
| 246 | ldd [%o0 + 0x158], %f22 |
| 247 | DES_ROUND(24, 26, 32, 32) |
| 248 | ldd [%o0 + 0x160], %f24 |
| 249 | ldd [%o0 + 0x168], %f26 |
| 250 | DES_ROUND(28, 30, 32, 32) |
| 251 | ldd [%o0 + 0x170], %f28 |
| 252 | ldd [%o0 + 0x178], %f30 |
| 253 | DES_IIP(32, 32) |
| 254 | DES_IP(32, 32) |
| 255 | DES_ROUND(0, 2, 32, 32) |
| 256 | DES_ROUND(4, 6, 32, 32) |
| 257 | DES_ROUND(8, 10, 32, 32) |
| 258 | DES_ROUND(12, 14, 32, 32) |
| 259 | DES_ROUND(16, 18, 32, 32) |
| 260 | DES_ROUND(20, 22, 32, 32) |
| 261 | DES_ROUND(24, 26, 32, 32) |
| 262 | DES_ROUND(28, 30, 32, 32) |
| 263 | DES_IIP(32, 32) |
| 264 | |
| 265 | std %f32, [%o2 + 0x00] |
| 266 | retl |
| 267 | VISExit |
| 268 | ENDPROC(des3_ede_sparc64_crypt) |
| 269 | |
| 270 | .align 32 |
| 271 | ENTRY(des3_ede_sparc64_load_keys) |
| 272 | /* %o0=key */ |
| 273 | VISEntry |
| 274 | ldd [%o0 + 0x00], %f0 |
| 275 | ldd [%o0 + 0x08], %f2 |
| 276 | ldd [%o0 + 0x10], %f4 |
| 277 | ldd [%o0 + 0x18], %f6 |
| 278 | ldd [%o0 + 0x20], %f8 |
| 279 | ldd [%o0 + 0x28], %f10 |
| 280 | ldd [%o0 + 0x30], %f12 |
| 281 | ldd [%o0 + 0x38], %f14 |
| 282 | ldd [%o0 + 0x40], %f16 |
| 283 | ldd [%o0 + 0x48], %f18 |
| 284 | ldd [%o0 + 0x50], %f20 |
| 285 | ldd [%o0 + 0x58], %f22 |
| 286 | ldd [%o0 + 0x60], %f24 |
| 287 | ldd [%o0 + 0x68], %f26 |
| 288 | ldd [%o0 + 0x70], %f28 |
| 289 | ldd [%o0 + 0x78], %f30 |
| 290 | ldd [%o0 + 0x80], %f32 |
| 291 | ldd [%o0 + 0x88], %f34 |
| 292 | ldd [%o0 + 0x90], %f36 |
| 293 | ldd [%o0 + 0x98], %f38 |
| 294 | ldd [%o0 + 0xa0], %f40 |
| 295 | ldd [%o0 + 0xa8], %f42 |
| 296 | ldd [%o0 + 0xb0], %f44 |
| 297 | ldd [%o0 + 0xb8], %f46 |
| 298 | ldd [%o0 + 0xc0], %f48 |
| 299 | ldd [%o0 + 0xc8], %f50 |
| 300 | ldd [%o0 + 0xd0], %f52 |
| 301 | ldd [%o0 + 0xd8], %f54 |
| 302 | ldd [%o0 + 0xe0], %f56 |
| 303 | retl |
| 304 | ldd [%o0 + 0xe8], %f58 |
| 305 | ENDPROC(des3_ede_sparc64_load_keys) |
| 306 | |
| 307 | #define DES3_LOOP_BODY(X) \ |
| 308 | DES_IP(X, X) \ |
| 309 | DES_ROUND(0, 2, X, X) \ |
| 310 | DES_ROUND(4, 6, X, X) \ |
| 311 | DES_ROUND(8, 10, X, X) \ |
| 312 | DES_ROUND(12, 14, X, X) \ |
| 313 | DES_ROUND(16, 18, X, X) \ |
| 314 | ldd [%o0 + 0xf0], %f16; \ |
| 315 | ldd [%o0 + 0xf8], %f18; \ |
| 316 | DES_ROUND(20, 22, X, X) \ |
| 317 | ldd [%o0 + 0x100], %f20; \ |
| 318 | ldd [%o0 + 0x108], %f22; \ |
| 319 | DES_ROUND(24, 26, X, X) \ |
| 320 | ldd [%o0 + 0x110], %f24; \ |
| 321 | ldd [%o0 + 0x118], %f26; \ |
| 322 | DES_ROUND(28, 30, X, X) \ |
| 323 | ldd [%o0 + 0x120], %f28; \ |
| 324 | ldd [%o0 + 0x128], %f30; \ |
| 325 | DES_IIP(X, X) \ |
| 326 | DES_IP(X, X) \ |
| 327 | DES_ROUND(32, 34, X, X) \ |
| 328 | ldd [%o0 + 0x130], %f0; \ |
| 329 | ldd [%o0 + 0x138], %f2; \ |
| 330 | DES_ROUND(36, 38, X, X) \ |
| 331 | ldd [%o0 + 0x140], %f4; \ |
| 332 | ldd [%o0 + 0x148], %f6; \ |
| 333 | DES_ROUND(40, 42, X, X) \ |
| 334 | ldd [%o0 + 0x150], %f8; \ |
| 335 | ldd [%o0 + 0x158], %f10; \ |
| 336 | DES_ROUND(44, 46, X, X) \ |
| 337 | ldd [%o0 + 0x160], %f12; \ |
| 338 | ldd [%o0 + 0x168], %f14; \ |
| 339 | DES_ROUND(48, 50, X, X) \ |
| 340 | DES_ROUND(52, 54, X, X) \ |
| 341 | DES_ROUND(56, 58, X, X) \ |
| 342 | DES_ROUND(16, 18, X, X) \ |
| 343 | ldd [%o0 + 0x170], %f16; \ |
| 344 | ldd [%o0 + 0x178], %f18; \ |
| 345 | DES_IIP(X, X) \ |
| 346 | DES_IP(X, X) \ |
| 347 | DES_ROUND(20, 22, X, X) \ |
| 348 | ldd [%o0 + 0x50], %f20; \ |
| 349 | ldd [%o0 + 0x58], %f22; \ |
| 350 | DES_ROUND(24, 26, X, X) \ |
| 351 | ldd [%o0 + 0x60], %f24; \ |
| 352 | ldd [%o0 + 0x68], %f26; \ |
| 353 | DES_ROUND(28, 30, X, X) \ |
| 354 | ldd [%o0 + 0x70], %f28; \ |
| 355 | ldd [%o0 + 0x78], %f30; \ |
| 356 | DES_ROUND(0, 2, X, X) \ |
| 357 | ldd [%o0 + 0x00], %f0; \ |
| 358 | ldd [%o0 + 0x08], %f2; \ |
| 359 | DES_ROUND(4, 6, X, X) \ |
| 360 | ldd [%o0 + 0x10], %f4; \ |
| 361 | ldd [%o0 + 0x18], %f6; \ |
| 362 | DES_ROUND(8, 10, X, X) \ |
| 363 | ldd [%o0 + 0x20], %f8; \ |
| 364 | ldd [%o0 + 0x28], %f10; \ |
| 365 | DES_ROUND(12, 14, X, X) \ |
| 366 | ldd [%o0 + 0x30], %f12; \ |
| 367 | ldd [%o0 + 0x38], %f14; \ |
| 368 | DES_ROUND(16, 18, X, X) \ |
| 369 | ldd [%o0 + 0x40], %f16; \ |
| 370 | ldd [%o0 + 0x48], %f18; \ |
| 371 | DES_IIP(X, X) |
| 372 | |
| 373 | .align 32 |
| 374 | ENTRY(des3_ede_sparc64_ecb_crypt) |
| 375 | /* %o0=key, %o1=input, %o2=output, %o3=len */ |
| 376 | 1: ldd [%o1 + 0x00], %f60 |
| 377 | DES3_LOOP_BODY(60) |
| 378 | std %f60, [%o2 + 0x00] |
David S. Miller | ce68895 | 2012-12-19 15:30:07 -0800 | [diff] [blame^] | 379 | add %o1, 0x08, %o1 |
David S. Miller | c5aac2d | 2012-08-25 22:37:23 -0700 | [diff] [blame] | 380 | subcc %o3, 0x08, %o3 |
| 381 | bne,pt %icc, 1b |
| 382 | add %o2, 0x08, %o2 |
| 383 | retl |
| 384 | nop |
| 385 | ENDPROC(des3_ede_sparc64_ecb_crypt) |
| 386 | |
| 387 | .align 32 |
| 388 | ENTRY(des3_ede_sparc64_cbc_encrypt) |
| 389 | /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */ |
| 390 | ldd [%o4 + 0x00], %f60 |
| 391 | 1: ldd [%o1 + 0x00], %f62 |
| 392 | fxor %f60, %f62, %f60 |
| 393 | DES3_LOOP_BODY(60) |
| 394 | std %f60, [%o2 + 0x00] |
| 395 | add %o1, 0x08, %o1 |
| 396 | subcc %o3, 0x08, %o3 |
| 397 | bne,pt %icc, 1b |
| 398 | add %o2, 0x08, %o2 |
| 399 | retl |
| 400 | std %f60, [%o4 + 0x00] |
| 401 | ENDPROC(des3_ede_sparc64_cbc_encrypt) |
| 402 | |
| 403 | .align 32 |
| 404 | ENTRY(des3_ede_sparc64_cbc_decrypt) |
| 405 | /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */ |
| 406 | ldd [%o4 + 0x00], %f62 |
| 407 | 1: ldx [%o1 + 0x00], %g1 |
| 408 | MOVXTOD_G1_F60 |
| 409 | DES3_LOOP_BODY(60) |
| 410 | fxor %f62, %f60, %f60 |
| 411 | MOVXTOD_G1_F62 |
| 412 | std %f60, [%o2 + 0x00] |
| 413 | add %o1, 0x08, %o1 |
| 414 | subcc %o3, 0x08, %o3 |
| 415 | bne,pt %icc, 1b |
| 416 | add %o2, 0x08, %o2 |
| 417 | retl |
| 418 | stx %g1, [%o4 + 0x00] |
| 419 | ENDPROC(des3_ede_sparc64_cbc_decrypt) |