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