mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
pki_crypto: Replace deprecated RSA_generate_key() with RSA_generate_key_ex()
On Mar 16, 09:41, Aris Adamantiadis wrote: > 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 > Yes, you are right. This works, tested with tests/unittests/torture_pki Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
This commit is contained in:
committed by
Andreas Schneider
parent
48354f56ec
commit
0b8d24f800
@@ -383,10 +383,20 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pki_key_generate_rsa(ssh_key key, int parameter){
|
int pki_key_generate_rsa(ssh_key key, int parameter){
|
||||||
key->rsa = RSA_generate_key(parameter, 65537, NULL, NULL);
|
BIGNUM *e;
|
||||||
if(key->rsa == NULL)
|
int rc;
|
||||||
return SSH_ERROR;
|
|
||||||
return SSH_OK;
|
e = BN_new();
|
||||||
|
key->rsa = RSA_new();
|
||||||
|
|
||||||
|
BN_set_word(e, 65537);
|
||||||
|
rc = RSA_generate_key_ex(key->rsa, parameter, e, NULL);
|
||||||
|
|
||||||
|
BN_free(e);
|
||||||
|
|
||||||
|
if (rc == -1 || key->rsa == NULL)
|
||||||
|
return SSH_ERROR;
|
||||||
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pki_key_generate_dss(ssh_key key, int parameter){
|
int pki_key_generate_dss(ssh_key key, int parameter){
|
||||||
|
|||||||
Reference in New Issue
Block a user