1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

pki_crypto: Change SSH_KEYTYPE_ED25519 position in switches

The goal here is to avoid errors due to fall through when
HAVE_OPENSSL_ECC is not defined.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Anderson Toshiyuki Sasaki
2019-04-25 18:02:56 +02:00
committed by Andreas Schneider
parent 20c03c289e
commit 58b3b2696c

View File

@@ -1277,6 +1277,12 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
break; break;
} }
case SSH_KEYTYPE_ED25519:
rc = pki_ed25519_public_key_to_blob(buffer, key);
if (rc == SSH_ERROR){
goto fail;
}
break;
case SSH_KEYTYPE_ECDSA_P256: case SSH_KEYTYPE_ECDSA_P256:
case SSH_KEYTYPE_ECDSA_P384: case SSH_KEYTYPE_ECDSA_P384:
case SSH_KEYTYPE_ECDSA_P521: case SSH_KEYTYPE_ECDSA_P521:
@@ -1312,12 +1318,6 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
break; break;
#endif #endif
case SSH_KEYTYPE_ED25519:
rc = pki_ed25519_public_key_to_blob(buffer, key);
if (rc == SSH_ERROR){
goto fail;
}
break;
case SSH_KEYTYPE_UNKNOWN: case SSH_KEYTYPE_UNKNOWN:
default: default:
goto fail; goto fail;
@@ -1537,6 +1537,9 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
case SSH_KEYTYPE_RSA1: case SSH_KEYTYPE_RSA1:
sig_blob = ssh_string_copy(sig->rsa_sig); sig_blob = ssh_string_copy(sig->rsa_sig);
break; break;
case SSH_KEYTYPE_ED25519:
sig_blob = pki_ed25519_sig_to_blob(sig);
break;
case SSH_KEYTYPE_ECDSA_P256: case SSH_KEYTYPE_ECDSA_P256:
case SSH_KEYTYPE_ECDSA_P384: case SSH_KEYTYPE_ECDSA_P384:
case SSH_KEYTYPE_ECDSA_P521: case SSH_KEYTYPE_ECDSA_P521:
@@ -1544,9 +1547,6 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
sig_blob = pki_ecdsa_signature_to_blob(sig); sig_blob = pki_ecdsa_signature_to_blob(sig);
break; break;
#endif #endif
case SSH_KEYTYPE_ED25519:
sig_blob = pki_ed25519_sig_to_blob(sig);
break;
default: default:
case SSH_KEYTYPE_UNKNOWN: case SSH_KEYTYPE_UNKNOWN:
SSH_LOG(SSH_LOG_WARN, "Unknown signature key type: %s", sig->type_c); SSH_LOG(SSH_LOG_WARN, "Unknown signature key type: %s", sig->type_c);
@@ -1821,6 +1821,12 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
goto error; goto error;
} }
break; break;
case SSH_KEYTYPE_ED25519:
rc = pki_ed25519_sig_from_blob(sig, sig_blob);
if (rc != SSH_OK){
goto error;
}
break;
case SSH_KEYTYPE_ECDSA_P256: case SSH_KEYTYPE_ECDSA_P256:
case SSH_KEYTYPE_ECDSA_P384: case SSH_KEYTYPE_ECDSA_P384:
case SSH_KEYTYPE_ECDSA_P521: case SSH_KEYTYPE_ECDSA_P521:
@@ -1834,12 +1840,6 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
} }
break; break;
#endif #endif
case SSH_KEYTYPE_ED25519:
rc = pki_ed25519_sig_from_blob(sig, sig_blob);
if (rc != SSH_OK){
goto error;
}
break;
default: default:
case SSH_KEYTYPE_UNKNOWN: case SSH_KEYTYPE_UNKNOWN:
SSH_LOG(SSH_LOG_WARN, "Unknown signature type"); SSH_LOG(SSH_LOG_WARN, "Unknown signature type");
@@ -2006,6 +2006,13 @@ ssh_signature pki_do_sign_hash(const ssh_key privkey,
} }
sig->dsa_sig = NULL; sig->dsa_sig = NULL;
break; break;
case SSH_KEYTYPE_ED25519:
rc = pki_ed25519_sign(privkey, sig, hash, hlen);
if (rc != SSH_OK){
ssh_signature_free(sig);
return NULL;
}
break;
case SSH_KEYTYPE_ECDSA_P256: case SSH_KEYTYPE_ECDSA_P256:
case SSH_KEYTYPE_ECDSA_P384: case SSH_KEYTYPE_ECDSA_P384:
case SSH_KEYTYPE_ECDSA_P521: case SSH_KEYTYPE_ECDSA_P521:
@@ -2027,13 +2034,6 @@ ssh_signature pki_do_sign_hash(const ssh_key privkey,
break; break;
#endif /* HAVE_OPENSSL_ECC */ #endif /* HAVE_OPENSSL_ECC */
case SSH_KEYTYPE_ED25519:
rc = pki_ed25519_sign(privkey, sig, hash, hlen);
if (rc != SSH_OK){
ssh_signature_free(sig);
return NULL;
}
break;
case SSH_KEYTYPE_UNKNOWN: case SSH_KEYTYPE_UNKNOWN:
default: default:
ssh_signature_free(sig); ssh_signature_free(sig);