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