PreviousNext
encryptBufferRF
Help > OS functions > Encryption > encryptBufferRF

Function

 

Encrypt bufferRF

Purpose

 

Payload data encryption by the user-specific User key

Syntax

 

void encryptBufferRF(uns8 X)

Parameters

 

X.0-5:   Number of 16 B blocks to be encrypted (1 to 4)

X.6:

     0        User key specified by setUserKey is used

     1        User key in bufferINFO[0 to 15] is used

Input values

 

  –

Return value

 

  –

Output values

 

The specified number of blocks in bufferRF is encrypted by the User key.

Preconditions

 

     For networking as well as non-networking communication.

     It is not allowed to transmit an encrypted 16 B block incomplete otherwise it can not be decrypted correctly.

     All encrypted blocks must completely be transmitted otherwise the whole plaintext can not be decrypted correctly.

Remarks

 

     If blocks < 4, the rest of bufferRF remains unencrypted.

     Industry standard AES-128 b ECB encryption is used.

Side effects

 

  –

See also

 

setUserKey, decryptBufferRF

Example 1

 

// When User key and bufferRF content are already prepared.

encryptBufferRF(2); // 32 B encrypted, User key defined by setUserKey()

                    // Number of bytes to be sent:

DLEN = 56;          // 56 B: correct (incomplete 24 B block is not encrypted)

DLEN = 32;          // 32 B: correct

DLEN = 31;          // 31 B: incorrect (incomplete encrypted block sent)

RFTXpacket();

Example 2

 

// When User key in bufferINFO and bufferRF content are already prepared.

encryptBufferRF(0b01000000 | 2); // 32 B encrypted, User key in bufferINFO[0 to 15]

DLEN = 32;

RFTXpacket();