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 |
| 171 | std %f32, [%o1 + 0x00] |
| 172 | add %o0, 0x08, %o0 |
| 173 | subcc %o2, 0x08, %o2 |
| 174 | bne,pt %icc, 1b |
| 175 | add %o1, 0x08, %o1 |
| 176 | retl |
| 177 | std %f36, [%o3 + 0x00] |
| 178 | ENDPROC(des_sparc64_cbc_decrypt) |
| 179 | |
| 180 | .align 32 |
| 181 | ENTRY(des3_ede_sparc64_crypt) |
| 182 | /* %o0=key, %o1=input, %o2=output */ |
| 183 | VISEntry |
| 184 | ldd [%o1 + 0x00], %f32 |
| 185 | ldd [%o0 + 0x00], %f0 |
| 186 | ldd [%o0 + 0x08], %f2 |
| 187 | ldd [%o0 + 0x10], %f4 |
| 188 | ldd [%o0 + 0x18], %f6 |
| 189 | ldd [%o0 + 0x20], %f8 |
| 190 | ldd [%o0 + 0x28], %f10 |
| 191 | ldd [%o0 + 0x30], %f12 |
| 192 | ldd [%o0 + 0x38], %f14 |
| 193 | ldd [%o0 + 0x40], %f16 |
| 194 | ldd [%o0 + 0x48], %f18 |
| 195 | ldd [%o0 + 0x50], %f20 |
| 196 | ldd [%o0 + 0x58], %f22 |
| 197 | ldd [%o0 + 0x60], %f24 |
| 198 | ldd [%o0 + 0x68], %f26 |
| 199 | ldd [%o0 + 0x70], %f28 |
| 200 | ldd [%o0 + 0x78], %f30 |
| 201 | DES_IP(32, 32) |
| 202 | DES_ROUND(0, 2, 32, 32) |
| 203 | ldd [%o0 + 0x80], %f0 |
| 204 | ldd [%o0 + 0x88], %f2 |
| 205 | DES_ROUND(4, 6, 32, 32) |
| 206 | ldd [%o0 + 0x90], %f4 |
| 207 | ldd [%o0 + 0x98], %f6 |
| 208 | DES_ROUND(8, 10, 32, 32) |
| 209 | ldd [%o0 + 0xa0], %f8 |
| 210 | ldd [%o0 + 0xa8], %f10 |
| 211 | DES_ROUND(12, 14, 32, 32) |
| 212 | ldd [%o0 + 0xb0], %f12 |
| 213 | ldd [%o0 + 0xb8], %f14 |
| 214 | DES_ROUND(16, 18, 32, 32) |
| 215 | ldd [%o0 + 0xc0], %f16 |
| 216 | ldd [%o0 + 0xc8], %f18 |
| 217 | DES_ROUND(20, 22, 32, 32) |
| 218 | ldd [%o0 + 0xd0], %f20 |
| 219 | ldd [%o0 + 0xd8], %f22 |
| 220 | DES_ROUND(24, 26, 32, 32) |
| 221 | ldd [%o0 + 0xe0], %f24 |
| 222 | ldd [%o0 + 0xe8], %f26 |
| 223 | DES_ROUND(28, 30, 32, 32) |
| 224 | ldd [%o0 + 0xf0], %f28 |
| 225 | ldd [%o0 + 0xf8], %f30 |
| 226 | DES_IIP(32, 32) |
| 227 | DES_IP(32, 32) |
| 228 | DES_ROUND(0, 2, 32, 32) |
| 229 | ldd [%o0 + 0x100], %f0 |
| 230 | ldd [%o0 + 0x108], %f2 |
| 231 | DES_ROUND(4, 6, 32, 32) |
| 232 | ldd [%o0 + 0x110], %f4 |
| 233 | ldd [%o0 + 0x118], %f6 |
| 234 | DES_ROUND(8, 10, 32, 32) |
| 235 | ldd [%o0 + 0x120], %f8 |
| 236 | ldd [%o0 + 0x128], %f10 |
| 237 | DES_ROUND(12, 14, 32, 32) |
| 238 | ldd [%o0 + 0x130], %f12 |
| 239 | ldd [%o0 + 0x138], %f14 |
| 240 | DES_ROUND(16, 18, 32, 32) |
| 241 | ldd [%o0 + 0x140], %f16 |
| 242 | ldd [%o0 + 0x148], %f18 |
| 243 | DES_ROUND(20, 22, 32, 32) |
| 244 | ldd [%o0 + 0x150], %f20 |
| 245 | ldd [%o0 + 0x158], %f22 |
| 246 | DES_ROUND(24, 26, 32, 32) |
| 247 | ldd [%o0 + 0x160], %f24 |
| 248 | ldd [%o0 + 0x168], %f26 |
| 249 | DES_ROUND(28, 30, 32, 32) |
| 250 | ldd [%o0 + 0x170], %f28 |
| 251 | ldd [%o0 + 0x178], %f30 |
| 252 | DES_IIP(32, 32) |
| 253 | DES_IP(32, 32) |
| 254 | DES_ROUND(0, 2, 32, 32) |
| 255 | DES_ROUND(4, 6, 32, 32) |
| 256 | DES_ROUND(8, 10, 32, 32) |
| 257 | DES_ROUND(12, 14, 32, 32) |
| 258 | DES_ROUND(16, 18, 32, 32) |
| 259 | DES_ROUND(20, 22, 32, 32) |
| 260 | DES_ROUND(24, 26, 32, 32) |
| 261 | DES_ROUND(28, 30, 32, 32) |
| 262 | DES_IIP(32, 32) |
| 263 | |
| 264 | std %f32, [%o2 + 0x00] |
| 265 | retl |
| 266 | VISExit |
| 267 | ENDPROC(des3_ede_sparc64_crypt) |
| 268 | |
| 269 | .align 32 |
| 270 | ENTRY(des3_ede_sparc64_load_keys) |
| 271 | /* %o0=key */ |
| 272 | VISEntry |
| 273 | ldd [%o0 + 0x00], %f0 |
| 274 | ldd [%o0 + 0x08], %f2 |
| 275 | ldd [%o0 + 0x10], %f4 |
| 276 | ldd [%o0 + 0x18], %f6 |
| 277 | ldd [%o0 + 0x20], %f8 |
| 278 | ldd [%o0 + 0x28], %f10 |
| 279 | ldd [%o0 + 0x30], %f12 |
| 280 | ldd [%o0 + 0x38], %f14 |
| 281 | ldd [%o0 + 0x40], %f16 |
| 282 | ldd [%o0 + 0x48], %f18 |
| 283 | ldd [%o0 + 0x50], %f20 |
| 284 | ldd [%o0 + 0x58], %f22 |
| 285 | ldd [%o0 + 0x60], %f24 |
| 286 | ldd [%o0 + 0x68], %f26 |
| 287 | ldd [%o0 + 0x70], %f28 |
| 288 | ldd [%o0 + 0x78], %f30 |
| 289 | ldd [%o0 + 0x80], %f32 |
| 290 | ldd [%o0 + 0x88], %f34 |
| 291 | ldd [%o0 + 0x90], %f36 |
| 292 | ldd [%o0 + 0x98], %f38 |
| 293 | ldd [%o0 + 0xa0], %f40 |
| 294 | ldd [%o0 + 0xa8], %f42 |
| 295 | ldd [%o0 + 0xb0], %f44 |
| 296 | ldd [%o0 + 0xb8], %f46 |
| 297 | ldd [%o0 + 0xc0], %f48 |
| 298 | ldd [%o0 + 0xc8], %f50 |
| 299 | ldd [%o0 + 0xd0], %f52 |
| 300 | ldd [%o0 + 0xd8], %f54 |
| 301 | ldd [%o0 + 0xe0], %f56 |
| 302 | retl |
| 303 | ldd [%o0 + 0xe8], %f58 |
| 304 | ENDPROC(des3_ede_sparc64_load_keys) |
| 305 | |
| 306 | #define DES3_LOOP_BODY(X) \ |
| 307 | DES_IP(X, X) \ |
| 308 | DES_ROUND(0, 2, X, X) \ |
| 309 | DES_ROUND(4, 6, X, X) \ |
| 310 | DES_ROUND(8, 10, X, X) \ |
| 311 | DES_ROUND(12, 14, X, X) \ |
| 312 | DES_ROUND(16, 18, X, X) \ |
| 313 | ldd [%o0 + 0xf0], %f16; \ |
| 314 | ldd [%o0 + 0xf8], %f18; \ |
| 315 | DES_ROUND(20, 22, X, X) \ |
| 316 | ldd [%o0 + 0x100], %f20; \ |
| 317 | ldd [%o0 + 0x108], %f22; \ |
| 318 | DES_ROUND(24, 26, X, X) \ |
| 319 | ldd [%o0 + 0x110], %f24; \ |
| 320 | ldd [%o0 + 0x118], %f26; \ |
| 321 | DES_ROUND(28, 30, X, X) \ |
| 322 | ldd [%o0 + 0x120], %f28; \ |
| 323 | ldd [%o0 + 0x128], %f30; \ |
| 324 | DES_IIP(X, X) \ |
| 325 | DES_IP(X, X) \ |
| 326 | DES_ROUND(32, 34, X, X) \ |
| 327 | ldd [%o0 + 0x130], %f0; \ |
| 328 | ldd [%o0 + 0x138], %f2; \ |
| 329 | DES_ROUND(36, 38, X, X) \ |
| 330 | ldd [%o0 + 0x140], %f4; \ |
| 331 | ldd [%o0 + 0x148], %f6; \ |
| 332 | DES_ROUND(40, 42, X, X) \ |
| 333 | ldd [%o0 + 0x150], %f8; \ |
| 334 | ldd [%o0 + 0x158], %f10; \ |
| 335 | DES_ROUND(44, 46, X, X) \ |
| 336 | ldd [%o0 + 0x160], %f12; \ |
| 337 | ldd [%o0 + 0x168], %f14; \ |
| 338 | DES_ROUND(48, 50, X, X) \ |
| 339 | DES_ROUND(52, 54, X, X) \ |
| 340 | DES_ROUND(56, 58, X, X) \ |
| 341 | DES_ROUND(16, 18, X, X) \ |
| 342 | ldd [%o0 + 0x170], %f16; \ |
| 343 | ldd [%o0 + 0x178], %f18; \ |
| 344 | DES_IIP(X, X) \ |
| 345 | DES_IP(X, X) \ |
| 346 | DES_ROUND(20, 22, X, X) \ |
| 347 | ldd [%o0 + 0x50], %f20; \ |
| 348 | ldd [%o0 + 0x58], %f22; \ |
| 349 | DES_ROUND(24, 26, X, X) \ |
| 350 | ldd [%o0 + 0x60], %f24; \ |
| 351 | ldd [%o0 + 0x68], %f26; \ |
| 352 | DES_ROUND(28, 30, X, X) \ |
| 353 | ldd [%o0 + 0x70], %f28; \ |
| 354 | ldd [%o0 + 0x78], %f30; \ |
| 355 | DES_ROUND(0, 2, X, X) \ |
| 356 | ldd [%o0 + 0x00], %f0; \ |
| 357 | ldd [%o0 + 0x08], %f2; \ |
| 358 | DES_ROUND(4, 6, X, X) \ |
| 359 | ldd [%o0 + 0x10], %f4; \ |
| 360 | ldd [%o0 + 0x18], %f6; \ |
| 361 | DES_ROUND(8, 10, X, X) \ |
| 362 | ldd [%o0 + 0x20], %f8; \ |
| 363 | ldd [%o0 + 0x28], %f10; \ |
| 364 | DES_ROUND(12, 14, X, X) \ |
| 365 | ldd [%o0 + 0x30], %f12; \ |
| 366 | ldd [%o0 + 0x38], %f14; \ |
| 367 | DES_ROUND(16, 18, X, X) \ |
| 368 | ldd [%o0 + 0x40], %f16; \ |
| 369 | ldd [%o0 + 0x48], %f18; \ |
| 370 | DES_IIP(X, X) |
| 371 | |
| 372 | .align 32 |
| 373 | ENTRY(des3_ede_sparc64_ecb_crypt) |
| 374 | /* %o0=key, %o1=input, %o2=output, %o3=len */ |
| 375 | 1: ldd [%o1 + 0x00], %f60 |
| 376 | DES3_LOOP_BODY(60) |
| 377 | std %f60, [%o2 + 0x00] |
| 378 | subcc %o3, 0x08, %o3 |
| 379 | bne,pt %icc, 1b |
| 380 | add %o2, 0x08, %o2 |
| 381 | retl |
| 382 | nop |
| 383 | ENDPROC(des3_ede_sparc64_ecb_crypt) |
| 384 | |
| 385 | .align 32 |
| 386 | ENTRY(des3_ede_sparc64_cbc_encrypt) |
| 387 | /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */ |
| 388 | ldd [%o4 + 0x00], %f60 |
| 389 | 1: ldd [%o1 + 0x00], %f62 |
| 390 | fxor %f60, %f62, %f60 |
| 391 | DES3_LOOP_BODY(60) |
| 392 | std %f60, [%o2 + 0x00] |
| 393 | add %o1, 0x08, %o1 |
| 394 | subcc %o3, 0x08, %o3 |
| 395 | bne,pt %icc, 1b |
| 396 | add %o2, 0x08, %o2 |
| 397 | retl |
| 398 | std %f60, [%o4 + 0x00] |
| 399 | ENDPROC(des3_ede_sparc64_cbc_encrypt) |
| 400 | |
| 401 | .align 32 |
| 402 | ENTRY(des3_ede_sparc64_cbc_decrypt) |
| 403 | /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */ |
| 404 | ldd [%o4 + 0x00], %f62 |
| 405 | 1: ldx [%o1 + 0x00], %g1 |
| 406 | MOVXTOD_G1_F60 |
| 407 | DES3_LOOP_BODY(60) |
| 408 | fxor %f62, %f60, %f60 |
| 409 | MOVXTOD_G1_F62 |
| 410 | std %f60, [%o2 + 0x00] |
| 411 | add %o1, 0x08, %o1 |
| 412 | subcc %o3, 0x08, %o3 |
| 413 | bne,pt %icc, 1b |
| 414 | add %o2, 0x08, %o2 |
| 415 | retl |
| 416 | stx %g1, [%o4 + 0x00] |
| 417 | ENDPROC(des3_ede_sparc64_cbc_decrypt) |