diff mbox series

[BlueZ] mesh: agent: add hash calculation of URI

Message ID 20250505124346.6621-2-ceggers@arri.de
State New
Headers show
Series [BlueZ] mesh: agent: add hash calculation of URI | expand

Commit Message

Christian Eggers May 5, 2025, 12:43 p.m. UTC
Mesh profile spec, 3.9.2 Unprovisioned Device beacon:
Along with the Unprovisioned Device beacon, the device may also
advertise a separate non-connectable advertising packet with a Uniform
Resource Identifier (URI) data type ...

The remaining implementation of this feature does already exist.
---
 mesh/agent.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mesh/agent.c b/mesh/agent.c
index a1413c0008dc..86f25ac96a11 100644
--- a/mesh/agent.c
+++ b/mesh/agent.c
@@ -16,7 +16,9 @@ 
 
 #include <ell/ell.h>
 
+#include "mesh/crypto.h"
 #include "mesh/mesh.h"
+#include "mesh/provision.h"
 #include "mesh/error.h"
 #include "mesh/dbus.h"
 #include "mesh/agent.h"
@@ -168,10 +170,19 @@  static bool parse_properties(struct mesh_agent *agent,
 			if (!parse_prov_caps(&agent->caps, &variant))
 				return false;
 		} else if (!strcmp(key, "URI")) {
+			uint8_t salt[16];
+
 			if (!l_dbus_message_iter_get_variant(&variant, "s",
 								&uri_string))
 				return false;
-			/* TODO: compute hash */
+
+			mesh_crypto_s1(uri_string, strlen(uri_string), salt);
+			agent->caps.uri_hash =
+				salt[0] << 24 |
+				salt[1] << 16 |
+				salt[2] <<  8 |
+				salt[3] <<  0;
+			agent->caps.oob_info |= OOB_INFO_URI_HASH;
 		} else if (!strcmp(key, "OutOfBandInfo")) {
 			if (!parse_oob_info(&agent->caps, &variant))
 				return false;