forked from wolfSSL/wolfssl
adjust GetInt call with ASN1 integer to big number
This commit is contained in:
@@ -18102,6 +18102,7 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_ASN1_INTEGER_new(void)
|
|||||||
|
|
||||||
XMEMSET(a, 0, sizeof(WOLFSSL_ASN1_INTEGER));
|
XMEMSET(a, 0, sizeof(WOLFSSL_ASN1_INTEGER));
|
||||||
a->data = a->intData;
|
a->data = a->intData;
|
||||||
|
a->dataMax = WOLFSSL_ASN1_INTEGER_MAX;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18138,6 +18139,7 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509* x509)
|
|||||||
wolfSSL_ASN1_INTEGER_free(a);
|
wolfSSL_ASN1_INTEGER_free(a);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
a->dataMax = x509->serialSz + 2;
|
||||||
a->isDynamic = 1;
|
a->isDynamic = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22911,7 +22913,7 @@ WOLFSSL_BIGNUM *wolfSSL_ASN1_INTEGER_to_BN(const WOLFSSL_ASN1_INTEGER *ai,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = GetInt(&mpi, ai->data, &idx, sizeof(ai->data))) != 0) {
|
if ((ret = GetInt(&mpi, ai->data, &idx, ai->dataMax)) != 0) {
|
||||||
/* expecting ASN1 format for INTEGER */
|
/* expecting ASN1 format for INTEGER */
|
||||||
WOLFSSL_LEAVE("wolfSSL_ASN1_INTEGER_to_BN", ret);
|
WOLFSSL_LEAVE("wolfSSL_ASN1_INTEGER_to_BN", ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
12
tests/api.c
12
tests/api.c
@@ -15995,7 +15995,7 @@ static void test_wolfSSL_BN(void)
|
|||||||
BIGNUM* b;
|
BIGNUM* b;
|
||||||
BIGNUM* c;
|
BIGNUM* c;
|
||||||
BIGNUM* d;
|
BIGNUM* d;
|
||||||
ASN1_INTEGER ai;
|
ASN1_INTEGER* ai;
|
||||||
unsigned char value[1];
|
unsigned char value[1];
|
||||||
|
|
||||||
printf(testingFmt, "wolfSSL_BN()");
|
printf(testingFmt, "wolfSSL_BN()");
|
||||||
@@ -16006,12 +16006,14 @@ static void test_wolfSSL_BN(void)
|
|||||||
|
|
||||||
value[0] = 0x03;
|
value[0] = 0x03;
|
||||||
|
|
||||||
|
AssertNotNull(ai = ASN1_INTEGER_new());
|
||||||
/* at the moment hard setting since no set function */
|
/* at the moment hard setting since no set function */
|
||||||
ai.data[0] = 0x02; /* tag for ASN_INTEGER */
|
ai->data[0] = 0x02; /* tag for ASN_INTEGER */
|
||||||
ai.data[1] = 0x01; /* length of integer */
|
ai->data[1] = 0x01; /* length of integer */
|
||||||
ai.data[2] = value[0];
|
ai->data[2] = value[0];
|
||||||
|
|
||||||
AssertNotNull(a = ASN1_INTEGER_to_BN(&ai, NULL));
|
AssertNotNull(a = ASN1_INTEGER_to_BN(ai, NULL));
|
||||||
|
ASN1_INTEGER_free(ai);
|
||||||
|
|
||||||
value[0] = 0x02;
|
value[0] = 0x02;
|
||||||
AssertNotNull(BN_bin2bn(value, sizeof(value), b));
|
AssertNotNull(BN_bin2bn(value, sizeof(value), b));
|
||||||
|
@@ -190,6 +190,7 @@ struct WOLFSSL_ASN1_INTEGER {
|
|||||||
/* ASN_INTEGER | LENGTH | hex of number */
|
/* ASN_INTEGER | LENGTH | hex of number */
|
||||||
|
|
||||||
unsigned char* data;
|
unsigned char* data;
|
||||||
|
word32 dataMax; /* max size of data buffer */
|
||||||
byte isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */
|
byte isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user