This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: AM5728: AM5728 Hardware crypto accelerators

Part Number: AM5728

Hi,

I am trying to check crypto accelerators using cryptodev on TI-AM5728 SDK 6.03 linux referring the link:

http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components/Kernel/Kernel_Drivers/Crypto.html

As per the documentation link above, I performed the following steps:

 Enabled CRYPTO_DEV_SA2UL using make menuconfig and its dependencies

root@am57xx-evm:~#  lsmod | grep sa2ul

sa2ul 36864 1 omap_rng

root@am57xx-evm:~# lsmod | grep cryptodev

cryptodev 49152 0


root@am57xx-evm:~# openssl speed -evp aes-128-cbc -engine cryptodev

invalid engine "cryptodev"
3069685776:error:25066067:DSO support routines:dlfcn_load:could not load the shared library:../openssl-1.1.1b/crypto/dso/dso_dlfcn.c:119:filename(/usr/lib/engines-1.1/cryptodev.so): /usr/lib/engines-1.1/cryptodev.so: cannot open shared object file: No such file or directory
3069685776:error:25070067:DSO support routines:DSO_load:could not load the shared library:../openssl-1.1.1b/crypto/dso/dso_lib.c:162:
3069685776:error:260B6084:engine routines:dynamic_load:dso not found:../openssl-1.1.1b/crypto/engine/eng_dyn.c:414:
3069685776:error:2606A074:engine routines:ENGINE_by_id:no such engine:../openssl-1.1.1b/crypto/engine/eng_list.c:334:id=cryptodev
3069685776:error:25066067:DSO support routines:dlfcn_load:could not load the shared library:../openssl-1.1.1b/crypto/dso/dso_dlfcn.c:119:filename(libcryptodev.so): libcryptodev.so: cannot open shared object file: No such file or directory
3069685776:error:25070067:DSO support routines:DSO_load:could not load the shared library:../openssl-1.1.1b/crypto/dso/dso_lib.c:162:
3069685776:error:260B6084:engine routines:dynamic_load:dso not found:../openssl-1.1.1b/crypto/engine/eng_dyn.c:414:
Doing aes-128-cbc for 3s on 16 size blocks: 9679889 aes-128-cbc's in 2.98s
Doing aes-128-cbc for 3s on 64 size blocks: 3005713 aes-128-cbc's in 2.99s
Doing aes-128-cbc for 3s on 256 size blocks: 815663 aes-128-cbc's in 2.99s
Doing aes-128-cbc for 3s on 1024 size blocks: 208577 aes-128-cbc's in 2.99s
Doing aes-128-cbc for 3s on 8192 size blocks: 26295 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 16384 size blocks: 13150 aes-128-cbc's in 2.99s
OpenSSL 1.1.1b 26 Feb 2019
built on: Sun Apr 19 02:06:32 2020 UTC
options:bn(64,32) rc4(char) des(long) aes(partial) idea(int) blowfish(ptr) 
compiler: arm-linux-gnueabihf-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=recipe-sysroot -isystem/home/gtbldadm/tools/gcc-arm-2019.03/arm-linux-gnueabihf/include -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map= -fdebug-prefix-map= -fdebug-prefix-map= -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DNDEBUG -isystem/home/gtbldadm/tools/gcc-arm-2019.03/arm-linux-gnueabihf/include
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
aes-128-cbc 51972.56k 64336.33k 69836.03k 71432.39k 71802.88k 72056.72k

* It seems cryptodev.so in not present in my SDK 

 Moreover, 

On running command:  

root@am57xx-evm:~# openssl engine -t -c 
(dynamic) Dynamic engine loading support 
[ unavailable ]

Query - As per lsmod command, cryptodev driver is included. But there is no cryptodev engine present in my SDK. Is openssl with cryptodev engine is not supported on AM5728 EVM?

Regards 

