From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [RFC 4/5] dpp: use dpp_append_point
Date: Wed, 13 Mar 2024 10:13:10 -0700 [thread overview]
Message-ID: <20240313171311.695830-5-prestwoj@gmail.com> (raw)
In-Reply-To: <20240313171311.695830-1-prestwoj@gmail.com>
Use dpp_append_point where possible to avoid temporarily copying data
---
src/dpp.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/src/dpp.c b/src/dpp.c
index d710aa98..47ebd495 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -1504,7 +1504,6 @@ static void send_authenticate_response(struct dpp_sm *dpp)
uint8_t frame[512];
uint8_t *ptr = frame;
uint8_t status = DPP_STATUS_OK;
- uint64_t r_proto_key[L_ECC_MAX_DIGITS * 2];
uint8_t version = 2;
struct iovec iov;
uint8_t wrapped2_plaintext[dpp->key_len + 4];
@@ -1514,9 +1513,6 @@ static void send_authenticate_response(struct dpp_sm *dpp)
memset(frame, 0, sizeof(frame));
- l_ecc_point_get_data(dpp->own_proto_public, r_proto_key,
- sizeof(r_proto_key));
-
ptr += dpp_build_header(netdev_get_address(dpp->netdev),
dpp->peer_addr,
DPP_FRAME_AUTHENTICATION_RESPONSE, ptr);
@@ -1526,8 +1522,8 @@ static void send_authenticate_response(struct dpp_sm *dpp)
if (dpp->mutual_auth)
ptr += dpp_append_attr(ptr, DPP_ATTR_INITIATOR_BOOT_KEY_HASH,
dpp->peer_boot_hash, 32);
- ptr += dpp_append_attr(ptr, DPP_ATTR_RESPONDER_PROTOCOL_KEY,
- r_proto_key, dpp->key_len * 2);
+ ptr += dpp_append_point(ptr, DPP_ATTR_RESPONDER_PROTOCOL_KEY,
+ dpp->own_proto_public);
ptr += dpp_append_attr(ptr, DPP_ATTR_PROTOCOL_VERSION, &version, 1);
/* Wrap up secondary data (R-Auth) */
@@ -1778,7 +1774,6 @@ static bool dpp_send_authenticate_request(struct dpp_sm *dpp)
{
uint8_t frame[256];
uint8_t *ptr = frame;
- uint64_t i_proto_key[L_ECC_MAX_DIGITS * 2];
uint8_t version = 2;
struct iovec iov;
struct station *station = station_find(netdev_get_ifindex(dpp->netdev));
@@ -1793,9 +1788,6 @@ static bool dpp_send_authenticate_request(struct dpp_sm *dpp)
return false;
}
- l_ecc_point_get_data(dpp->own_proto_public, i_proto_key,
- sizeof(i_proto_key));
-
ptr += dpp_build_header(netdev_get_address(dpp->netdev),
dpp->peer_addr,
DPP_FRAME_AUTHENTICATION_REQUEST, ptr);
@@ -1803,8 +1795,8 @@ static bool dpp_send_authenticate_request(struct dpp_sm *dpp)
dpp->peer_boot_hash, 32);
ptr += dpp_append_attr(ptr, DPP_ATTR_INITIATOR_BOOT_KEY_HASH,
dpp->own_boot_hash, 32);
- ptr += dpp_append_attr(ptr, DPP_ATTR_INITIATOR_PROTOCOL_KEY,
- i_proto_key, dpp->key_len * 2);
+ ptr += dpp_append_point(ptr, DPP_ATTR_INITIATOR_PROTOCOL_KEY,
+ dpp->own_proto_public);
ptr += dpp_append_attr(ptr, DPP_ATTR_PROTOCOL_VERSION, &version, 1);
if (dpp->role == DPP_CAPABILITY_CONFIGURATOR &&
@@ -1835,7 +1827,6 @@ static void dpp_send_pkex_exchange_request(struct dpp_sm *dpp)
uint8_t hdr[32];
uint8_t attrs[256];
uint8_t *ptr = attrs;
- uint64_t m_data[L_ECC_MAX_DIGITS * 2];
uint16_t group;
struct iovec iov[2];
const uint8_t *own_mac = netdev_get_address(dpp->netdev);
@@ -1855,10 +1846,7 @@ static void dpp_send_pkex_exchange_request(struct dpp_sm *dpp)
ptr += dpp_append_attr(ptr, DPP_ATTR_CODE_IDENTIFIER,
dpp->pkex_id, strlen(dpp->pkex_id));
- l_ecc_point_get_data(dpp->pkex_m, m_data, sizeof(m_data));
-
- ptr += dpp_append_attr(ptr, DPP_ATTR_ENCRYPTED_KEY,
- m_data, dpp->key_len * 2);
+ ptr += dpp_append_point(ptr, DPP_ATTR_ENCRYPTED_KEY, dpp->pkex_m);
iov[1].iov_base = attrs;
iov[1].iov_len = ptr - attrs;
@@ -3018,7 +3006,6 @@ static void dpp_send_pkex_exchange_response(struct dpp_sm *dpp,
uint8_t hdr[32];
uint8_t attrs[256];
uint8_t *ptr = attrs;
- uint64_t n_data[L_ECC_MAX_DIGITS * 2];
uint16_t group;
uint8_t status = DPP_STATUS_OK;
struct iovec iov[2];
@@ -3036,10 +3023,7 @@ static void dpp_send_pkex_exchange_response(struct dpp_sm *dpp,
ptr += dpp_append_attr(ptr, DPP_ATTR_CODE_IDENTIFIER,
dpp->pkex_id, strlen(dpp->pkex_id));
- l_ecc_point_get_data(n, n_data, sizeof(n_data));
-
- ptr += dpp_append_attr(ptr, DPP_ATTR_ENCRYPTED_KEY,
- n_data, dpp->key_len * 2);
+ ptr += dpp_append_point(ptr, DPP_ATTR_ENCRYPTED_KEY, n);
iov[1].iov_base = attrs;
iov[1].iov_len = ptr - attrs;
--
2.34.1
next prev parent reply other threads:[~2024-03-13 17:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 17:13 [RFC 0/5] Initial prep/skeleton for isolating core DPP protocol James Prestwood
2024-03-13 17:13 ` [RFC 1/5] dpp: prep for moving AAD within dpp_append_wrapped_data James Prestwood
2024-03-13 17:13 ` [RFC 2/5] dpp-util: move AAD logic within dpp_append_wrapped_attributes James Prestwood
2024-03-13 17:13 ` [RFC 3/5] dpp-util: add dpp_append_point James Prestwood
2024-03-13 17:13 ` James Prestwood [this message]
2024-03-13 17:13 ` [RFC 5/5] dpp-common: Skeleton for common DPP module James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240313171311.695830-5-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox