Skip to content

kserin/433mhz

Repository files navigation

433mhz

Project to send 433MHz message with Arduino using rc-switch library.

Protocol

Two layers:

  1. The first one consists of fragments of 32 bits (a long for Arduino). This layer is in charge to segment data in several fragments and to ensure intergrity using CRC check.
  2. TODO (addresses, cipher, seq number anti replay attack)

Layer 1

Fragment datagram:

0 1 2 3 4 5 6 7
Fragment number CRC4
Data
Data
Data

The first fragment contains the total size of the data instead of the first data byte:

0 1 2 3 4 5 6 7
Fragment number ( = 0000) CRC4
Data size
Data
Data

The protocol allows 16 fragments (4 bits used to code the fragment number). Each fragment allows 3 bytes (24 bits) of data except the first which allows 2 bytes (16 bits). So the maximum data the layer 1 allows is: 47 bytes.

ℹ️ rc-switch library allows to repeat transmission of each fragment (using setRepeatTransmit function). In this case, if the message is only composed of one fragment (only fragment n°0), the message may be transmitted several times. For longer messages (more than one fragment), the duplication of fragments will be transparent (because the protocol will compute the next expected fragment number).

Layer 2

Datagram:

bits
0 1 2 3 4 5 6 7
Protocol ( = 00) Data size
Sender address
Receiver address
Sequence number
Sequence number
Sequence number
Sequence number
Secret ID [encrypted part]
Secret ID [encrypted part]
Data (38 bytes) ... [encrypted part]

Data size requires onlys 6 bits as the data part is 38 bytes max (47 bytes are allowed by layer1 and the header size is 9 bytes).

Addresses are encoded with 8 bits which allows 254 possible addresses (0x00 and x0FF are reserved).

The sequence number is a unique number that is incremented at each message. The receiver must ensure to don't trust any message with a sequence number already processed to avoid replay attacks.

The encrypted part (secret ID + data) is encrypted using AES256 CTR algorithm. The CTR nonce is composed of two part: the sequence number for the first 64 bits and the counter for the last 64 bits. As the data is composed of 38 bytes max, only 2 blocs of 128 bits (16 bytes) can be sent for each message. The secretID is used like a password and it is checked after the message decryption. It also ensures that the payload has been correctly decrypted.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages