diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-12-31 10:59:01 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-12-31 10:59:01 +0100 |
commit | 5cf5f6e9ac953270c696c1f4bd01881d183be5e3 (patch) | |
tree | ec4480836baaca5864ec192561bc92dbbc447f7a /sys/src/libmp/port/mpfmt.c | |
parent | ea212266a15351ee79ce1d99ffcad5dfa291d5b5 (diff) |
libmp: use constant time encode(2) routines instead of lookup tables
the encode(2) routines are constant time now, so
use them instead of using lookup table that can
leak information through cache timing side channel.
Diffstat (limited to 'sys/src/libmp/port/mpfmt.c')
-rw-r--r-- | sys/src/libmp/port/mpfmt.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sys/src/libmp/port/mpfmt.c b/sys/src/libmp/port/mpfmt.c index 837f6f87a..e1dd74267 100644 --- a/sys/src/libmp/port/mpfmt.c +++ b/sys/src/libmp/port/mpfmt.c @@ -17,8 +17,6 @@ toencx(mpint *b, char *buf, int len, int (*enc)(char*, int, uchar*, int)) return rv; } -static char set16[] = "0123456789ABCDEF"; - static int topow2(mpint *b, char *buf, int len, int s) { @@ -39,7 +37,7 @@ topow2(mpint *b, char *buf, int len, int s) if(j != 0 || out != buf){ if(out >= eout) return -1; - *out++ = set16[j]; + *out++ = enc16chr(j); } } } |