1.machine "any" 2 3.csect .text[PR],7 4 5.align 7 6_vpaes_consts: 7Lk_mc_forward: 8.byte 0x01,0x02,0x03,0x00,0x05,0x06,0x07,0x04,0x09,0x0a,0x0b,0x08,0x0d,0x0e,0x0f,0x0c 9.byte 0x05,0x06,0x07,0x04,0x09,0x0a,0x0b,0x08,0x0d,0x0e,0x0f,0x0c,0x01,0x02,0x03,0x00 10.byte 0x09,0x0a,0x0b,0x08,0x0d,0x0e,0x0f,0x0c,0x01,0x02,0x03,0x00,0x05,0x06,0x07,0x04 11.byte 0x0d,0x0e,0x0f,0x0c,0x01,0x02,0x03,0x00,0x05,0x06,0x07,0x04,0x09,0x0a,0x0b,0x08 12Lk_mc_backward: 13.byte 0x03,0x00,0x01,0x02,0x07,0x04,0x05,0x06,0x0b,0x08,0x09,0x0a,0x0f,0x0c,0x0d,0x0e 14.byte 0x0f,0x0c,0x0d,0x0e,0x03,0x00,0x01,0x02,0x07,0x04,0x05,0x06,0x0b,0x08,0x09,0x0a 15.byte 0x0b,0x08,0x09,0x0a,0x0f,0x0c,0x0d,0x0e,0x03,0x00,0x01,0x02,0x07,0x04,0x05,0x06 16.byte 0x07,0x04,0x05,0x06,0x0b,0x08,0x09,0x0a,0x0f,0x0c,0x0d,0x0e,0x03,0x00,0x01,0x02 17Lk_sr: 18.byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f 19.byte 0x00,0x05,0x0a,0x0f,0x04,0x09,0x0e,0x03,0x08,0x0d,0x02,0x07,0x0c,0x01,0x06,0x0b 20.byte 0x00,0x09,0x02,0x0b,0x04,0x0d,0x06,0x0f,0x08,0x01,0x0a,0x03,0x0c,0x05,0x0e,0x07 21.byte 0x00,0x0d,0x0a,0x07,0x04,0x01,0x0e,0x0b,0x08,0x05,0x02,0x0f,0x0c,0x09,0x06,0x03 22 23 24 25 26Lk_inv: 27.byte 0xf0,0x01,0x08,0x0d,0x0f,0x06,0x05,0x0e,0x02,0x0c,0x0b,0x0a,0x09,0x03,0x07,0x04 28.byte 0xf0,0x07,0x0b,0x0f,0x06,0x0a,0x04,0x01,0x09,0x08,0x05,0x02,0x0c,0x0e,0x0d,0x03 29Lk_ipt: 30.byte 0x00,0x70,0x2a,0x5a,0x98,0xe8,0xb2,0xc2,0x08,0x78,0x22,0x52,0x90,0xe0,0xba,0xca 31.byte 0x00,0x4d,0x7c,0x31,0x7d,0x30,0x01,0x4c,0x81,0xcc,0xfd,0xb0,0xfc,0xb1,0x80,0xcd 32Lk_sbo: 33.byte 0x00,0xc7,0xbd,0x6f,0x17,0x6d,0xd2,0xd0,0x78,0xa8,0x02,0xc5,0x7a,0xbf,0xaa,0x15 34.byte 0x00,0x6a,0xbb,0x5f,0xa5,0x74,0xe4,0xcf,0xfa,0x35,0x2b,0x41,0xd1,0x90,0x1e,0x8e 35Lk_sb1: 36.byte 0x00,0x23,0xe2,0xfa,0x15,0xd4,0x18,0x36,0xef,0xd9,0x2e,0x0d,0xc1,0xcc,0xf7,0x3b 37.byte 0x00,0x3e,0x50,0xcb,0x8f,0xe1,0x9b,0xb1,0x44,0xf5,0x2a,0x14,0x6e,0x7a,0xdf,0xa5 38Lk_sb2: 39.byte 0x00,0x29,0xe1,0x0a,0x40,0x88,0xeb,0x69,0x4a,0x23,0x82,0xab,0xc8,0x63,0xa1,0xc2 40.byte 0x00,0x24,0x71,0x0b,0xc6,0x93,0x7a,0xe2,0xcd,0x2f,0x98,0xbc,0x55,0xe9,0xb7,0x5e 41 42 43 44 45Lk_dipt: 46.byte 0x00,0x5f,0x54,0x0b,0x04,0x5b,0x50,0x0f,0x1a,0x45,0x4e,0x11,0x1e,0x41,0x4a,0x15 47.byte 0x00,0x65,0x05,0x60,0xe6,0x83,0xe3,0x86,0x94,0xf1,0x91,0xf4,0x72,0x17,0x77,0x12 48Lk_dsbo: 49.byte 0x00,0x40,0xf9,0x7e,0x53,0xea,0x87,0x13,0x2d,0x3e,0x94,0xd4,0xb9,0x6d,0xaa,0xc7 50.byte 0x00,0x1d,0x44,0x93,0x0f,0x56,0xd7,0x12,0x9c,0x8e,0xc5,0xd8,0x59,0x81,0x4b,0xca 51Lk_dsb9: 52.byte 0x00,0xd6,0x86,0x9a,0x53,0x03,0x1c,0x85,0xc9,0x4c,0x99,0x4f,0x50,0x1f,0xd5,0xca 53.byte 0x00,0x49,0xd7,0xec,0x89,0x17,0x3b,0xc0,0x65,0xa5,0xfb,0xb2,0x9e,0x2c,0x5e,0x72 54Lk_dsbd: 55.byte 0x00,0xa2,0xb1,0xe6,0xdf,0xcc,0x57,0x7d,0x39,0x44,0x2a,0x88,0x13,0x9b,0x6e,0xf5 56.byte 0x00,0xcb,0xc6,0x24,0xf7,0xfa,0xe2,0x3c,0xd3,0xef,0xde,0x15,0x0d,0x18,0x31,0x29 57Lk_dsbb: 58.byte 0x00,0x42,0xb4,0x96,0x92,0x64,0x22,0xd0,0x04,0xd4,0xf2,0xb0,0xf6,0x46,0x26,0x60 59.byte 0x00,0x67,0x59,0xcd,0xa6,0x98,0x94,0xc1,0x6b,0xaa,0x55,0x32,0x3e,0x0c,0xff,0xf3 60Lk_dsbe: 61.byte 0x00,0xd0,0xd4,0x26,0x96,0x92,0xf2,0x46,0xb0,0xf6,0xb4,0x64,0x04,0x60,0x42,0x22 62.byte 0x00,0xc1,0xaa,0xff,0xcd,0xa6,0x55,0x0c,0x32,0x3e,0x59,0x98,0x6b,0xf3,0x67,0x94 63 64 65 66 67Lk_dksd: 68.byte 0x00,0x47,0xe4,0xa3,0x5d,0x1a,0xb9,0xfe,0xf9,0xbe,0x1d,0x5a,0xa4,0xe3,0x40,0x07 69.byte 0x00,0x83,0x36,0xb5,0xf4,0x77,0xc2,0x41,0x1e,0x9d,0x28,0xab,0xea,0x69,0xdc,0x5f 70Lk_dksb: 71.byte 0x00,0xd5,0x50,0x85,0x1f,0xca,0x4f,0x9a,0x99,0x4c,0xc9,0x1c,0x86,0x53,0xd6,0x03 72.byte 0x00,0x4a,0xfc,0xb6,0xa7,0xed,0x5b,0x11,0xc8,0x82,0x34,0x7e,0x6f,0x25,0x93,0xd9 73Lk_dkse: 74.byte 0x00,0xd6,0xc9,0x1f,0xca,0x1c,0x03,0xd5,0x86,0x50,0x4f,0x99,0x4c,0x9a,0x85,0x53 75.byte 0xe8,0x7b,0xdc,0x4f,0x05,0x96,0x31,0xa2,0x87,0x14,0xb3,0x20,0x6a,0xf9,0x5e,0xcd 76Lk_dks9: 77.byte 0x00,0xa7,0xd9,0x7e,0xc8,0x6f,0x11,0xb6,0xfc,0x5b,0x25,0x82,0x34,0x93,0xed,0x4a 78.byte 0x00,0x33,0x14,0x27,0x62,0x51,0x76,0x45,0xce,0xfd,0xda,0xe9,0xac,0x9f,0xb8,0x8b 79 80Lk_rcon: 81.byte 0xb6,0xee,0x9d,0xaf,0xb9,0x91,0x83,0x1f,0x81,0x7d,0x7c,0x4d,0x08,0x98,0x2a,0x70 82Lk_s63: 83.byte 0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b 84 85Lk_opt: 86.byte 0x00,0x60,0xb6,0xd6,0x29,0x49,0x9f,0xff,0x08,0x68,0xbe,0xde,0x21,0x41,0x97,0xf7 87.byte 0x00,0xec,0xbc,0x50,0x51,0xbd,0xed,0x01,0xe0,0x0c,0x5c,0xb0,0xb1,0x5d,0x0d,0xe1 88Lk_deskew: 89.byte 0x00,0xe3,0xa4,0x47,0x40,0xa3,0xe4,0x07,0x1a,0xf9,0xbe,0x5d,0x5a,0xb9,0xfe,0x1d 90.byte 0x00,0x69,0xea,0x83,0xdc,0xb5,0x36,0x5f,0x77,0x1e,0x9d,0xf4,0xab,0xc2,0x41,0x28 91.align 5 92Lconsts: 93 mflr 0 94 bcl 20,31,$+4 95 mflr 12 96 addi 12,12,-0x308 97 mtlr 0 98 blr 99.long 0 100.byte 0,12,0x14,0,0,0,0,0 101.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,65,108,116,105,86,101,99,44,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 102.align 2 103.align 6 104 105 106 107 108 109 110.align 4 111_vpaes_encrypt_preheat: 112 mflr 8 113 bl Lconsts 114 mtlr 8 115 li 11, 0xc0 116 li 10, 0xd0 117 li 9, 0xe0 118 li 8, 0xf0 119 vxor 7, 7, 7 120 vspltisb 8,4 121 vspltisb 9,0x0f 122 lvx 10, 12, 11 123 li 11, 0x100 124 lvx 11, 12, 10 125 li 10, 0x110 126 lvx 12, 12, 9 127 li 9, 0x120 128 lvx 13, 12, 8 129 li 8, 0x130 130 lvx 14, 12, 11 131 li 11, 0x140 132 lvx 15, 12, 10 133 li 10, 0x150 134 lvx 16, 12, 9 135 lvx 17, 12, 8 136 lvx 18, 12, 11 137 lvx 19, 12, 10 138 blr 139.long 0 140.byte 0,12,0x14,0,0,0,0,0 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156.align 5 157_vpaes_encrypt_core: 158 lwz 8, 240(5) 159 li 9, 16 160 lvx 5, 0, 5 161 li 11, 0x10 162 lvx 6, 9, 5 163 addi 9, 9, 16 164 vperm 5, 5, 6, 31 165 addi 10, 11, 0x40 166 vsrb 1, 0, 8 167 vperm 0, 12, 12, 0 168 vperm 1, 13, 13, 1 169 vxor 0, 0, 5 170 vxor 0, 0, 1 171 mtctr 8 172 b Lenc_entry 173 174.align 4 175Lenc_loop: 176 177 vperm 4, 17, 7, 2 178 lvx 1, 12, 11 179 addi 11, 11, 16 180 vperm 0, 16, 7, 3 181 vxor 4, 4, 5 182 andi. 11, 11, 0x30 183 vperm 5, 19, 7, 2 184 vxor 0, 0, 4 185 vperm 2, 18, 7, 3 186 lvx 4, 12, 10 187 addi 10, 11, 0x40 188 vperm 3, 0, 7, 1 189 vxor 2, 2, 5 190 vperm 0, 0, 7, 4 191 vxor 3, 3, 2 192 vperm 4, 3, 7, 1 193 vxor 0, 0, 3 194 vxor 0, 0, 4 195 196Lenc_entry: 197 198 vsrb 1, 0, 8 199 vperm 5, 11, 11, 0 200 vxor 0, 0, 1 201 vperm 3, 10, 10, 1 202 vperm 4, 10, 10, 0 203 vand 0, 0, 9 204 vxor 3, 3, 5 205 vxor 4, 4, 5 206 vperm 2, 10, 7, 3 207 vor 5,6,6 208 lvx 6, 9, 5 209 vperm 3, 10, 7, 4 210 addi 9, 9, 16 211 vxor 2, 2, 0 212 vperm 5, 5, 6, 31 213 vxor 3, 3, 1 214 bc 16,0,Lenc_loop 215 216 217 addi 10, 11, 0x80 218 219 220 vperm 4, 14, 7, 2 221 lvx 1, 12, 10 222 vperm 0, 15, 7, 3 223 vxor 4, 4, 5 224 vxor 0, 0, 4 225 vperm 0, 0, 7, 1 226 blr 227.long 0 228.byte 0,12,0x14,0,0,0,0,0 229 230.globl .vpaes_encrypt 231.align 5 232.vpaes_encrypt: 233 stdu 1,-256(1) 234 li 10,63 235 li 11,79 236 mflr 6 237 li 7,-1 238 stvx 20,10,1 239 addi 10,10,32 240 stvx 21,11,1 241 addi 11,11,32 242 stvx 22,10,1 243 addi 10,10,32 244 stvx 23,11,1 245 addi 11,11,32 246 stvx 24,10,1 247 addi 10,10,32 248 stvx 25,11,1 249 addi 11,11,32 250 stvx 26,10,1 251 addi 10,10,32 252 stvx 27,11,1 253 addi 11,11,32 254 stvx 28,10,1 255 addi 10,10,32 256 stvx 29,11,1 257 addi 11,11,32 258 stvx 30,10,1 259 stvx 31,11,1 260 stw 7,252(1) 261 li 0, -1 262 std 6,272(1) 263 or 0,0,0 264 265 bl _vpaes_encrypt_preheat 266 267 lvsl 27, 0, 3 268 lvx 0, 0, 3 269 addi 3, 3, 15 270 lvsr 29, 0, 4 271 lvsl 31, 0, 5 272 lvx 26, 0, 3 273 vperm 0, 0, 26, 27 274 275 bl _vpaes_encrypt_core 276 277 andi. 8, 4, 15 278 li 9, 16 279 beq Lenc_out_aligned 280 281 vperm 0, 0, 0, 29 282 mtctr 9 283Lenc_out_unaligned: 284 stvebx 0, 0, 4 285 addi 4, 4, 1 286 bc 16,0,Lenc_out_unaligned 287 b Lenc_done 288 289.align 4 290Lenc_out_aligned: 291 stvx 0, 0, 4 292Lenc_done: 293 294 li 10,63 295 li 11,79 296 mtlr 6 297 or 7,7,7 298 lvx 20,10,1 299 addi 10,10,32 300 lvx 21,11,1 301 addi 11,11,32 302 lvx 22,10,1 303 addi 10,10,32 304 lvx 23,11,1 305 addi 11,11,32 306 lvx 24,10,1 307 addi 10,10,32 308 lvx 25,11,1 309 addi 11,11,32 310 lvx 26,10,1 311 addi 10,10,32 312 lvx 27,11,1 313 addi 11,11,32 314 lvx 28,10,1 315 addi 10,10,32 316 lvx 29,11,1 317 addi 11,11,32 318 lvx 30,10,1 319 lvx 31,11,1 320 addi 1,1,256 321 blr 322.long 0 323.byte 0,12,0x04,1,0x80,0,3,0 324.long 0 325 326 327.align 4 328_vpaes_decrypt_preheat: 329 mflr 8 330 bl Lconsts 331 mtlr 8 332 li 11, 0xc0 333 li 10, 0xd0 334 li 9, 0x160 335 li 8, 0x170 336 vxor 7, 7, 7 337 vspltisb 8,4 338 vspltisb 9,0x0f 339 lvx 10, 12, 11 340 li 11, 0x180 341 lvx 11, 12, 10 342 li 10, 0x190 343 lvx 12, 12, 9 344 li 9, 0x1a0 345 lvx 13, 12, 8 346 li 8, 0x1b0 347 lvx 14, 12, 11 348 li 11, 0x1c0 349 lvx 15, 12, 10 350 li 10, 0x1d0 351 lvx 16, 12, 9 352 li 9, 0x1e0 353 lvx 17, 12, 8 354 li 8, 0x1f0 355 lvx 18, 12, 11 356 li 11, 0x200 357 lvx 19, 12, 10 358 li 10, 0x210 359 lvx 20, 12, 9 360 lvx 21, 12, 8 361 lvx 22, 12, 11 362 lvx 23, 12, 10 363 blr 364.long 0 365.byte 0,12,0x14,0,0,0,0,0 366 367 368 369 370 371 372.align 4 373_vpaes_decrypt_core: 374 lwz 8, 240(5) 375 li 9, 16 376 lvx 5, 0, 5 377 li 11, 0x30 378 lvx 6, 9, 5 379 addi 9, 9, 16 380 vperm 5, 5, 6, 31 381 vsrb 1, 0, 8 382 vperm 0, 12, 12, 0 383 vperm 1, 13, 13, 1 384 vxor 0, 0, 5 385 vxor 0, 0, 1 386 mtctr 8 387 b Ldec_entry 388 389.align 4 390Ldec_loop: 391 392 393 394 lvx 0, 12, 11 395 396 397 vperm 4, 16, 7, 2 398 subi 11, 11, 16 399 vperm 1, 17, 7, 3 400 andi. 11, 11, 0x30 401 vxor 5, 5, 4 402 403 vxor 5, 5, 1 404 405 406 vperm 4, 18, 7, 2 407 vperm 5, 5, 7, 0 408 vperm 1, 19, 7, 3 409 vxor 5, 5, 4 410 411 vxor 5, 5, 1 412 413 414 vperm 4, 20, 7, 2 415 vperm 5, 5, 7, 0 416 vperm 1, 21, 7, 3 417 vxor 5, 5, 4 418 419 vxor 5, 5, 1 420 421 422 vperm 4, 22, 7, 2 423 vperm 5, 5, 7, 0 424 vperm 1, 23, 7, 3 425 vxor 0, 5, 4 426 vxor 0, 0, 1 427 428Ldec_entry: 429 430 vsrb 1, 0, 8 431 vperm 2, 11, 11, 0 432 vxor 0, 0, 1 433 vperm 3, 10, 10, 1 434 vperm 4, 10, 10, 0 435 vand 0, 0, 9 436 vxor 3, 3, 2 437 vxor 4, 4, 2 438 vperm 2, 10, 7, 3 439 vor 5,6,6 440 lvx 6, 9, 5 441 vperm 3, 10, 7, 4 442 addi 9, 9, 16 443 vxor 2, 2, 0 444 vperm 5, 5, 6, 31 445 vxor 3, 3, 1 446 bc 16,0,Ldec_loop 447 448 449 addi 10, 11, 0x80 450 451 vperm 4, 14, 7, 2 452 453 lvx 2, 12, 10 454 vperm 1, 15, 7, 3 455 vxor 4, 4, 5 456 vxor 0, 1, 4 457 vperm 0, 0, 7, 2 458 blr 459.long 0 460.byte 0,12,0x14,0,0,0,0,0 461 462.globl .vpaes_decrypt 463.align 5 464.vpaes_decrypt: 465 stdu 1,-256(1) 466 li 10,63 467 li 11,79 468 mflr 6 469 li 7,-1 470 stvx 20,10,1 471 addi 10,10,32 472 stvx 21,11,1 473 addi 11,11,32 474 stvx 22,10,1 475 addi 10,10,32 476 stvx 23,11,1 477 addi 11,11,32 478 stvx 24,10,1 479 addi 10,10,32 480 stvx 25,11,1 481 addi 11,11,32 482 stvx 26,10,1 483 addi 10,10,32 484 stvx 27,11,1 485 addi 11,11,32 486 stvx 28,10,1 487 addi 10,10,32 488 stvx 29,11,1 489 addi 11,11,32 490 stvx 30,10,1 491 stvx 31,11,1 492 stw 7,252(1) 493 li 0, -1 494 std 6,272(1) 495 or 0,0,0 496 497 bl _vpaes_decrypt_preheat 498 499 lvsl 27, 0, 3 500 lvx 0, 0, 3 501 addi 3, 3, 15 502 lvsr 29, 0, 4 503 lvsl 31, 0, 5 504 lvx 26, 0, 3 505 vperm 0, 0, 26, 27 506 507 bl _vpaes_decrypt_core 508 509 andi. 8, 4, 15 510 li 9, 16 511 beq Ldec_out_aligned 512 513 vperm 0, 0, 0, 29 514 mtctr 9 515Ldec_out_unaligned: 516 stvebx 0, 0, 4 517 addi 4, 4, 1 518 bc 16,0,Ldec_out_unaligned 519 b Ldec_done 520 521.align 4 522Ldec_out_aligned: 523 stvx 0, 0, 4 524Ldec_done: 525 526 li 10,63 527 li 11,79 528 mtlr 6 529 or 7,7,7 530 lvx 20,10,1 531 addi 10,10,32 532 lvx 21,11,1 533 addi 11,11,32 534 lvx 22,10,1 535 addi 10,10,32 536 lvx 23,11,1 537 addi 11,11,32 538 lvx 24,10,1 539 addi 10,10,32 540 lvx 25,11,1 541 addi 11,11,32 542 lvx 26,10,1 543 addi 10,10,32 544 lvx 27,11,1 545 addi 11,11,32 546 lvx 28,10,1 547 addi 10,10,32 548 lvx 29,11,1 549 addi 11,11,32 550 lvx 30,10,1 551 lvx 31,11,1 552 addi 1,1,256 553 blr 554.long 0 555.byte 0,12,0x04,1,0x80,0,3,0 556.long 0 557 558 559.globl .vpaes_cbc_encrypt 560.align 5 561.vpaes_cbc_encrypt: 562 cmpldi 5,16 563 bclr 14,0 564 565 stdu 1,-272(1) 566 mflr 0 567 li 10,63 568 li 11,79 569 li 12,-1 570 stvx 20,10,1 571 addi 10,10,32 572 stvx 21,11,1 573 addi 11,11,32 574 stvx 22,10,1 575 addi 10,10,32 576 stvx 23,11,1 577 addi 11,11,32 578 stvx 24,10,1 579 addi 10,10,32 580 stvx 25,11,1 581 addi 11,11,32 582 stvx 26,10,1 583 addi 10,10,32 584 stvx 27,11,1 585 addi 11,11,32 586 stvx 28,10,1 587 addi 10,10,32 588 stvx 29,11,1 589 addi 11,11,32 590 stvx 30,10,1 591 stvx 31,11,1 592 stw 12,252(1) 593 std 30,256(1) 594 std 31,264(1) 595 li 9, -16 596 std 0, 288(1) 597 598 and 30, 5, 9 599 andi. 9, 4, 15 600 mr 5, 6 601 mr 31, 7 602 li 6, -1 603 mcrf 1, 0 604 mr 7, 12 605 or 6,6,6 606 607 lvx 24, 0, 31 608 li 9, 15 609 lvsl 27, 0, 31 610 lvx 25, 9, 31 611 vperm 24, 24, 25, 27 612 613 cmpwi 8, 0 614 neg 8, 3 615 vxor 7, 7, 7 616 lvsl 31, 0, 5 617 lvsr 29, 0, 4 618 lvsr 27, 0, 8 619 vnor 30, 7, 7 620 lvx 26, 0, 3 621 vperm 30, 7, 30, 29 622 addi 3, 3, 15 623 624 beq Lcbc_decrypt 625 626 bl _vpaes_encrypt_preheat 627 li 0, 16 628 629 beq 1, Lcbc_enc_loop 630 631 vor 0,26,26 632 lvx 26, 0, 3 633 addi 3, 3, 16 634 vperm 0, 0, 26, 27 635 vxor 0, 0, 24 636 637 bl _vpaes_encrypt_core 638 639 andi. 8, 4, 15 640 vor 24,0,0 641 sub 9, 4, 8 642 vperm 28, 0, 0, 29 643 644Lcbc_enc_head: 645 stvebx 28, 8, 9 646 cmpwi 8, 15 647 addi 8, 8, 1 648 bne Lcbc_enc_head 649 650 sub. 30, 30, 0 651 addi 4, 4, 16 652 beq Lcbc_unaligned_done 653 654Lcbc_enc_loop: 655 vor 0,26,26 656 lvx 26, 0, 3 657 addi 3, 3, 16 658 vperm 0, 0, 26, 27 659 vxor 0, 0, 24 660 661 bl _vpaes_encrypt_core 662 663 vor 24,0,0 664 sub. 30, 30, 0 665 vperm 0, 0, 0, 29 666 vsel 1,28,0,30 667 vor 28,0,0 668 stvx 1, 0, 4 669 addi 4, 4, 16 670 bne Lcbc_enc_loop 671 672 b Lcbc_done 673 674.align 5 675Lcbc_decrypt: 676 bl _vpaes_decrypt_preheat 677 li 0, 16 678 679 beq 1, Lcbc_dec_loop 680 681 vor 0,26,26 682 lvx 26, 0, 3 683 addi 3, 3, 16 684 vperm 0, 0, 26, 27 685 vor 25,0,0 686 687 bl _vpaes_decrypt_core 688 689 andi. 8, 4, 15 690 vxor 0, 0, 24 691 vor 24,25,25 692 sub 9, 4, 8 693 vperm 28, 0, 0, 29 694 695Lcbc_dec_head: 696 stvebx 28, 8, 9 697 cmpwi 8, 15 698 addi 8, 8, 1 699 bne Lcbc_dec_head 700 701 sub. 30, 30, 0 702 addi 4, 4, 16 703 beq Lcbc_unaligned_done 704 705Lcbc_dec_loop: 706 vor 0,26,26 707 lvx 26, 0, 3 708 addi 3, 3, 16 709 vperm 0, 0, 26, 27 710 vor 25,0,0 711 712 bl _vpaes_decrypt_core 713 714 vxor 0, 0, 24 715 vor 24,25,25 716 sub. 30, 30, 0 717 vperm 0, 0, 0, 29 718 vsel 1,28,0,30 719 vor 28,0,0 720 stvx 1, 0, 4 721 addi 4, 4, 16 722 bne Lcbc_dec_loop 723 724Lcbc_done: 725 beq 1, Lcbc_write_iv 726 727Lcbc_unaligned_done: 728 andi. 8, 4, 15 729 sub 4, 4, 8 730 li 9, 0 731Lcbc_tail: 732 stvebx 28, 9, 4 733 addi 9, 9, 1 734 cmpw 9, 8 735 bne Lcbc_tail 736 737Lcbc_write_iv: 738 neg 8, 31 739 li 10, 4 740 lvsl 29, 0, 8 741 li 11, 8 742 li 12, 12 743 vperm 24, 24, 24, 29 744 stvewx 24, 0, 31 745 stvewx 24, 10, 31 746 stvewx 24, 11, 31 747 stvewx 24, 12, 31 748 749 or 7,7,7 750 li 10,63 751 li 11,79 752 lvx 20,10,1 753 addi 10,10,32 754 lvx 21,11,1 755 addi 11,11,32 756 lvx 22,10,1 757 addi 10,10,32 758 lvx 23,11,1 759 addi 11,11,32 760 lvx 24,10,1 761 addi 10,10,32 762 lvx 25,11,1 763 addi 11,11,32 764 lvx 26,10,1 765 addi 10,10,32 766 lvx 27,11,1 767 addi 11,11,32 768 lvx 28,10,1 769 addi 10,10,32 770 lvx 29,11,1 771 addi 11,11,32 772 lvx 30,10,1 773 lvx 31,11,1 774Lcbc_abort: 775 ld 0, 288(1) 776 ld 30,256(1) 777 ld 31,264(1) 778 mtlr 0 779 addi 1,1,272 780 blr 781.long 0 782.byte 0,12,0x04,1,0x80,2,6,0 783.long 0 784 785 786 787 788 789 790.align 4 791_vpaes_key_preheat: 792 mflr 8 793 bl Lconsts 794 mtlr 8 795 li 11, 0xc0 796 li 10, 0xd0 797 li 9, 0xe0 798 li 8, 0xf0 799 800 vspltisb 8,4 801 vxor 9,9,9 802 lvx 10, 12, 11 803 li 11, 0x120 804 lvx 11, 12, 10 805 li 10, 0x130 806 lvx 12, 12, 9 807 li 9, 0x220 808 lvx 13, 12, 8 809 li 8, 0x230 810 811 lvx 14, 12, 11 812 li 11, 0x240 813 lvx 15, 12, 10 814 li 10, 0x250 815 816 lvx 16, 12, 9 817 li 9, 0x260 818 lvx 17, 12, 8 819 li 8, 0x270 820 lvx 18, 12, 11 821 li 11, 0x280 822 lvx 19, 12, 10 823 li 10, 0x290 824 lvx 20, 12, 9 825 li 9, 0x2a0 826 lvx 21, 12, 8 827 li 8, 0x2b0 828 lvx 22, 12, 11 829 lvx 23, 12, 10 830 831 lvx 24, 12, 9 832 lvx 25, 0, 12 833 lvx 26, 12, 8 834 blr 835.long 0 836.byte 0,12,0x14,0,0,0,0,0 837 838.align 4 839_vpaes_schedule_core: 840 mflr 7 841 842 bl _vpaes_key_preheat 843 844 845 neg 8, 3 846 lvx 0, 0, 3 847 addi 3, 3, 15 848 lvsr 27, 0, 8 849 lvx 6, 0, 3 850 addi 3, 3, 8 851 vperm 0, 0, 6, 27 852 853 854 vor 3,0,0 855 bl _vpaes_schedule_transform 856 vor 7,0,0 857 858 bne 1, Lschedule_am_decrypting 859 860 861 li 8, 0x30 862 li 9, 4 863 li 10, 8 864 li 11, 12 865 866 lvsr 29, 0, 5 867 vnor 30, 9, 9 868 vperm 30, 9, 30, 29 869 870 871 vperm 28, 0, 0, 29 872 stvewx 28, 0, 5 873 stvewx 28, 9, 5 874 stvewx 28, 10, 5 875 addi 10, 12, 0x80 876 stvewx 28, 11, 5 877 b Lschedule_go 878 879Lschedule_am_decrypting: 880 srwi 8, 4, 1 881 andi. 8, 8, 32 882 xori 8, 8, 32 883 addi 10, 12, 0x80 884 885 lvx 1, 8, 10 886 li 9, 4 887 li 10, 8 888 li 11, 12 889 vperm 4, 3, 3, 1 890 891 neg 0, 5 892 lvsl 29, 0, 0 893 vnor 30, 9, 9 894 vperm 30, 30, 9, 29 895 896 897 vperm 28, 4, 4, 29 898 stvewx 28, 0, 5 899 stvewx 28, 9, 5 900 stvewx 28, 10, 5 901 addi 10, 12, 0x80 902 stvewx 28, 11, 5 903 addi 5, 5, 15 904 xori 8, 8, 0x30 905 906Lschedule_go: 907 cmplwi 4, 192 908 bgt Lschedule_256 909 beq Lschedule_192 910 911 912 913 914 915 916 917 918 919 920Lschedule_128: 921 li 0, 10 922 mtctr 0 923 924Loop_schedule_128: 925 bl _vpaes_schedule_round 926 bdz Lschedule_mangle_last 927 bl _vpaes_schedule_mangle 928 b Loop_schedule_128 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945.align 4 946Lschedule_192: 947 li 0, 4 948 lvx 0, 0, 3 949 vperm 0, 6, 0, 27 950 vsldoi 0, 3, 0, 8 951 bl _vpaes_schedule_transform 952 vsldoi 6, 0, 9, 8 953 vsldoi 6, 9, 6, 8 954 mtctr 0 955 956Loop_schedule_192: 957 bl _vpaes_schedule_round 958 vsldoi 0, 6, 0, 8 959 bl _vpaes_schedule_mangle 960 bl _vpaes_schedule_192_smear 961 bl _vpaes_schedule_mangle 962 bl _vpaes_schedule_round 963 bdz Lschedule_mangle_last 964 bl _vpaes_schedule_mangle 965 bl _vpaes_schedule_192_smear 966 b Loop_schedule_192 967 968 969 970 971 972 973 974 975 976 977 978.align 4 979Lschedule_256: 980 li 0, 7 981 addi 3, 3, 8 982 lvx 0, 0, 3 983 vperm 0, 6, 0, 27 984 bl _vpaes_schedule_transform 985 mtctr 0 986 987Loop_schedule_256: 988 bl _vpaes_schedule_mangle 989 vor 6,0,0 990 991 992 bl _vpaes_schedule_round 993 bdz Lschedule_mangle_last 994 bl _vpaes_schedule_mangle 995 996 997 vspltw 0, 0, 3 998 vor 5,7,7 999 vor 7,6,6 1000 bl _vpaes_schedule_low_round 1001 vor 7,5,5 1002 1003 b Loop_schedule_256 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014.align 4 1015Lschedule_mangle_last: 1016 1017 li 11, 0x2e0 1018 li 9, 0x2f0 1019 bne 1, Lschedule_mangle_last_dec 1020 1021 1022 lvx 1, 8, 10 1023 li 11, 0x2c0 1024 li 9, 0x2d0 1025 vperm 0, 0, 0, 1 1026 1027 lvx 12, 11, 12 1028 lvx 13, 9, 12 1029 addi 5, 5, 16 1030 vxor 0, 0, 26 1031 bl _vpaes_schedule_transform 1032 1033 1034 vperm 0, 0, 0, 29 1035 li 10, 4 1036 vsel 2,28,0,30 1037 li 11, 8 1038 stvx 2, 0, 5 1039 li 12, 12 1040 stvewx 0, 0, 5 1041 stvewx 0, 10, 5 1042 stvewx 0, 11, 5 1043 stvewx 0, 12, 5 1044 b Lschedule_mangle_done 1045 1046.align 4 1047Lschedule_mangle_last_dec: 1048 lvx 12, 11, 12 1049 lvx 13, 9, 12 1050 addi 5, 5, -16 1051 vxor 0, 0, 26 1052 bl _vpaes_schedule_transform 1053 1054 1055 addi 9, 5, -15 1056 vperm 0, 0, 0, 29 1057 li 10, 4 1058 vsel 2,28,0,30 1059 li 11, 8 1060 stvx 2, 0, 5 1061 li 12, 12 1062 stvewx 0, 0, 9 1063 stvewx 0, 10, 9 1064 stvewx 0, 11, 9 1065 stvewx 0, 12, 9 1066 1067 1068Lschedule_mangle_done: 1069 mtlr 7 1070 1071 vxor 0, 0, 0 1072 vxor 1, 1, 1 1073 vxor 2, 2, 2 1074 vxor 3, 3, 3 1075 vxor 4, 4, 4 1076 vxor 5, 5, 5 1077 vxor 6, 6, 6 1078 vxor 7, 7, 7 1079 1080 blr 1081.long 0 1082.byte 0,12,0x14,0,0,0,0,0 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098.align 4 1099_vpaes_schedule_192_smear: 1100 vspltw 0, 7, 3 1101 vsldoi 1, 9, 6, 12 1102 vsldoi 0, 7, 0, 8 1103 vxor 6, 6, 1 1104 vxor 6, 6, 0 1105 vor 0,6,6 1106 vsldoi 6, 6, 9, 8 1107 vsldoi 6, 9, 6, 8 1108 blr 1109.long 0 1110.byte 0,12,0x14,0,0,0,0,0 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130.align 4 1131_vpaes_schedule_round: 1132 1133 1134 vsldoi 1, 24, 9, 15 1135 vsldoi 24, 24, 24, 15 1136 vxor 7, 7, 1 1137 1138 1139 vspltw 0, 0, 3 1140 vsldoi 0, 0, 0, 1 1141 1142 1143 1144 1145_vpaes_schedule_low_round: 1146 1147 vsldoi 1, 9, 7, 12 1148 vxor 7, 7, 1 1149 vspltisb 1,0x0f 1150 vsldoi 4, 9, 7, 8 1151 1152 1153 vand 1, 1, 0 1154 vsrb 0, 0, 8 1155 vxor 7, 7, 4 1156 vperm 2, 11, 9, 1 1157 vxor 1, 1, 0 1158 vperm 3, 10, 9, 0 1159 vxor 3, 3, 2 1160 vperm 4, 10, 9, 1 1161 vxor 7, 7, 26 1162 vperm 3, 10, 9, 3 1163 vxor 4, 4, 2 1164 vperm 2, 10, 9, 4 1165 vxor 3, 3, 1 1166 vxor 2, 2, 0 1167 vperm 4, 15, 9, 3 1168 vperm 1, 14, 9, 2 1169 vxor 1, 1, 4 1170 1171 1172 vxor 0, 1, 7 1173 vxor 7, 1, 7 1174 blr 1175.long 0 1176.byte 0,12,0x14,0,0,0,0,0 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187.align 4 1188_vpaes_schedule_transform: 1189 1190 vsrb 2, 0, 8 1191 1192 vperm 0, 12, 12, 0 1193 1194 vperm 2, 13, 13, 2 1195 vxor 0, 0, 2 1196 blr 1197.long 0 1198.byte 0,12,0x14,0,0,0,0,0 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223.align 4 1224_vpaes_schedule_mangle: 1225 1226 1227 bne 1, Lschedule_mangle_dec 1228 1229 1230 vxor 4, 0, 26 1231 addi 5, 5, 16 1232 vperm 4, 4, 4, 25 1233 vperm 1, 4, 4, 25 1234 vperm 3, 1, 1, 25 1235 vxor 4, 4, 1 1236 lvx 1, 8, 10 1237 vxor 3, 3, 4 1238 1239 vperm 3, 3, 3, 1 1240 addi 8, 8, -16 1241 andi. 8, 8, 0x30 1242 1243 1244 vperm 1, 3, 3, 29 1245 vsel 2,28,1,30 1246 vor 28,1,1 1247 stvx 2, 0, 5 1248 blr 1249 1250.align 4 1251Lschedule_mangle_dec: 1252 1253 1254 vsrb 1, 0, 8 1255 1256 1257 1258 vperm 2, 16, 16, 0 1259 1260 vperm 3, 17, 17, 1 1261 vxor 3, 3, 2 1262 vperm 3, 3, 9, 25 1263 1264 1265 vperm 2, 18, 18, 0 1266 vxor 2, 2, 3 1267 1268 vperm 3, 19, 19, 1 1269 vxor 3, 3, 2 1270 vperm 3, 3, 9, 25 1271 1272 1273 vperm 2, 20, 20, 0 1274 vxor 2, 2, 3 1275 1276 vperm 3, 21, 21, 1 1277 vxor 3, 3, 2 1278 1279 1280 vperm 2, 22, 22, 0 1281 vperm 3, 3, 9, 25 1282 1283 vperm 4, 23, 23, 1 1284 lvx 1, 8, 10 1285 vxor 2, 2, 3 1286 vxor 3, 4, 2 1287 1288 addi 5, 5, -16 1289 1290 vperm 3, 3, 3, 1 1291 addi 8, 8, -16 1292 andi. 8, 8, 0x30 1293 1294 1295 vperm 1, 3, 3, 29 1296 vsel 2,28,1,30 1297 vor 28,1,1 1298 stvx 2, 0, 5 1299 blr 1300.long 0 1301.byte 0,12,0x14,0,0,0,0,0 1302 1303.globl .vpaes_set_encrypt_key 1304.align 5 1305.vpaes_set_encrypt_key: 1306 stdu 1,-256(1) 1307 li 10,63 1308 li 11,79 1309 mflr 0 1310 li 6,-1 1311 stvx 20,10,1 1312 addi 10,10,32 1313 stvx 21,11,1 1314 addi 11,11,32 1315 stvx 22,10,1 1316 addi 10,10,32 1317 stvx 23,11,1 1318 addi 11,11,32 1319 stvx 24,10,1 1320 addi 10,10,32 1321 stvx 25,11,1 1322 addi 11,11,32 1323 stvx 26,10,1 1324 addi 10,10,32 1325 stvx 27,11,1 1326 addi 11,11,32 1327 stvx 28,10,1 1328 addi 10,10,32 1329 stvx 29,11,1 1330 addi 11,11,32 1331 stvx 30,10,1 1332 stvx 31,11,1 1333 stw 6,252(1) 1334 li 7, -1 1335 std 0, 272(1) 1336 or 7,7,7 1337 1338 srwi 9, 4, 5 1339 addi 9, 9, 6 1340 stw 9, 240(5) 1341 1342 cmplw 1,4,4 1343 li 8, 0x30 1344 bl _vpaes_schedule_core 1345 1346 ld 0, 272(1) 1347 li 10,63 1348 li 11,79 1349 or 6,6,6 1350 mtlr 0 1351 xor 3, 3, 3 1352 lvx 20,10,1 1353 addi 10,10,32 1354 lvx 21,11,1 1355 addi 11,11,32 1356 lvx 22,10,1 1357 addi 10,10,32 1358 lvx 23,11,1 1359 addi 11,11,32 1360 lvx 24,10,1 1361 addi 10,10,32 1362 lvx 25,11,1 1363 addi 11,11,32 1364 lvx 26,10,1 1365 addi 10,10,32 1366 lvx 27,11,1 1367 addi 11,11,32 1368 lvx 28,10,1 1369 addi 10,10,32 1370 lvx 29,11,1 1371 addi 11,11,32 1372 lvx 30,10,1 1373 lvx 31,11,1 1374 addi 1,1,256 1375 blr 1376.long 0 1377.byte 0,12,0x04,1,0x80,0,3,0 1378.long 0 1379 1380 1381.globl .vpaes_set_decrypt_key 1382.align 4 1383.vpaes_set_decrypt_key: 1384 stdu 1,-256(1) 1385 li 10,63 1386 li 11,79 1387 mflr 0 1388 li 6,-1 1389 stvx 20,10,1 1390 addi 10,10,32 1391 stvx 21,11,1 1392 addi 11,11,32 1393 stvx 22,10,1 1394 addi 10,10,32 1395 stvx 23,11,1 1396 addi 11,11,32 1397 stvx 24,10,1 1398 addi 10,10,32 1399 stvx 25,11,1 1400 addi 11,11,32 1401 stvx 26,10,1 1402 addi 10,10,32 1403 stvx 27,11,1 1404 addi 11,11,32 1405 stvx 28,10,1 1406 addi 10,10,32 1407 stvx 29,11,1 1408 addi 11,11,32 1409 stvx 30,10,1 1410 stvx 31,11,1 1411 stw 6,252(1) 1412 li 7, -1 1413 std 0, 272(1) 1414 or 7,7,7 1415 1416 srwi 9, 4, 5 1417 addi 9, 9, 6 1418 stw 9, 240(5) 1419 1420 slwi 9, 9, 4 1421 add 5, 5, 9 1422 1423 cmplwi 1, 4, 0 1424 srwi 8, 4, 1 1425 andi. 8, 8, 32 1426 xori 8, 8, 32 1427 bl _vpaes_schedule_core 1428 1429 ld 0, 272(1) 1430 li 10,63 1431 li 11,79 1432 or 6,6,6 1433 mtlr 0 1434 xor 3, 3, 3 1435 lvx 20,10,1 1436 addi 10,10,32 1437 lvx 21,11,1 1438 addi 11,11,32 1439 lvx 22,10,1 1440 addi 10,10,32 1441 lvx 23,11,1 1442 addi 11,11,32 1443 lvx 24,10,1 1444 addi 10,10,32 1445 lvx 25,11,1 1446 addi 11,11,32 1447 lvx 26,10,1 1448 addi 10,10,32 1449 lvx 27,11,1 1450 addi 11,11,32 1451 lvx 28,10,1 1452 addi 10,10,32 1453 lvx 29,11,1 1454 addi 11,11,32 1455 lvx 30,10,1 1456 lvx 31,11,1 1457 addi 1,1,256 1458 blr 1459.long 0 1460.byte 0,12,0x04,1,0x80,0,3,0 1461.long 0 1462 1463