summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2020-11-30 20:23:01 +0100
committerNiels Möller <nisse@lysator.liu.se>2020-11-30 20:23:01 +0100
commitefdd88ec59d2653bda53070448c8eb1889ca3544 (patch)
treef6f7a29b911fe6c75fefcea84a2d55d1242647ba
parent42443755a94ccb0c99ce5dde6432ad4311c1ca5d (diff)
downloadnettle-efdd88ec59d2653bda53070448c8eb1889ca3544.tar.gz
ppc: Add byte-swapping to chacha_4core, for big-endian builds.
-rw-r--r--powerpc64/p7/chacha-4core.asm13
1 files changed, 13 insertions, 0 deletions
diff --git a/powerpc64/p7/chacha-4core.asm b/powerpc64/p7/chacha-4core.asm
index 49a801be..29d3f3c1 100644
--- a/powerpc64/p7/chacha-4core.asm
+++ b/powerpc64/p7/chacha-4core.asm
@@ -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