also clear bits in der_decode_raw_bit_string()

This commit is contained in:
Steffen Jaeckel 2017-09-30 01:18:30 +02:00
parent 1d20c32a45
commit 3fef07c03e

View File

@ -17,6 +17,7 @@
#ifdef LTC_DER #ifdef LTC_DER
#define SETBIT(v, n) (v=((unsigned char)(v) | (1U << (unsigned char)(n)))) #define SETBIT(v, n) (v=((unsigned char)(v) | (1U << (unsigned char)(n))))
#define CLRBIT(v, n) (v=((unsigned char)(v) & ~(1U << (unsigned char)(n))))
/** /**
Store a BIT STRING Store a BIT STRING
@ -86,6 +87,8 @@ int der_decode_raw_bit_string(const unsigned char *in, unsigned long inlen,
for (y = 0; y < blen; y++) { for (y = 0; y < blen; y++) {
if (in[x] & (1 << (7 - (y & 7)))) { if (in[x] & (1 << (7 - (y & 7)))) {
SETBIT(out[y/8], 7-(y%8)); SETBIT(out[y/8], 7-(y%8));
} else {
CLRBIT(out[y/8], 7-(y%8));
} }
if ((y & 7) == 7) { if ((y & 7) == 7) {
++x; ++x;