cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 cryptographic library - GCC compatibility

Tantalum
Associate II
Posted on November 11, 2013 at 20:26

Hello

Maybe I'm wrong, but the

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259409

only provides binaries compatible with compilers from Keil or IAR but none for GCC.

Since the sources aren't openly available, for reasons I can understand, is it possible that somebody from ST provides us an GCC compatible version?

Thank you.

#stm32-cryptograhic-library-gcc #understand-your-tools #understand-your-tools #know-your-tools
23 REPLIES 23
ababo
Associate II
Posted on November 22, 2013 at 10:22

Due to flash memory restrictions, I decided not use the ST Crypto library.

Thanks clive1.

pierpaolo
Associate II
Posted on June 01, 2014 at 18:15

Hi, where I should put that code?

I'm using Eclipse with this Plugin http://gnuarmeclipse.livius.net/blog/ and this Toolchain https://launchpad.net/gcc-arm-embedded, but I can't find any ''abi.c'' file...

Thanks in advance,

Pierpaolo

Posted on June 01, 2014 at 18:32

Hi, where I should put that code? I'm using Eclipse with this Plugin http://gnuarmeclipse.livius.net/blog/ and this Toolchain https://launchpad.net/gcc-arm-embedded, but I can't find any ''abi.c'' file...

 

You can't find the file because I created for the sole purpose of making the linkage work. You take the code, place it in a file called abi.c, or whatever, put that in your project, along with the IAR library. The linker can then get closure on the symbols/functions it needs and you get working code out the back end.

I'd refer to this as a shim or a wrapper, and it's a method of getting two similar but different API/ABI to work together. It's helps to allow code from one brand of compiler to work with another, or code from a different OS or platform work without modifying the original code, which you may, or may not, have access to.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pierpaolo
Associate II
Posted on June 01, 2014 at 20:58

Hi, thanks for the answer!

I'm trying to compile my project, but I can't figure it out.

I'm including the library file (M4_CryptoFW_RngHW_2_0_6.a) via Eclipse, but it says:

Building target: CryptoFirmware.elf

Invoking: Cross ARM C Linker

arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall  -g3 -T libs.ld -T mem.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L''../ldscripts'' -L../libs -Wl,-Map,''CryptoFirmware.map'' -o ''CryptoFirmware.elf''  ./src/abi.o ./src/main.o  ./libs/misc/src/_sbrk.o ./libs/misc/src/_write.o ./libs/misc/src/trace_impl.o  ./libs/cmsis/src/startup_cm.o ./libs/cmsis/src/startup_stm32f4xx.o ./libs/cmsis/src/system_stm32f4xx.o ./libs/cmsis/src/vectors_stm32f4xx.o  ./libs/StdPeriph/src/misc.o ./libs/StdPeriph/src/stm32f4xx_adc.o ./libs/StdPeriph/src/stm32f4xx_can.o ./libs/StdPeriph/src/stm32f4xx_crc.o ./libs/StdPeriph/src/stm32f4xx_cryp.o ./libs/StdPeriph/src/stm32f4xx_cryp_aes.o ./libs/StdPeriph/src/stm32f4xx_cryp_des.o ./libs/StdPeriph/src/stm32f4xx_cryp_tdes.o ./libs/StdPeriph/src/stm32f4xx_dac.o ./libs/StdPeriph/src/stm32f4xx_dbgmcu.o ./libs/StdPeriph/src/stm32f4xx_dcmi.o ./libs/StdPeriph/src/stm32f4xx_dma.o ./libs/StdPeriph/src/stm32f4xx_dma2d.o ./libs/StdPeriph/src/stm32f4xx_exti.o ./libs/StdPeriph/src/stm32f4xx_flash.o ./libs/StdPeriph/src/stm32f4xx_fmc.o ./libs/StdPeriph/src/stm32f4xx_fsmc.o ./libs/StdPeriph/src/stm32f4xx_gpio.o ./libs/StdPeriph/src/stm32f4xx_hash.o ./libs/StdPeriph/src/stm32f4xx_hash_md5.o ./libs/StdPeriph/src/stm32f4xx_hash_sha1.o ./libs/StdPeriph/src/stm32f4xx_i2c.o ./libs/StdPeriph/src/stm32f4xx_iwdg.o ./libs/StdPeriph/src/stm32f4xx_ltdc.o ./libs/StdPeriph/src/stm32f4xx_pwr.o ./libs/StdPeriph/src/stm32f4xx_rcc.o ./libs/StdPeriph/src/stm32f4xx_rng.o ./libs/StdPeriph/src/stm32f4xx_rtc.o ./libs/StdPeriph/src/stm32f4xx_sai.o ./libs/StdPeriph/src/stm32f4xx_sdio.o ./libs/StdPeriph/src/stm32f4xx_spi.o ./libs/StdPeriph/src/stm32f4xx_syscfg.o ./libs/StdPeriph/src/stm32f4xx_tim.o ./libs/StdPeriph/src/stm32f4xx_usart.o ./libs/StdPeriph/src/stm32f4xx_wwdg.o   -llibs/mammtmym4.a

