Skip to content

Commit

Permalink
Reduce diff, avoid extra function renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
beldmit committed Oct 19, 2023
1 parent 936d39a commit 1626e1d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions kexecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
6 changes: 3 additions & 3 deletions regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ssh-ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions sshbuf-getput-crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions sshbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 1626e1d

Please sign in to comment.