mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-10-21 16:13:39 +03:00
pki: update RSA key generation to use default size when parameter is 0
Signed-off-by: Praneeth Sarode <praneethsarode@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
8c4e337ab7
commit
08cbbea461
@@ -2182,6 +2182,7 @@ int ssh_pki_import_cert_file(const char *filename, ssh_key *pkey)
|
||||
*
|
||||
* @param[in] parameter Parameter to the creation of key:
|
||||
* rsa : length of the key in bits (e.g. 1024, 2048, 4096)
|
||||
* If parameter is 0, then the default size will be used.
|
||||
* @param[out] pkey A pointer to store the allocated private key. You need
|
||||
* to free the memory using ssh_key_free().
|
||||
*
|
||||
|
@@ -803,6 +803,10 @@ int pki_key_generate_rsa(ssh_key key, int parameter){
|
||||
unsigned e = 65537;
|
||||
#endif /* OPENSSL_VERSION_NUMBER */
|
||||
|
||||
if (parameter == 0) {
|
||||
parameter = RSA_DEFAULT_KEY_SIZE;
|
||||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||
e = BN_new();
|
||||
key_rsa = RSA_new();
|
||||
|
@@ -1300,6 +1300,10 @@ pki_key_generate(ssh_key key, int parameter, const char *type_s, int type)
|
||||
|
||||
int pki_key_generate_rsa(ssh_key key, int parameter)
|
||||
{
|
||||
if (parameter == 0) {
|
||||
parameter = RSA_DEFAULT_KEY_SIZE;
|
||||
}
|
||||
|
||||
return pki_key_generate(key, parameter, "rsa", SSH_KEYTYPE_RSA);
|
||||
}
|
||||
|
||||
|
@@ -564,6 +564,10 @@ int pki_key_generate_rsa(ssh_key key, int parameter)
|
||||
int rc;
|
||||
const mbedtls_pk_info_t *info = NULL;
|
||||
|
||||
if (parameter == 0) {
|
||||
parameter = RSA_DEFAULT_KEY_SIZE;
|
||||
}
|
||||
|
||||
key->pk = malloc(sizeof(mbedtls_pk_context));
|
||||
if (key->pk == NULL) {
|
||||
return SSH_ERROR;
|
||||
|
Reference in New Issue
Block a user