Browse Source

easier calculation

Steffen Jaeckel 7 years ago
parent
commit
b84bea8e78

+ 1 - 1
src/pk/asn1/der/bit/der_encode_bit_string.c

@@ -47,7 +47,7 @@ int der_encode_bit_string(const unsigned char *in, unsigned long inlen,
 
    /* store header (include bit padding count in length) */
    x = 0;
-   y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1;
+   y = ((inlen + 7) >> 3) + 1;
 
    out[x++] = 0x03;
    if (y < 128) {

+ 1 - 1
src/pk/asn1/der/bit/der_encode_raw_bit_string.c

@@ -49,7 +49,7 @@ int der_encode_raw_bit_string(const unsigned char *in, unsigned long inlen,
 
    /* store header (include bit padding count in length) */
    x = 0;
-   y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1;
+   y = ((inlen + 7) >> 3) + 1;
 
    out[x++] = 0x03;
    if (y < 128) {