diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-02-06 03:50:03 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-02-06 03:50:03 +0100 |
commit | 5256f4063e381bb7a6f175ea397202e93f8be4b1 (patch) | |
tree | 3bbb9134585cd3e77a5620e3a415277b94d9b547 /sys/src/libsec | |
parent | 02b3c609ed7deb369722617c20f69c5f3f73e570 (diff) |
libsec: fix mkbigint(), asn.1 uses two's compement signed representation
quick fix is to bias the rounding so the msb will always
be zero. should write proper conversion code to actually
deal with signed mpints... also for asn1mpint()... -- cinap
Diffstat (limited to 'sys/src/libsec')
-rw-r--r-- | sys/src/libsec/port/x509.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/sys/src/libsec/port/x509.c b/sys/src/libsec/port/x509.c index 4e151915a..1555210f3 100644 --- a/sys/src/libsec/port/x509.c +++ b/sys/src/libsec/port/x509.c @@ -2461,15 +2461,12 @@ static Elem mkbigint(mpint *p) { Elem e; - uchar *buf; - int buflen; e.tag.class = Universal; e.tag.num = INTEGER; e.val.tag = VBigInt; - buflen = mptobe(p, nil, 0, &buf); - e.val.u.bigintval = makebytes(buf, buflen); - free(buf); + e.val.u.bigintval = newbytes((mpsignif(p)+8)/8); + mptober(p, e.val.u.bigintval->data, e.val.u.bigintval->len); return e; } |