I am trying to write a litle RIOT-OS project which uses AES encryption.
After some fiddling around, I made it work by adding a "CFLAGS +=
-DCRYPTO_AES" line to my Makefile.
Is this the recommended way to do it? I am asking, because I could not
find any reference to it in the documentations.
You need to add:
USEMODULE += crypto
to your Makefile to enable the AES cypher in your implementation.
This line includes the crypto module which includes AES.
Just head over to the RIOT wiki to learn more about modules  and how to use them.
You can also have a look into the crypto unittests  to get some hints how to use the AES implementation.
I did use the USEMODULE clause, but without the addtional CFLAGS
setting, it won't work. aes_init/cipher_init will return 0 because
CIPHER_MAX_CONTEXT_SIZE is set to 1 in sys/include/crypto/ciphers.h.
The unit test you referenced works, because it adds a "CFLAGS +=
-DCRYPTO_THREEDES" (which enables aes, too, because the
CIPHER_MAX_CONTEXT_SIZE set for 3DES is larger then the one for AES) in
the Makefile.include, too.
yes I forgot to mention the CFLAG.
If you use AES I suggest to use:
CFLAGS += -DCRYPTO_AES
CFLAGS += -DCRYPTO_THREEDES
then the appropriate CIPHER_MAX_CONTEXT_SIZE for AES will be defined .
So this is on purpose. This should be added to docs, I think.
Funny, my small example with AES worked without setting any CFLAGS.
that's really interesting since initialize AES should fail .
I didn't tested it with failing initialization.
Could you change your small example accordingly?
I mean change the example in the documentation in #4786