瀏覽代碼

easier calculation

Steffen Jaeckel 8 年之前
父節點
當前提交
b84bea8e78
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/pk/asn1/der/bit/der_encode_bit_string.c
  2. 1 1
      src/pk/asn1/der/bit/der_encode_raw_bit_string.c

+ 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) */
    /* store header (include bit padding count in length) */
    x = 0;
    x = 0;
-   y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1;
+   y = ((inlen + 7) >> 3) + 1;
 
 
    out[x++] = 0x03;
    out[x++] = 0x03;
    if (y < 128) {
    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) */
    /* store header (include bit padding count in length) */
    x = 0;
    x = 0;
-   y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1;
+   y = ((inlen + 7) >> 3) + 1;
 
 
    out[x++] = 0x03;
    out[x++] = 0x03;
    if (y < 128) {
    if (y < 128) {