mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-09 15:41:10 +03:00
libgcrypt: Reformat
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
@@ -548,9 +548,14 @@ static ssh_buffer privatekey_string_to_buffer(const char *pkey, int type,
|
||||
return out;
|
||||
}
|
||||
|
||||
static int b64decode_rsa_privatekey(const char *pkey, gcry_sexp_t *r,
|
||||
ssh_auth_callback cb, void *userdata, const char *desc) {
|
||||
const unsigned char *data;
|
||||
static int
|
||||
b64decode_rsa_privatekey(const char *pkey,
|
||||
gcry_sexp_t *r,
|
||||
ssh_auth_callback cb,
|
||||
void *userdata,
|
||||
const char *desc)
|
||||
{
|
||||
const unsigned char *data = NULL;
|
||||
ssh_string n = NULL;
|
||||
ssh_string e = NULL;
|
||||
ssh_string d = NULL;
|
||||
@@ -562,8 +567,13 @@ static int b64decode_rsa_privatekey(const char *pkey, gcry_sexp_t *r,
|
||||
ssh_string v = NULL;
|
||||
ssh_buffer buffer = NULL;
|
||||
int rc = 1;
|
||||
gcry_error_t rv = 0;
|
||||
|
||||
buffer = privatekey_string_to_buffer(pkey, SSH_KEYTYPE_RSA, cb, userdata, desc);
|
||||
buffer = privatekey_string_to_buffer(pkey,
|
||||
SSH_KEYTYPE_RSA,
|
||||
cb,
|
||||
userdata,
|
||||
desc);
|
||||
if (buffer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -603,14 +613,23 @@ static int b64decode_rsa_privatekey(const char *pkey, gcry_sexp_t *r,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (gcry_sexp_build(r, NULL,
|
||||
rv = gcry_sexp_build(
|
||||
r,
|
||||
NULL,
|
||||
"(private-key(rsa(n %b)(e %b)(d %b)(p %b)(q %b)(u %b)))",
|
||||
ssh_string_len(n), ssh_string_data(n),
|
||||
ssh_string_len(e), ssh_string_data(e),
|
||||
ssh_string_len(d), ssh_string_data(d),
|
||||
ssh_string_len(p), ssh_string_data(p),
|
||||
ssh_string_len(q), ssh_string_data(q),
|
||||
ssh_string_len(u), ssh_string_data(u))) {
|
||||
ssh_string_len(n),
|
||||
ssh_string_data(n),
|
||||
ssh_string_len(e),
|
||||
ssh_string_data(e),
|
||||
ssh_string_len(d),
|
||||
ssh_string_data(d),
|
||||
ssh_string_len(p),
|
||||
ssh_string_data(p),
|
||||
ssh_string_len(q),
|
||||
ssh_string_data(q),
|
||||
ssh_string_len(u),
|
||||
ssh_string_data(u));
|
||||
if (rv) {
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
@@ -1200,16 +1219,20 @@ ssh_key pki_key_dup(const ssh_key key, int demote)
|
||||
return new;
|
||||
}
|
||||
|
||||
static int pki_key_generate(ssh_key key, int parameter, const char *type_s, int type){
|
||||
gcry_sexp_t params;
|
||||
static int
|
||||
pki_key_generate(ssh_key key, int parameter, const char *type_s, int type)
|
||||
{
|
||||
gcry_sexp_t params = NULL;
|
||||
int rc;
|
||||
rc = gcry_sexp_build(¶ms,
|
||||
NULL,
|
||||
"(genkey(%s(nbits %d)(transient-key)))",
|
||||
type_s,
|
||||
parameter);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case SSH_KEYTYPE_RSA:
|
||||
rc = gcry_pk_genkey(&key->rsa, params);
|
||||
@@ -1228,7 +1251,9 @@ static int pki_key_generate(ssh_key key, int parameter, const char *type_s, int
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
int pki_key_generate_rsa(ssh_key key, int parameter){
|
||||
int
|
||||
pki_key_generate_rsa(ssh_key key, int parameter)
|
||||
{
|
||||
return pki_key_generate(key, parameter, "rsa", SSH_KEYTYPE_RSA);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user