summaryrefslogtreecommitdiffstats
path: root/src/crypto/mac/ghash
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-04 18:22:33 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-04 19:15:56 +0100
commit822c9e935a25a7590cd99b4c5407bb6596be41b7 (patch)
treebbb54a32dc204bd87174b6c444032a306f7e5c73 /src/crypto/mac/ghash
parent35748654f39a99c226cd14f3b92822eb64bd7037 (diff)
downloadfastd-822c9e935a25a7590cd99b4c5407bb6596be41b7.tar
fastd-822c9e935a25a7590cd99b4c5407bb6596be41b7.zip
Change xor and xor_a back to work on pointers
For some reason, this makes GCC generate much better code on MIPS with -Os
Diffstat (limited to 'src/crypto/mac/ghash')
-rw-r--r--src/crypto/mac/ghash/builtin/ghash_builtin.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c
index c518663..651c7ed 100644
--- a/src/crypto/mac/ghash/builtin/ghash_builtin.c
+++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c
@@ -35,13 +35,13 @@ struct fastd_mac_state {
static const fastd_block128_t r = { .b = {0xe1} };
-static inline uint8_t shr(fastd_block128_t *out, fastd_block128_t in, int n) {
+static inline uint8_t shr(fastd_block128_t *out, const fastd_block128_t *in, int n) {
size_t i;
uint8_t c = 0;
for (i = 0; i < sizeof(fastd_block128_t); i++) {
- uint8_t c2 = in.b[i] << (8-n);
- out->b[i] = (in.b[i] >> n) | c;
+ uint8_t c2 = in->b[i] << (8-n);
+ out->b[i] = (in->b[i] >> n) | c;
c = c2;
}
@@ -53,8 +53,8 @@ static inline void mulH_a(fastd_block128_t *x, const fastd_mac_state_t *cstate)
int i;
for (i = 0; i < 16; i++) {
- xor_a(&out, cstate->H[2*i][x->b[i]>>4]);
- xor_a(&out, cstate->H[2*i+1][x->b[i]&0xf]);
+ xor_a(&out, &cstate->H[2*i][x->b[i]>>4]);
+ xor_a(&out, &cstate->H[2*i+1][x->b[i]&0xf]);
}
*x = out;
@@ -74,11 +74,11 @@ static fastd_mac_state_t* ghash_init(const uint8_t *key) {
int i;
for (i = 1; i < 4; i++) {
- uint8_t carry = shr(&Hbase[i], Hbase[i-1], 1);
+ uint8_t carry = shr(&Hbase[i], &Hbase[i-1], 1);
if (carry)
- xor_a(&Hbase[i], r);
+ xor_a(&Hbase[i], &r);
- shr(&Rbase[i], Rbase[i-1], 1);
+ shr(&Rbase[i], &Rbase[i-1], 1);
}
fastd_block128_t R[16];
@@ -89,8 +89,8 @@ static fastd_mac_state_t* ghash_init(const uint8_t *key) {
int j;
for (j = 0; j < 4; j++) {
if (i & (8 >> j)) {
- xor_a(&state->H[0][i], Hbase[j]);
- xor_a(&R[i], Rbase[j]);
+ xor_a(&state->H[0][i], &Hbase[j]);
+ xor_a(&R[i], &Rbase[j]);
}
}
}
@@ -99,8 +99,8 @@ static fastd_mac_state_t* ghash_init(const uint8_t *key) {
int j;
for (j = 0; j < 16; j++) {
- uint8_t carry = shr(&state->H[i][j], state->H[i-1][j], 4);
- xor_a(&state->H[i][j], R[carry]);
+ uint8_t carry = shr(&state->H[i][j], &state->H[i-1][j], 4);
+ xor_a(&state->H[i][j], &R[carry]);
}
}
@@ -112,7 +112,7 @@ static bool ghash_hash(const fastd_mac_state_t *state, fastd_block128_t *out, co
size_t i;
for (i = 0; i < n_blocks; i++) {
- xor_a(out, in[i]);
+ xor_a(out, &in[i]);
mulH_a(out, state);
}