mirror of https://github.com/wolfSSL/wolfssl
adjust GetInt call with ASN1 integer to big number
This commit is contained in:
parent
df06707496
commit
cfaed48f90
|
@ -18101,7 +18101,8 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_ASN1_INTEGER_new(void)
|
|||
}
|
||||
|
||||
XMEMSET(a, 0, sizeof(WOLFSSL_ASN1_INTEGER));
|
||||
a->data = a->intData;
|
||||
a->data = a->intData;
|
||||
a->dataMax = WOLFSSL_ASN1_INTEGER_MAX;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -18138,6 +18139,7 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509* x509)
|
|||
wolfSSL_ASN1_INTEGER_free(a);
|
||||
return NULL;
|
||||
}
|
||||
a->dataMax = x509->serialSz + 2;
|
||||
a->isDynamic = 1;
|
||||
}
|
||||
|
||||
|
@ -22911,7 +22913,7 @@ WOLFSSL_BIGNUM *wolfSSL_ASN1_INTEGER_to_BN(const WOLFSSL_ASN1_INTEGER *ai,
|
|||
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 */
|
||||
WOLFSSL_LEAVE("wolfSSL_ASN1_INTEGER_to_BN", ret);
|
||||
return NULL;
|
||||
|
|
12
tests/api.c
12
tests/api.c
|
@ -15995,7 +15995,7 @@ static void test_wolfSSL_BN(void)
|
|||
BIGNUM* b;
|
||||
BIGNUM* c;
|
||||
BIGNUM* d;
|
||||
ASN1_INTEGER ai;
|
||||
ASN1_INTEGER* ai;
|
||||
unsigned char value[1];
|
||||
|
||||
printf(testingFmt, "wolfSSL_BN()");
|
||||
|
@ -16006,12 +16006,14 @@ static void test_wolfSSL_BN(void)
|
|||
|
||||
value[0] = 0x03;
|
||||
|
||||
AssertNotNull(ai = ASN1_INTEGER_new());
|
||||
/* at the moment hard setting since no set function */
|
||||
ai.data[0] = 0x02; /* tag for ASN_INTEGER */
|
||||
ai.data[1] = 0x01; /* length of integer */
|
||||
ai.data[2] = value[0];
|
||||
ai->data[0] = 0x02; /* tag for ASN_INTEGER */
|
||||
ai->data[1] = 0x01; /* length of integer */
|
||||
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;
|
||||
AssertNotNull(BN_bin2bn(value, sizeof(value), b));
|
||||
|
|
|
@ -190,6 +190,7 @@ struct WOLFSSL_ASN1_INTEGER {
|
|||
/* ASN_INTEGER | LENGTH | hex of number */
|
||||
|
||||
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) */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue