This is the quick start guide for the AES Driver, with step-by-step instructions on how to configure and use the driver for specific use cases.
The section described below can be compiled into e.g. the main application loop or any other function that might use the AES functionality.
In our basic use case, the AES driver is used to manually encrypt a block of code with AES encryption using a predefined key, and subsequently decrypt it using the same key.
The System Clock Management module is required to enable the clock to the AES module.
When the System Clock Management module has been included, it must be initialized:
Subsequently, the clock to the AES module must be started:
We first define our encryption key, and some encryption data, along with variables to hold encrypted and decrypted data.
Inside our function, we first do a call to aes_software_reset(), to make sure that the AES driver is ready for use:
We configure the driver for manual encryption, with no XOR-ing:
We tell the driver where the key and the encryption data is located:
We are now ready to start encryption, and since we have selected manual triggering, we trigger the module to start by calling aes_start():
We then wait until the module is finished, by checking the status register:
When it is done, we can read out our result using aes_read_outputdata():
Our encrypted data is now stored in the variable encrypted_data.
We will now decrypt the data, and the procedure is very similar. We first set up the driver to do decryption, manually triggered with no XOR-ing:
We tell it where our encrypted data is located:
And tell it to start decryption:
And wait until it is finished:
We read the output:
The decrypted data is now stored in the variable decrypted_data, and is identical to that stored in the variable encryption_data.