Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relay ACK MIC incorrectly calculated #92

Closed
StevenCellist opened this issue Oct 9, 2024 · 2 comments
Closed

Relay ACK MIC incorrectly calculated #92

StevenCellist opened this issue Oct 9, 2024 · 2 comments

Comments

@StevenCellist
Copy link

StevenCellist commented Oct 9, 2024

Hi team,

In my opinion, the MIC of the ACK message is not correctly calculated. According to TS011-1.0.0 section 6.2, the CMAC is calculated over block B_0, AckUplinkEnc and WOR, where "WOR contains the data received in the WOR Relay Class A Uplink".
I read this as follows: the Frequency and Datarate fields in the WOR block should be the Frequency and Datarate as received in the WOR frame.
However, in LBM, the MIC is calculated using the Frequency and Datarate of the ACK message:

const relay_tx_channel_config_t* conf =
( infos->last_ch_idx == 0 ) ? &infos->default_ch_config : &( infos->relay_tx_config.second_ch );
wor_ack_mic_info_t ack_mic_info = {
.dev_addr = lorawan_api_devaddr_get( relay_stack_id ),
.wfcnt = infos->fcnt,
.frequency_hz = conf->freq_hz,
.datarate = conf->dr,
};
// SMTC_MODEM_HAL_TRACE_PRINTF( "frequency_hz = %d, infos->last_ch_idx = %d , .dev_addr = %x, datarate = %d\n",
// conf->ack_freq_hz,infos->last_ch_idx,lorawan_api_devaddr_get( relay_stack_id ),conf->dr);
// Key is set to NULL because it is already save in the crypto element (soft or hard)
const uint32_t mic_calc = wor_compute_mic_ack( &ack_mic_info, infos->buffer, NULL );

tmp[3] = mic_info->datarate & 0x0F;
tmp[4] = ( uint8_t )( freq_step );
tmp[5] = ( uint8_t )( freq_step >> 8 );
tmp[6] = ( uint8_t )( freq_step >> 16 );

I think that these fields should refer to the WOR payload's Freq/Dr instead. Please let me know your thoughts!

@mluis1
Copy link

mluis1 commented Oct 10, 2024

Duplicate of #62

@mluis1 mluis1 marked this as a duplicate of #62 Oct 10, 2024
@StevenCellist
Copy link
Author

Ah, sorry, the name of that issue somehow didn't strike my eye as being a duplicate. Thanks! I'll close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants