This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
proiecte:encrypted-communication [2017/01/23 00:53] veronica.velciu [AES library] |
proiecte:encrypted-communication [2017/01/23 22:30] (current) veronica.velciu [Resources] |
||
---|---|---|---|
Line 41: | Line 41: | ||
void encryptECB(uint8_t *key, uint8_t *plaintext, uint8_t len, uint8_t *ciphertext); | void encryptECB(uint8_t *key, uint8_t *plaintext, uint8_t len, uint8_t *ciphertext); | ||
</ | </ | ||
- | This function encrypts (using AES in ECB mode) //len// bytes of the // | + | This function encrypts (using AES in ECB mode) //len// bytes of the // |
<code C> | <code C> | ||
void decryptECB(uint8_t *key, uint8_t *ciphertext, | void decryptECB(uint8_t *key, uint8_t *ciphertext, | ||
Line 49: | Line 49: | ||
void encryptCBC(uint8_t *key, uint8_t *iv, uint8_t *plaintext, uint8_t len, uint8_t *ciphertext); | void encryptCBC(uint8_t *key, uint8_t *iv, uint8_t *plaintext, uint8_t len, uint8_t *ciphertext); | ||
</ | </ | ||
- | This function encrypts (using AES in CBC mode) //len// bytes of the // | + | This function encrypts (using AES in CBC mode) //len// bytes of the // |
- | As it can be observed, there is no function for AES in CBC mode decryption. This is due to the lack of support in the ATmega128RFA1 Security Module. | + | As it can be observed, there is no function for AES in CBC mode decryption. This is due to the lack of support in the ATmega128RFA1 Security Module |
**Testing the AES library** | **Testing the AES library** | ||
Line 84: | Line 84: | ||
The test vectors were generated using [[http:// | The test vectors were generated using [[http:// | ||
+ | |||
+ | ===== Encrypted communication ===== | ||
+ | |||
+ | The encrypted communication was implemented by extending the SparrowTransfer library with two functions: | ||
+ | <code C> | ||
+ | void sendEncData(uint8_t* key); | ||
+ | uint8_t receiveEncData(uint8_t *key); | ||
+ | </ | ||
+ | |||
+ | The **sendEncData** function receives a key as first parameter, which will be used in order to encrypt the data prior to sending it. The implementation follows these steps: | ||
+ | - Set the header and the size of the message. Please note that the size represents a multiple of 16 bytes (as this is the size of the AES encryption block). | ||
+ | - Copy the data structure to be sent to a message buffer. | ||
+ | - Pad the message buffer with 0, until its length is a multiple of 16. | ||
+ | - Encrypt the payload of the message using **encryptECB** with the given key (the header and the size are not encrypted in order to keep the receive functionality). | ||
+ | - Compute and add the checksum to the message. | ||
+ | - Send the message. | ||
+ | |||
+ | The **receiveEncData** function receives a key as first parameter, which will be used in order to decrypt the payload of the incoming message. The implementation follows these steps: | ||
+ | - Continue reading bytes until the header is encountered. | ||
+ | - Read the size of the message and check that it corresponds to the size needed for the data structure to be encrypted (the first number greater than the size which is also a multiple of 16). | ||
+ | - Continue reading byte by byte until the payload is received. | ||
+ | - Receive the checksum and check it. | ||
+ | - Decrypt the message by using **decryptECB** with the give key and save the plain text to the user data structure. | ||
+ | |||
+ | |||
+ | **Testing the encrypted communication** | ||
+ | |||
+ | In order to demonstrate the implemented functionality, | ||
+ | * **EncTransmitter**: | ||
+ | * **EncReceiver**: | ||
+ | * **BadReceiver**: | ||
+ | |||
+ | {{ : | ||
===== Results ===== | ===== Results ===== | ||
+ | |||
+ | The below picture shows the output of the implemented project. In the upper left corner you can see the output of **EncTransmitter** and in the upper right the output of **EncReceiver**. Below them is the attacker, represented by the **BadReceiver** project. | ||
+ | |||
+ | {{ : | ||
===== Resources ===== | ===== Resources ===== | ||
+ | |||
+ | * AES library implementation: | ||
+ | * AES library tests: {{: | ||
+ | * Modified SparrowRadio library: {{: | ||
+ | * **EncTransmitter**, | ||
+ | |||