ref: e3f307a08f2ca7b1dfef1a39e0181cfb30d9e190
parent: 0526b2a45b75203f32df0b335db3eb36825862a3
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jan 14 23:09:47 EST 2017
libsec: avoid temp variables in chacha/salsa ENCRYPT() macro given that we only pass uchar* with constant offsets to the s and d arguments of ENCRYPT(), we do not need the temporary variables sp/dp and the compiler is smart enougth to combine the const offset with the ones from GET4() and PUT4() and emit single load and store instructions for the byte accesses.
--- a/sys/src/libsec/port/chacha.c
+++ b/sys/src/libsec/port/chacha.c
@@ -32,12 +32,9 @@
#define ENCRYPT(s, x, y, d) {\u32int v; \
- uchar *sp, *dp; \
- sp = (s); \
- v = GET4(sp); \
+ v = GET4(s); \
v ^= (x)+(y); \
- dp = (d); \
- PUT4(dp, v); \
+ PUT4(d, v); \
}
static uchar sigma[16] = "expand 32-byte k";
--- a/sys/src/libsec/port/salsa.c
+++ b/sys/src/libsec/port/salsa.c
@@ -9,12 +9,9 @@
#define ENCRYPT(s, x, y, d) {\u32int v; \
- uchar *sp, *dp; \
- sp = (s); \
- v = GET4(sp); \
+ v = GET4(s); \
v ^= (x)+(y); \
- dp = (d); \
- PUT4(dp, v); \
+ PUT4(d, v); \
}
static uchar sigma[16] = "expand 32-byte k";
--
⑨