Sahil Kalra

  • Hi Sahil,

    Please do not enable CRYPTO_DEV_SA2UL. Document needs some updating. CRYPTO_DEV_SA2UL is for different SoCs & not for am57xx.

    If you look at:

    arch/arm/configs/tisdk_am57xx-evm_defconfig

    CONFIG_CRYPTO_DEV_OMAP=m
    CONFIG_CRYPTO_DEV_OMAP_SHAM=m
    CONFIG_CRYPTO_DEV_OMAP_AES=m
    CONFIG_CRYPTO_DEV_OMAP_DES=m

    You can look for omap-aes/omap-sha with lsmod instead of sa2ul. The HW crypto IP in AM57xx is not SA2UL and it is omap-aes/omap-des/omap-sha.

    Best Regards,
    Keerthy

  • Hi Keerthy,

    Thanks for your response.

    I understand that CRYPTO_DEV_SA2UL module was for AM65x and I have disabled it. However, I have the following queries :

    1. I have already included the OMAP modules you have mentioned in your reply and I am able to verify them using lsmod. What is the significance of including these modules? 

    2. Are these modules solely responsible for activating Hardware Crypto Accelerator?

    3.  I have setup IPSEC tunnel with and without rmmod of these OMAP modules. I could not find any difference in the 2 cases. How can I check the performance of IPSEC with and without hardware crypto accelerator?

    4. I am still not able to run openssl test case with Hardware Crypto Accelerator. It seems from the error that cryptodev engine is missing in our SDK. How to run this openssl testcase on AM5728 SoC.

    Thanks

    Sahil Kalra

  • Hi Sahil,

    Sahil Kalra said:
    1. I have already included the OMAP modules you have mentioned in your reply and I am able to verify them using lsmod. What is the significance of including these modules? 

    They are drivers for crypto hardware accelerators.

    Sahil Kalra said:
    2. Are these modules solely responsible for activating Hardware Crypto Accelerator?

    Correct.

    Sahil Kalra said:
    3.  I have setup IPSEC tunnel with and without rmmod of these OMAP modules. I could not find any difference in the 2 cases. How can I check the performance of IPSEC with and without hardware crypto accelerator?

    That is precisely how you test the HW crypto vs Crypto on CPU(A15). I believe the performances would be similar and
    when the packet sizes are less non-Hardware crypto is known to do better.

    Sahil Kalra said:
    . I am still not able to run openssl test case with Hardware Crypto Accelerator. It seems from the error that cryptodev engine is missing in our SDK. How to run this openssl testcase on AM5728 SoC.

    There are issues with openssl on 4.19 kernel. I believe you are using that.
    Check: https://e2e.ti.com/support/processors/f/791/t/925885#pi320966=4

    Best Regards,
    Keerthy

  • Hello Keerthy, 

    Thanks for clarifying the above doubts. I still have a few queries. Hope you can provide the resolution for the same.

    1. Is the Hardware accelerator and hardware crypto accelerator are two different things on Soc? 

    2. What does Hardware Accelerator using Random Number Generator doing? How shall I verify that it is using Hw Accelerator? 

    3. Similarly, what role does Hardware Accelerator playing in tcrypt testing? 

    PS: Link to which I am referring to:

    https://software-dl.ti.com/processor-sdk-linux/esd/docs/06_03_00_106/linux/Foundational_Components/Kernel/Kernel_Drivers/Crypto.html

    Regards,

    Sahil Kalra

  • Hello Keerthy, 

    Any resolution to my queries?

    Thanks and Regards

    Sahil Kalra

  • Hi Sahil,

    Apologies for the late response. I was out of office for a week.

    Sahil Kalra said:
    1. Is the Hardware accelerator and hardware crypto accelerator are two different things on Soc? 

    No they are same when used in the context of crypto.

    Sahil Kalra said:

    2. What does Hardware Accelerator using Random Number Generator doing? How shall I verify that it is using Hw Accelerator?

    cat /proc/interrupts | grep rng

    You should see that interrupts count will be increasing if the HW accelerator is used. This is enabled by default in the 6.3 SDK.

    Sahil Kalra said:

    3. Similarly, what role does Hardware Accelerator playing in tcrypt testing?

    When the hardware accelerator is enabled the tcrypt test case will use the hardware accelerator for crypto
    operations and the measurements reported are for the HW accelerator.

    ex: 

    [ 4096.153232] testing speed of async ecb(aes) (ecb-aes-omap) encryption
    [ 4096.161897] tcrypt: test 0 (128 bit key, 16 byte blocks): 1332410 operations in 1 seconds (21318560 bytes)
    [ 4097.162090] tcrypt: test 1 (128 bit key, 64 byte blocks): 542480 operations in 1 seconds (34718720 bytes)
    [ 4098.161999] tcrypt: test 2 (128 bit key, 256 byte blocks): 16238 operations in 1 seconds (4156928 bytes)
    [ 4099.161922] tcrypt: test 3 (128 bit key, 1024 byte blocks): 12254 operations in 1 seconds (12548096 bytes)
    [ 4100.162176] tcrypt: test 4 (128 bit key, 8192 byte blocks): 3597 operations in 1 seconds (29466624 bytes)
    [ 4101.162114] tcrypt: test 5 (192 bit key, 16 byte blocks): 1229730 operations in 1 seconds (19675680 bytes)
    [ 4102.162092] tcrypt: test 6 (192 bit key, 64 byte blocks): 478068 operations in 1 seconds (30596352 bytes)
    [ 4103.162004] tcrypt: test 7 (192 bit key, 256 byte blocks): 16654 operations in 1 seconds (4263424 bytes)
    [ 4104.161952] tcrypt: test 8 (192 bit key, 1024 byte blocks): 12110 operations in 1 seconds (12400640 bytes)
    [ 4105.162110] tcrypt: test 9 (192 bit key, 8192 byte blocks): 3652 operations in 1 seconds (29917184 bytes)
    [ 4106.162055] tcrypt: test 10 (256 bit key, 16 byte blocks): 1159445 operations in 1 seconds (18551120 bytes)
    [ 4107.162209] tcrypt: test 11 (256 bit key, 64 byte blocks): 438213 operations in 1 seconds (28045632 bytes)
    [ 4108.162090] tcrypt: test 12 (256 bit key, 256 byte blocks): 17065 operations in 1 seconds (4368640 bytes)
    [ 4109.162038] tcrypt: test 13 (256 bit key, 1024 byte blocks): 12108 operations in 1 seconds (12398592 bytes)
    [ 4110.162226] tcrypt: test 14 (256 bit key, 8192 byte blocks): 3696 operations in 1 seconds (30277632 bytes)

    The algorithm used is: ecb-aes-omap the omap after ecb-aes tells us that hardware accelerator is being employed.

    Hope you can resolve this issue.

    Best Regards,
    Keerthy