cjoin: Initial update of the Join Message implementation compliant with minimal-security-06
#include "idmanager.h"
#include "IEEE802154E.h"
#include "IEEE802154_security.h"
-#include "cbor.h"
+#include "cojp_cbor.h"
#include "eui64.h"
#include "neighbors.h"
@@ -126,7 +126,7 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,
coap_option_iht* coap_outgoingOptions,
uint8_t* coap_outgoingOptionsLen) {
- join_response_t join_response;
+ cojp_configuration_object_t configuration;
owerror_t ret;
opentimers_cancel(cjoin_vars.timerId); // cancel the retransmission timer
@@ -135,12 +135,17 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,
return E_FAIL;
}
- ret = cbor_parse_join_response(&join_response, msg->payload, msg->length);
+ ret = cojp_cbor_decode_configuration_object(msg->payload, msg->length, &configuration);
if (ret == E_FAIL) { return E_FAIL; }
+ if (configuration.keyset.num_keys == 1 &&
+ configuration.keyset.key[0].key_usage == COJP_KEY_USAGE_6TiSCH_K1K2_ENC_MIC32) {
// set the L2 keys as per the parsed value
- IEEE802154_security_setBeaconKey(join_response.keyset.key[0].kid[0], join_response.keyset.key[0].k);
- IEEE802154_security_setDataKey(join_response.keyset.key[0].kid[0], join_response.keyset.key[0].k);
+ IEEE802154_security_setBeaconKey(configuration.keyset.key[0].key_index, configuration.keyset.key[0].key_value);
+ IEEE802154_security_setDataKey(configuration.keyset.key[0].key_index, configuration.keyset.key[0].key_value);
+ } else {
+ // TODO not supported for now
+ }
cjoin_setIsJoined(TRUE); // declare join is over
