From 7af8995cdec2783433b01c78a8a6c49b682d1fd1 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Tue, 13 May 2008 13:52:45 +0000 Subject: [PATCH] fixed unsave calculation of mpz_export length --- src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c b/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c index b6285dad7..5eb28cb20 100644 --- a/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c +++ b/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c @@ -373,11 +373,9 @@ 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) { - size_t bits = mpz_sizeinbase(value, 2); /* size in bits */ chunk_t n; - n.len = 1 + bits / 8; /* size in bytes */ - n.ptr = mpz_export(NULL, NULL, 1, n.len, 1, 0, value); + n.ptr = mpz_export(NULL, &n.len, 1, 1, 1, 0, value); return asn1_wrap(ASN1_INTEGER, "m", n); }