]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
ppc: Add byte-swapping to chacha_4core, for big-endian builds.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 30 Nov 2020 19:23:01 +0000 (20:23 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 30 Nov 2020 19:23:01 +0000 (20:23 +0100)
powerpc64/p7/chacha-4core.asm

index 49a801be135e48e148b4dd85f954f9daa5d2d429..29d3f3c154380c7beeb40f830fc2f3f854f31e88 100644 (file)
@@ -184,6 +184,19 @@ C Load state and splat
        vadduwm v10, v10, T2
        vadduwm v11, v11, T2
 
+IF_BE(`
+       C Output always stored in little-endian byte order.
+       C Can reuse T0 and T1 to construct permutation mask.
+       li       r9, 0
+       lvsl     T0, r9, r9     C 00 01 02 03 ... 0c 0d 0e 0f
+       vspltisb T1, 0x03       C 03 03 03 03 ... 03 03 03 03
+       vxor     T1, T1, T0     C 03 02 01 00 ... 0f 0e 0d 0c
+
+       forloop(i, 0, 15, `
+       vperm   `v'i, `v'i, `v'i, T1
+       ')
+')
+
        stxvw4x VSR(v0), 0, DST
        stxvw4x VSR(v4), r6, DST
        stxvw4x VSR(v8), r7, DST