summaryrefslogtreecommitdiff
path: root/sys/src/libmp/port/letomp.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-11-21 09:39:59 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-11-21 09:39:59 +0100
commit38e1e5272fc9c66a00d702246813135452819ffe (patch)
treeb2d56b8f5e66a17daeb63693fc4dbd15c7308275 /sys/src/libmp/port/letomp.c
parentb677ab0c5909942bf8946e9e9bd148dea7dae718 (diff)
libmp: initial attempt at constant time code, faster reductions for special primes (for ecc)
introduce MPtimesafe flag to request time invariant computation disables normalization so significant digits are not leaked.
Diffstat (limited to 'sys/src/libmp/port/letomp.c')
-rw-r--r--sys/src/libmp/port/letomp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/src/libmp/port/letomp.c b/sys/src/libmp/port/letomp.c
index e23fed21e..d5cca241b 100644
--- a/sys/src/libmp/port/letomp.c
+++ b/sys/src/libmp/port/letomp.c
@@ -9,8 +9,10 @@ letomp(uchar *s, uint n, mpint *b)
int i=0, m = 0;
mpdigit x=0;
- if(b == nil)
+ if(b == nil){
b = mpnew(0);
+ setmalloctag(b, getcallerpc(&s));
+ }
mpbits(b, 8*n);
for(; n > 0; n--){
x |= ((mpdigit)(*s++)) << i;
@@ -24,5 +26,6 @@ letomp(uchar *s, uint n, mpint *b)
if(i > 0)
b->p[m++] = x;
b->top = m;
- return b;
+ b->sign = 1;
+ return mpnorm(b);
}