From 7f83a1efae6a7da19e18268d6298fc11b4e68c57 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 22 Nov 2018 10:38:30 +0100 Subject: [PATCH] pki: Set correct type for imported signatures Issue reported by Tilo Eckert Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/pki_crypto.c | 3 ++- src/pki_gcrypt.c | 3 ++- src/pki_mbedcrypto.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pki_crypto.c b/src/pki_crypto.c index 0c9f8ab4..8f3b21ea 100644 --- a/src/pki_crypto.c +++ b/src/pki_crypto.c @@ -1608,7 +1608,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey, sig->type = type; sig->hash_type = hash_type; - sig->type_c = ssh_key_signature_to_char(type, hash_type); + sig->type_c = pubkey->type_c; /* for all types but RSA */ len = ssh_string_len(sig_blob); @@ -1674,6 +1674,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey, case SSH_KEYTYPE_RSA: case SSH_KEYTYPE_RSA1: sig = pki_signature_from_rsa_blob(pubkey, sig_blob, sig); + sig->type_c = ssh_key_signature_to_char(type, hash_type); break; case SSH_KEYTYPE_ECDSA: #ifdef HAVE_OPENSSL_ECC diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c index e0c356b8..ff60dc67 100644 --- a/src/pki_gcrypt.c +++ b/src/pki_gcrypt.c @@ -1855,7 +1855,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey, sig->type = type; sig->hash_type = hash_type; - sig->type_c = ssh_key_signature_to_char(type, hash_type); + sig->type_c = pubkey->type_c; /* for all types but RSA */ len = ssh_string_len(sig_blob); @@ -1921,6 +1921,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey, ssh_signature_free(sig); return NULL; } + sig->type_c = ssh_key_signature_to_char(type, hash_type); break; case SSH_KEYTYPE_ED25519: rc = pki_ed25519_sig_from_blob(sig, sig_blob); diff --git a/src/pki_mbedcrypto.c b/src/pki_mbedcrypto.c index f4138ab4..da6e4da1 100644 --- a/src/pki_mbedcrypto.c +++ b/src/pki_mbedcrypto.c @@ -904,11 +904,12 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey, sig->type = type; sig->hash_type = hash_type; - sig->type_c = ssh_key_signature_to_char(type, hash_type); + sig->type_c = pubkey->type_c; /* for all types but RSA */ switch(type) { case SSH_KEYTYPE_RSA: sig = pki_signature_from_rsa_blob(pubkey, sig_blob, sig); + sig->type_c = ssh_key_signature_to_char(type, hash_type); break; case SSH_KEYTYPE_ECDSA: { ssh_buffer b;