diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-01-14 23:39:29 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-01-14 23:39:29 +0100 |
commit | 4a47b264ac6c072cc180176f84297a93a38e4631 (patch) | |
tree | 3e6f9bd4f8e63b5a754843dab5c22b85f1669c3d /sys/src/9 | |
parent | a57a6e511f15c02b4fd2690197b6f1333b171193 (diff) |
wifi: check tkip/ccmp mac and crc in constant time avoiding timing side channels
Diffstat (limited to 'sys/src/9')
-rw-r--r-- | sys/src/9/pc/wifi.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/src/9/pc/wifi.c b/sys/src/9/pc/wifi.c index ba4f62244..8155b25e3 100644 --- a/sys/src/9/pc/wifi.c +++ b/sys/src/9/pc/wifi.c @@ -1429,8 +1429,7 @@ tkipdecrypt(Wkey *k, Wifipkt *w, Block *b, uvlong tsc) (ulong)b->wp[2]<<16 | (ulong)b->wp[3]<<24; crc = ~crc; - if(ethercrc(b->rp, BLEN(b)) != crc) - return -1; + crc ^= ethercrc(b->rp, BLEN(b)); b->wp -= 8; micsetup(&ms, k->key+16); @@ -1440,7 +1439,7 @@ tkipdecrypt(Wkey *k, Wifipkt *w, Block *b, uvlong tsc) micupdate(&ms, b->rp, BLEN(b)); micfinish(&ms, mic); - return memcmp(b->wp, mic, 8) != 0; + return tsmemcmp(b->wp, mic, 8) | crc; } static uchar* @@ -1561,7 +1560,7 @@ aesCCMdecrypt(int L, int M, uchar *N /* N[15-L] */, for(p = sblock(L, N, 0, b, s), x = t; p < &b[M]; x++, p++) *x ^= *p; - return memcmp(m, t, M) != 0; + return tsmemcmp(m, t, M); } static int |