Waspmote Libraries; Waspmote Aes Files; Constructor; Pre-Defined Constants - Libelium Waspmote v15 and Plug & Sense Programming Manual

Waspmote encryption libraries
Table of Contents

Advertisement

4.1. Waspmote Libraries

4.1.1. Waspmote AES Files

WaspAES.h is the header file of the class, and WaspAES.cpp is the class where the functions and variables are implemented.
It is mandatory to include the AES library when using it. The following line must be introduced at the beginning of the code:
#include <WaspAES.h>

4.1.2. Constructor

To start using Waspmote AES library, an object from class 'WaspAES' must be created. This object, called 'AES' , is created inside
the Waspmote AES library and it is public to all libraries. It is used through the guide to show how the Waspmote AES library
works.
When creating this constructor, no variables are initialized by default.

4.1.3. Pre-Defined Constants

There are some constants defined in 'WaspAES.h' related with the different encryption and padding modes that can be used to
encrypt messages.

4.2. Calculating the encrypted message length

Before using an encryption function, the length of the encrypted message is needed in order to create the proper memory
buffers. As the data block size is 16 bytes, the final length is multiple of 16.
The next code shows how to calculate the length of the ciphertext in bytes. The function
total length of the 16-byte data blocks that will be included within the message.
{
char plaintext[] = "Original Text";
uint16_t length;
length = AES.sizeOfBlocks(plaintext);
}

4.3. AES Encryption

The next code shows how to encrypt a message from a plaintext with the function
When calling this function, the mode of operation must be specified between:
is
, the initialization vector must be defined as a 16-byte array of bytes.
CBC
Finally, the padding mode must be specified between two possibilities:
Example of use:
{
// AES 128 encryption: ECB mode, PKCS5 padding
AES.encrypt( 128,
password,
message,
encrypted_message,
ECB,
PKCS5);
AES.encrypt().
or
. In the case that the mode of operation
ECB
CBC
or
PKCS5
ZEROS
-13-
Confidentiality (privacy)
returns the
AES.sizeOfBlocks()
v7.0

Advertisement

Table of Contents
loading

Table of Contents