diff options
Diffstat (limited to 'src/pki_gcrypt.c')
-rw-r--r-- | src/pki_gcrypt.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c index a39b2607..65c9107f 100644 --- a/src/pki_gcrypt.c +++ b/src/pki_gcrypt.c @@ -749,6 +749,11 @@ ssh_key pki_key_dup(const ssh_key key, int demote) } new->type = key->type; new->type_c = key->type_c; + if (demote) { + new->flags = SSH_KEY_FLAG_PUBLIC; + } else { + new->flags = key->flags; + } switch(key->type) { case SSH_KEYTYPE_DSS: @@ -845,28 +850,28 @@ ssh_key pki_key_dup(const ssh_key key, int demote) break; case SSH_KEYTYPE_RSA: case SSH_KEYTYPE_RSA1: - sexp = gcry_sexp_find_token(key->rsa, "n", 0); + sexp = gcry_sexp_find_token(key->rsa, "e", 0); if (sexp == NULL) { goto fail; } tmp = gcry_sexp_nth_data(sexp, 1, &size); - n = ssh_string_new(size); - if (n == NULL) { + e = ssh_string_new(size); + if (e == NULL) { goto fail; } - ssh_string_fill(n, (char *)tmp, size); + ssh_string_fill(e, (char *)tmp, size); gcry_sexp_release(sexp); - sexp = gcry_sexp_find_token(key->rsa, "e", 0); + sexp = gcry_sexp_find_token(key->rsa, "n", 0); if (sexp == NULL) { goto fail; } tmp = gcry_sexp_nth_data(sexp, 1, &size); - e = ssh_string_new(size); - if (e == NULL) { + n = ssh_string_new(size); + if (n == NULL) { goto fail; } - ssh_string_fill(e, (char *)tmp, size); + ssh_string_fill(n, (char *)tmp, size); gcry_sexp_release(sexp); if (!demote && (key->flags & SSH_KEY_FLAG_PRIVATE)) { |