reverted [3945], proper fix for zero value ASN1 integer
This commit is contained in:
@@ -374,9 +374,13 @@ static bool belongs_to(private_gmp_rsa_private_key_t *this, public_key_t *public
|
|||||||
chunk_t gmp_mpz_to_asn1(const mpz_t value)
|
chunk_t gmp_mpz_to_asn1(const mpz_t value)
|
||||||
{
|
{
|
||||||
chunk_t n;
|
chunk_t n;
|
||||||
|
|
||||||
n.ptr = mpz_export(NULL, &n.len, 1, 1, 1, 0, value);
|
n.len = 1 + mpz_sizeinbase(value, 2) / 8; /* size in bytes */
|
||||||
|
n.ptr = mpz_export(NULL, NULL, 1, n.len, 1, 0, value);
|
||||||
|
if (n.ptr == NULL)
|
||||||
|
{ /* if we have zero in "value", gmp returns NULL */
|
||||||
|
n.len = 0;
|
||||||
|
}
|
||||||
return asn1_wrap(ASN1_INTEGER, "m", n);
|
return asn1_wrap(ASN1_INTEGER, "m", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user