[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pki_crypto: Replace deprecated RSA_generate_key() with RSA_generate_key_ex()


Hi Petar,
I agree with the principle, but I don't think this code can work...
RSA_generate_key takes an RSA* as parameter and in our code we probably
have key->rsa==NULL. (if we don't then the old code had a memory leak).

Does the test case work ?

Aris

Le 16/03/14 01:04, Petar Koretic a écrit :
> Hi guys.
>
> This fixes problem on platforms (like Android) where OpenSSL is compiled with
> -no-deprecated option so there is no RSA_generate_key function in library.
>
> Regards,
> Petar
>
> Signed-off-by: Petar Koretic <petar.koretic@xxxxxxxxxx>
> ---
>  src/pki_crypto.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/src/pki_crypto.c b/src/pki_crypto.c
> index 89bb538..9ca7760 100644
> --- a/src/pki_crypto.c
> +++ b/src/pki_crypto.c
> @@ -383,8 +383,16 @@ fail:
>  }
>  
>  int pki_key_generate_rsa(ssh_key key, int parameter){
> -    key->rsa = RSA_generate_key(parameter, 65537, NULL, NULL);
> -    if(key->rsa == NULL)
> +	BIGNUM *e;
> +	e = BN_new();
> +	BN_set_word(e, 65537);
> +
> +	RSA_generate_key_ex(key->rsa, parameter, e, NULL);
> +
> +	BN_free(e);
> +	e = NULL;
> +
> +	if(key->rsa == NULL)
>          return SSH_ERROR;
>      return SSH_OK;
>  }


Archive administrator: postmaster@lists.cynapses.org