diff --git a/kexecdh.c b/kexecdh.c index d451b07a20a3..efb2e55a6d42 100644 --- a/kexecdh.c +++ b/kexecdh.c @@ -70,7 +70,7 @@ kex_ecdh_keypair(struct kex *kex) r = SSH_ERR_ALLOC_FAIL; goto out; } - if ((r = sshbuf_put_ecbuf(buf, public_key, group)) != 0 || + if ((r = sshbuf_put_ec(buf, public_key, group)) != 0 || (r = sshbuf_get_u32(buf, NULL)) != 0) goto out; #ifdef DEBUG_KEXECDH @@ -120,7 +120,7 @@ kex_ecdh_enc(struct kex *kex, const struct sshbuf *client_blob, r = SSH_ERR_ALLOC_FAIL; goto out; } - if ((r = sshbuf_put_ecbuf(server_blob, pub_key, group)) != 0 || + if ((r = sshbuf_put_ec(server_blob, pub_key, group)) != 0 || (r = sshbuf_get_u32(server_blob, NULL)) != 0) goto out; if ((r = kex_ecdh_dec_key_group(kex, client_blob, server_key, group, diff --git a/packet.c b/packet.c index ca4aa5b214c1..e628d091a850 100644 --- a/packet.c +++ b/packet.c @@ -2539,7 +2539,7 @@ sshpkt_getb_froms(struct ssh *ssh, struct sshbuf **valp) int sshpkt_put_ec(struct ssh *ssh, EVP_PKEY *pkey) { - return sshbuf_put_ec(ssh->state->outgoing_packet, pkey); + return sshbuf_put_ecpkey(ssh->state->outgoing_packet, pkey); } #endif /* OPENSSL_HAS_ECC */ diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c index 509a24da5967..7b4cb3cb42cf 100644 --- a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c +++ b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c @@ -240,7 +240,7 @@ sshbuf_getput_crypto_tests(void) TEST_DONE(); #if defined(OPENSSL_HAS_ECC) && defined(OPENSSL_HAS_NISTP256) - TEST_START("sshbuf_put_ec"); + TEST_START("sshbuf_put_ecpkey"); #if (OPENSSL_VERSION_NUMBER >= 0x30000000L) param_bld = OSSL_PARAM_BLD_new(); ASSERT_PTR_NE(param_bld, NULL); @@ -292,9 +292,9 @@ sshbuf_getput_crypto_tests(void) p1 = sshbuf_new(); ASSERT_PTR_NE(p1, NULL); #if (OPENSSL_VERSION_NUMBER >= 0x30000000L) - ASSERT_INT_EQ(sshbuf_put_ec(p1, eck), 0); + ASSERT_INT_EQ(sshbuf_put_ecpkey(p1, eck), 0); #else - ASSERT_INT_EQ(sshbuf_put_ecbuf(p1, EC_KEY_get0_public_key(eck), + ASSERT_INT_EQ(sshbuf_put_ec(p1, EC_KEY_get0_public_key(eck), EC_KEY_get0_group(eck)), 0); #endif ASSERT_INT_EQ(sshbuf_get_string_direct(p1, &d, &s), 0); diff --git a/ssh-ecdsa.c b/ssh-ecdsa.c index 7b51c94a9d4f..a218b0237ed2 100644 --- a/ssh-ecdsa.c +++ b/ssh-ecdsa.c @@ -96,7 +96,7 @@ ssh_ecdsa_serialize_public(const struct sshkey *key, struct sshbuf *b, return SSH_ERR_INVALID_ARGUMENT; if ((r = sshbuf_put_cstring(b, sshkey_curve_nid_to_name(key->ecdsa_nid))) != 0 || - (r = sshbuf_put_ec(b, key->pkey)) != 0) + (r = sshbuf_put_ecpkey(b, key->pkey)) != 0) return r; return 0; diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c index ac3d5d3c876a..798012f90650 100644 --- a/sshbuf-getput-crypto.c +++ b/sshbuf-getput-crypto.c @@ -153,7 +153,7 @@ sshbuf_put_bignum2(struct sshbuf *buf, const BIGNUM *v) #ifdef OPENSSL_HAS_ECC int -sshbuf_put_ecbuf(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) +sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) { u_char d[SSHBUF_MAX_ECPOINT]; size_t len; @@ -173,14 +173,14 @@ sshbuf_put_ecbuf(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) } int -sshbuf_put_ec(struct sshbuf *buf, EVP_PKEY *pkey) +sshbuf_put_ecpkey(struct sshbuf *buf, EVP_PKEY *pkey) { const EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); if (ec == NULL) return SSH_ERR_LIBCRYPTO_ERROR; - return sshbuf_put_ecbuf(buf, EC_KEY_get0_public_key(ec), + return sshbuf_put_ec(buf, EC_KEY_get0_public_key(ec), EC_KEY_get0_group(ec)); /* FIXME beldmit */ #if 0 diff --git a/sshbuf.h b/sshbuf.h index 29b0f25a0e5c..e9d148483554 100644 --- a/sshbuf.h +++ b/sshbuf.h @@ -216,11 +216,12 @@ int sshbuf_get_bignum2_bytes_direct(struct sshbuf *buf, #ifdef WITH_OPENSSL int sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM **valp); int sshbuf_put_bignum2(struct sshbuf *buf, const BIGNUM *v); -/* FIXME beldmit should accept EVP_PKEY * */ +# ifdef OPENSSL_HAS_ECC int sshbuf_get_ec(struct sshbuf *buf, EC_POINT *v, const EC_GROUP *g); int sshbuf_get_eckey(struct sshbuf *buf, EC_KEY *v); -int sshbuf_put_ec(struct sshbuf *buf, EVP_PKEY *pkey); -int sshbuf_put_ecbuf(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g); +int sshbuf_put_ecpkey(struct sshbuf *buf, EVP_PKEY *pkey); +int sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g); +# endif #endif /* WITH_OPENSSL */ /* Dump the contents of the buffer in a human-readable format */