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