Link error trying to use AES

I am trying to encrypt something on my Photon, and after including tropicssl/aes.h and making some AES calls, I am getting a linker error:

test.cpp:248: undefined reference to `aes_setkey_dec'
test.cpp:249: undefined reference to `aes_crypt_cbc'

The code compiles fine; it’s just the linker that’s failing. I’m using the Web IDE. What am I missing?

I’m actually getting the exact same problem now when compiling through the web IDE–any fix for this? So far it’s just for the AES functions.

As an update here, my code successfully compiles for the Core and it fails while compiling for the Photon using the Web IDE. I was able to compile successfully about 2 weeks ago so I’m assuming this is related to a recent change.

Any ideas?

undefined reference to `aes_crypt_cbc’
collect2: error: ld returned 1 exit status

@solarplug, the Photon firmware now includes a HAL (Hardware Abstraction Layer) which obfuscates the lower level layers of the firmware. The HAL now provides API interfaces into those lower levels and some have not been implemented yet. Add t that the fact that the Photon uses a Broadcom wifi chip (vs the Core’s TI CC3000) so you can appreciate the challenge. I will ping @mdma but he is on a well deserved vacation until next week. :smile:

Thanks for the quick response!

Is there any work-around for this for the time being?

@solarplug, if you compile locally, you may be able to find a work around. However, the Broadcom WICED library has not been open sourced yet and what you need my be there.

Hi Guys,

Just FYI, I was able to work around this (for now) by simply including the following source file in my project (in the web-IDE):

That was the only file I added (I did not need to add any .h header files) and it now compiles and as far as I can tell is working correctly.

NOTE: You still have to include the following lines at the top of your INO file:

#include "application.h"
#include "spark_protocol.h"
#include "tropicssl/rsa.h"
#include "tropicssl/aes.h"
1 Like

Probably too late to help you out, but this is telling you that the functions are declared in the header files, but there is no object or library file that includes those functions (i.e. a .o or .a file).

You need to compile the core-communication-lib and then include that library in your code.
i.e. cd firmware/core-communication-lib/build ; make PLATFORM=photon

The library is: firmware/core-communication-lib/build/libcore-communication-lib.a.

The simplest thing (I think this works) is to just drop the archive into your src directory when building.