I would like to learn more about RE.

I wrote a simple program on a STM32F107 which does nothing else than encrypting and decrypting a text once using AES128-ECB.

Here is the C code (I intentionally left out the key so far):

    struct AES_ctx TestAes;
uint8_t key[16] =
        { MY_KEY_IS_HERE };
uint8_t InputText[16] =
        { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0 };
AES_init_ctx(&TestAes, key);
AES_ECB_encrypt(&TestAes, InputText);
AES_ECB_decrypt(&TestAes, InputText);

Now I want to find the 16 byte private key in my binary.

When I open the binary in a hex editor and search for my key I find all 16 bytes in a row.

I loaded the binary in Ghidra, installed FindCrypt before and now run the analysis.

FindCrypt now finds AES_Decrytion_SBox_Inverse and AES_Ecryption_SBox.

But both are not my AES key but the SBox. How does it go on after that? In all tutorials I find it looks quite simple, because the Functions Finder finds the AES functions - but since the project is Bare Metal this will probably not work.

I thought FindCrypt looks for some kind of hex pattern which could result in a key...

I have attached the binary. endian is little, architecture is ARM Cortex (I think?!)

Ghidra FindCrypt Analysis


FindCrypt is not supposed to find your key, it's supposed to find fixed, known constants associated with well-known cryptographic algorithms. You can see the byte patterns it's looking for in its database.json. It has done exactly what it was supposed to do. Your job as a reverse engineer is to look at the cross-references to the tables that it found and see if you can determine the key being passed as argument to the encryption or decryption routines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.