c:/arm/gnu tools arm embedded/4.8 2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld.exe: cannot find -llibs/M4_CryptoFW_RngHW_2_0_6.a

collect2.exe: error: ld returned 1 exit status''

I don't understand why it says so. I tried to change the path, the name, the directory... nothing works. Is this a problem of Eclipse or of my toolchain?

Thanks,

Pierpaolo

Posted on June 01, 2014 at 23:30

I don't understand why it says so. I tried to change the path, the name, the directory... nothing works. Is this a problem of Eclipse or of my toolchain?

Probably the relative paths, and placement within your project, but I have no insight into how you're doing that. Realistically you probably don't need the -l and you could explicitly path the file.

I use Yagarto and makefiles for my GNU/GCC work under Windows.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Paresh Parekh
Associate II
Posted on November 07, 2016 at 12:24

Hi Mr Clive1,

Good Evening,

I had a problem with Cryptography Library module SHA

I have been already working with SWSTM32 Tools. for Developing Camera Application.In this application i need to use SHA256 cryptography algorithm.

Please find attached file in which I mention issue.

Currently Camera application migrate in IAR tools because Cryptography library LIB file available for IAR tools.

Kindly provide me solution

Regards from

Paresh Parekh

________________

Attachments :

Cryptography_Issue.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0pl&d=%2Fa%2F0X0000000bg0%2F9i_oiyKo.KMkfRSfGPRQEcf19i6YZJO8W5rXeYjM8ks&asPdf=false
Posted on November 07, 2016 at 13:28

This perhaps should have been a new thread.

Not really able to divine the cause from the presentation, I would recommend getting it to work in a standalone form, and then integrate with your existing project. Create a number of your own test vectors from a PC implementation you have validated.

One potential pitfall is that the library expects the CRC peripheral to be enabled, as this allows it to validate it is running on an STM32 core. For cores with a programmable CRC module it must be in the default 32-bit mode.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Paresh Parekh
Associate II
Posted on November 11, 2016 at 10:26

Hi Clive1,

Thanks you very much for your support. Once I enable CRC clock my issue solved.

Now SHA256 HASH algorithm works perfectly.

Next step is RSA with 2048 bits key sign algorithm use for digitally sign data.

STM32 Cryptography library support SHA1 with RSA 1024 bits key sign algorithm.

I test this algorithm it's works fine.  

Can you guide me what is the changes require in above application to Digitally sign data on SAH256 with RSA2048 bits key?

Thanks

Paresh Parekh

Posted on November 11, 2016 at 17:09

I'm afraid I don't have the resources to guide you through your project implementation.

The ST library basically covers the functionality it has in common with the hardware HASH/CRYPT engine.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
slimen
Senior
Posted on November 11, 2016 at 18:02

Hello,

I think you are using an old version of crypto-lib 2.0.6 (UM0586) and it will be better referring to the new version

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-software/x-cube-cryptolib.html

 3.1.0 and follow this manual 

http://www.st.com/content/ccc/resource/technical/document/user_manual/group0/f9/6e/f2/a2/b4/ec/49/c0/DM00215061/files/DM00215061.pdf/jcr:content/translations/en.DM00215061.pdf

.

You should use the APIs of SHA256 HASH algorithm instead of SHA1.

About RSA2048, the APIs remain the same as RSA1024, just for RSA_PKCS1v15_Sign function you should use E_SHA256 as ''P_hashType'' input parameter instead of E_SHA1.

Also, use a Modulus and a private Exponent with size 2048 instead of 1024.

Regards