Fix encoding of "unsigned" integers. If MSB is set, we need to pad

with a zero byte.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12337 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2003-05-27 21:59:52 +00:00
parent ca77d81243
commit 5ce268bf83
3 changed files with 100 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997-2003 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -264,6 +264,15 @@ encode_unsigned (unsigned char *p, size_t len, const unsigned *data,
p -= l;
len -= l;
ret += l;
/* if first octet has msb set, we need to pad with a zero byte */
if(p[1] >= 128) {
if(len == 0)
return ASN1_OVERFLOW;
*p-- = 0;
len--;
ret++;
l++;
}
e = der_put_length_and_tag (p, len, l, UNIV, PRIM, UT_Integer, &l);
if (e)
return e;