From: James Prestwood <prestwoj at gmail.com>
To: iwd at lists.01.org
Subject: [PATCH 3/4] dpp-util: add DPP attribute iteration APIs
Date: Mon, 06 Dec 2021 13:03:55 -0800 [thread overview]
Message-ID: <20211206210356.1204046-3-prestwoj@gmail.com> (raw)
In-Reply-To: 20211206210356.1204046-1-prestwoj@gmail.com
[-- Attachment #1: Type: text/plain, Size: 3312 bytes --]
---
src/dpp-util.c | 34 ++++++++++++++++++++++++++++++++++
src/dpp-util.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
diff --git a/src/dpp-util.c b/src/dpp-util.c
index ca641311..b7122de6 100644
--- a/src/dpp-util.c
+++ b/src/dpp-util.c
@@ -94,6 +94,40 @@ char *dpp_generate_uri(const uint8_t *asn1, size_t asn1_len, uint8_t version,
return l_string_unwrap(uri);
}
+void dpp_attr_iter_init(struct dpp_attr_iter *iter, const uint8_t *pdu,
+ size_t len)
+{
+ iter->pos = pdu;
+ iter->end = pdu + len;
+}
+
+bool dpp_attr_iter_next(struct dpp_attr_iter *iter,
+ enum dpp_attribute_type *type_out, size_t *len_out,
+ const uint8_t **data_out)
+{
+ enum dpp_attribute_type type;
+ size_t len;
+
+ if (iter->pos + 4 > iter->end)
+ return false;
+
+ type = l_get_le16(iter->pos);
+ len = l_get_le16(iter->pos + 2);
+
+ iter->pos += 4;
+
+ if (iter->pos + len > iter->end)
+ return false;
+
+ *type_out = type;
+ *len_out = len;
+ *data_out = iter->pos;
+
+ iter->pos += len;
+
+ return true;
+}
+
/*
* EasyConnect 2.0 Table 3. Key and Nonce Length Dependency on Prime Length
*/
diff --git a/src/dpp-util.h b/src/dpp-util.h
index 971c0ce4..6d0dcccb 100644
--- a/src/dpp-util.h
+++ b/src/dpp-util.h
@@ -22,6 +22,55 @@
struct l_ecc_point;
struct l_ecc_scalar;
+enum dpp_attribute_type {
+ /* 0000 - 0FFF reserved */
+ DPP_ATTR_STATUS = 0x1000,
+ DPP_ATTR_INITIATOR_BOOT_KEY_HASH = 0x1001,
+ DPP_ATTR_RESPONDER_BOOT_KEY_HASH = 0x1002,
+ DPP_ATTR_INITIATOR_PROTOCOL_KEY = 0x1003,
+ DPP_ATTR_WRAPPED_DATA = 0x1004,
+ DPP_ATTR_INITIATOR_NONCE = 0x1005,
+ DPP_ATTR_INITIATOR_CAPABILITIES = 0x1006,
+ DPP_ATTR_RESPONDER_NONCE = 0x1007,
+ DPP_ATTR_RESPONDER_CAPABILITIES = 0x1008,
+ DPP_ATTR_RESPONDER_PROTOCOL_KEY = 0x1009,
+ DPP_ATTR_INITIATOR_AUTH_TAG = 0x100a,
+ DPP_ATTR_RESPONDER_AUTH_TAG = 0x100b,
+ DPP_ATTR_CONFIGURATION_OBJECT = 0x100c,
+ DPP_ATTR_CONNECTOR = 0x100d,
+ DPP_ATTR_CONFIGURATION_REQUEST = 0x100e,
+ DPP_ATTR_BOOTSTRAPPING_KEY = 0x100f,
+ /* 1010 - 1011 reserved */
+ DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012,
+ DPP_ATTR_ENCRYPTED_KEY = 0x1013,
+ DPP_ATTR_ENROLLEE_NONCE = 0x1014,
+ DPP_ATTR_CODE_IDENTIFIER = 0x1015,
+ DPP_ATTR_TRANSACTION_ID = 0x1016,
+ DPP_ATTR_BOOTSTRAPPING_INFO = 0x1017,
+ DPP_ATTR_CHANNEL = 0x1018,
+ DPP_ATTR_PROTOCOL_VERSION = 0x1019,
+ DPP_ATTR_ENVELOPED_DATA = 0x101a,
+ DPP_ATTR_SEND_CONN_STATUS = 0x101b,
+ DPP_ATTR_CONN_STATUS = 0x101c,
+ DPP_ATTR_RECONFIGURATION_FLAGS = 0x101d,
+ DPP_ATTR_C_SIGN_KEY_HASH = 0x101e,
+ DPP_ATTR_CSR_ATTRIBUTES_REQUEST = 0x101f,
+ DPP_ATTR_ANONCE = 0x1020,
+ DPP_ATTR_EID = 0x1021,
+ DPP_ATTR_CONFIGURATOR_NONCE = 0x1022,
+};
+
+struct dpp_attr_iter {
+ const uint8_t *pos;
+ const uint8_t *end;
+};
+
+void dpp_attr_iter_init(struct dpp_attr_iter *iter, const uint8_t *pdu,
+ size_t len);
+bool dpp_attr_iter_next(struct dpp_attr_iter *iter,
+ enum dpp_attribute_type *type, size_t *len,
+ const uint8_t **data);
+
char *dpp_generate_uri(const uint8_t *asn1, size_t asn1_len, uint8_t version,
const uint8_t *mac, const uint32_t *freqs,
size_t freqs_len, const char *info, const char *host);
--
2.31.1
reply other threads:[~2021-12-06 21:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211206210356.1204046-3-prestwoj@gmail.com \
--to=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