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