diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-01-15 04:09:47 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-01-15 04:09:47 +0100 |
commit | e9bf14ecebd1f7b91968b10cec05620dd338ac0f (patch) | |
tree | d74732107b20c9740a818995a77aab19da10a62c /sys/src/libsec/port | |
parent | 03c44c44b014d29fc62418d6b3cf6ee920c1b6df (diff) |
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.
Diffstat (limited to 'sys/src/libsec/port')
-rw-r--r-- | sys/src/libsec/port/chacha.c | 7 | ||||
-rw-r--r-- | sys/src/libsec/port/salsa.c | 7 |
2 files changed, 4 insertions, 10 deletions
diff --git a/sys/src/libsec/port/chacha.c b/sys/src/libsec/port/chacha.c index 49b7ee906..b885b8b92 100644 --- a/sys/src/libsec/port/chacha.c +++ b/sys/src/libsec/port/chacha.c @@ -32,12 +32,9 @@ enum{ #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"; diff --git a/sys/src/libsec/port/salsa.c b/sys/src/libsec/port/salsa.c index 3a0ba940b..aac9b65c7 100644 --- 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"; |