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 : Hardware crypto accelerators

Part Number: AM5728

Hello, 

I am trying to check the working on hardware crypto accelerators in Ti-AM5728 SDK 6.03 using this link : 

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

 

  • /lib/modules/`uname -r`/extra/cryptodev.ko 

cryptodev.ko is present in my SDK.

  • lsmod
Module                  Size     Used by
cryptodev              49152    0

This command is also OK.

  • openssl speed -evp aes-128-cbc -engine cryptodev

    On running this command, I am receiving this error.

    invalid engine "cryptodev"
    3069534224: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
    3069534224:error:25070067:DSO support routines:DSO_load:could not load the shared library:../openssl-1.1.1b/crypto/dso/dso_lib.c:162:
    3069534224:error:260B6084:engine routines:dynamic_load:dso not found:../openssl-1.1.1b/crypto/engine/eng_dyn.c:414:
    3069534224:error:2606A074:engine routines:ENGINE_by_id:no such engine:../openssl-1.1.1b/crypto/engine/eng_list.c:334:id=cryptodev
    3069534224: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
    3069534224:error:25070067:DSO support routines:DSO_load:could not load the shared library:../openssl-1.1.1b/crypto/dso/dso_lib.c:162:
    3069534224: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: 8272539 aes-128-cbc's in 2.96s
    Doing aes-128-cbc for 3s on 64 size blocks: 2015138 aes-128-cbc's in 2.97s
    Doing aes-128-cbc for 3s on 256 size blocks: 539253 aes-128-cbc's in 2.97s
    Doing aes-128-cbc for 3s on 1024 size blocks: 143164 aes-128-cbc's in 2.97s
    Doing aes-128-cbc for 3s on 8192 size blocks: 20682 aes-128-cbc's in 2.98s
    Doing aes-128-cbc for 3s on 16384 size blocks: 11453 aes-128-cbc's in 2.97s
    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 44716.43k 43423.85k 46481.07k 49360.25k 56854.68k 63180.46k

Why the error invalid engine "cryptodev" ? Also, it is taking around 3 seconds, means it is not using crypto accelerators for speed testing.

 

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Second Query:

Link referred: https://processors.wiki.ti.com/index.php/Sitara_Linux_Training:_Cryptography

  • openssl version -a

OpenSSL 1.1.1b 26 Feb 2019
built on: Sun Apr 19 02:06:32 2020 UTC
platform: linux-armv4
options: bn(64,32) rc4(char) des(long) 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
OPENSSLDIR: "/usr/lib/ssl-1.1"
ENGINESDIR: "/usr/lib/engines-1.1"
Seeding source: os-specific

  • Basic Encrypt/Decrypt

  • openssl enc -p -aes-256-cbc -salt -in /usr/share/matrix-gui-2.0/index.php -out index_php.enc
  • openssl enc -d -p -aes-256-cbc -in index_php.enc -out index_php.dec

Both these commands of encryption and decryption are working FINE

  • Generate Keys

  • openssl genrsa -out privatekey.pem 1024
  • openssl rsa -in privatekey.pem -pubout > publickey.pem

Able to generate Public and Private Key successfully

  • Generate a Digital Signature (Sign a Hash)

  • openssl dgst -sha256 -sign privatekey.pem -out index_php.sha256 /usr/share/matrix-gui-2.0/index.php

Able to generate digital signature also

  • openssl dgst -sha256 -verify publickey.pem -signature index_php.sha256 /usr/share/matrix-gui-2.0/index.php

Verified OK as well

  • Web Certificate Generation

  • openssl req -x509 -nodes -days 365 -new -key privatekey.pem -out cert.pem
  • openssl x509 -text -in cert.pem


Certificate:
Data:
Version: 3 (0x2)
Serial Number:
3a:91:32:26:68:21:1d:26:94:41:1e:92:54:43:74:ec:0a:44:46:60
Signature Algorithm: sha256WithRSAEncryption
Issuer: C = AB, ST = C, L = D, O = E, OU = F, CN = G, emailAddress = H@i.com
Validity
Not Before: Sep 8 12:48:16 2020 GMT
Not After : Sep 8 12:48:16 2021 GMT
Subject: C = AB, ST = C, L = D, O = E, OU = F, CN = G, emailAddress = H@i.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (1024 bit)
Modulus:
00:c4:b1:b4:41:fc:37:89:bd:a7:bb:21:25:55:1e:
9a:71:94:9b:a1:14:11:b4:02:e8:ee:c4:9f:41:56:
0b:d4:f9:79:a4:76:04:bc:ff:21:3d:24:5b:24:c1:
e8:b1:ef:ef:5f:76:e8:b9:b4:cf:79:dc:15:d3:aa:
a7:67:0d:dc:f8:f3:93:f1:86:02:13:64:39:12:71:
69:25:96:13:8a:a0:62:9f:eb:3b:30:2a:4c:8f:30:
b9:d6:3b:fc:f0:82:f8:e5:f8:2c:c3:42:df:27:4c:
aa:fe:0e:f4:92:c7:2a:8d:1a:27:13:ea:ab:fa:34:
e5:cf:c0:ab:74:a6:00:e3:b9
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Subject Key Identifier:
F5:9E:51:45:68:44:D8:74:C1:9C:78:6E:69:44:5A:B4:AA:E5:88:B7
X509v3 Authority Key Identifier:
keyid:F5:9E:51:45:68:44:D8:74:C1:9C:78:6E:69:44:5A:B4:AA:E5:88:B7

X509v3 Basic Constraints: critical
CA:TRUE
Signature Algorithm: sha256WithRSAEncryption
3c:67:a2:79:3b:8c:46:ef:f0:43:73:e4:3b:14:f3:64:f7:33:
27:c9:ce:9a:88:21:19:0d:54:d8:7a:0a:be:06:f9:e8:60:d7:
96:2e:fa:08:83:6a:96:a0:5a:da:57:67:ef:e0:2f:4a:f9:77:
32:78:92:81:10:94:ca:7b:74:64:26:8b:f3:ef:52:64:1e:df:
d3:56:a5:3d:92:c5:0a:2c:53:fe:66:4a:12:43:6e:fd:d9:dc:
00:0a:82:ac:a3:41:72:8e:76:2b:0f:dc:b1:ca:85:1c:e0:ae:
79:ce:94:8e:b8:7a:27:a1:cd:f4:96:d9:68:cd:1b:91:20:04:
7f:16
-----BEGIN CERTIFICATE-----
MIICnjCCAgegAwIBAgIUOpEyJmghHSaUQR6SVEN07ApERmAwDQYJKoZIhvcNAQEL
BQAwYTELMAkGA1UEBhMCQUIxCjAIBgNVBAgMAUMxCjAIBgNVBAcMAUQxCjAIBgNV
BAoMAUUxCjAIBgNVBAsMAUYxCjAIBgNVBAMMAUcxFjAUBgkqhkiG9w0BCQEWB0hA
aS5jb20wHhcNMjAwOTA4MTI0ODE2WhcNMjEwOTA4MTI0ODE2WjBhMQswCQYDVQQG
EwJBQjEKMAgGA1UECAwBQzEKMAgGA1UEBwwBRDEKMAgGA1UECgwBRTEKMAgGA1UE
CwwBRjEKMAgGA1UEAwwBRzEWMBQGCSqGSIb3DQEJARYHSEBpLmNvbTCBnzANBgkq
hkiG9w0BAQEFAAOBjQAwgYkCgYEAxLG0Qfw3ib2nuyElVR6acZSboRQRtALo7sSf
QVYL1Pl5pHYEvP8hPSRbJMHose/vX3boubTPedwV06qnZw3c+POT8YYCE2Q5EnFp
JZYTiqBin+s7MCpMjzC51jv88IL45fgsw0LfJ0yq/g70kscqjRonE+qr+jTlz8Cr
dKYA47kCAwEAAaNTMFEwHQYDVR0OBBYEFPWeUUVoRNh0wZx4bmlEWrSq5Yi3MB8G
A1UdIwQYMBaAFPWeUUVoRNh0wZx4bmlEWrSq5Yi3MA8GA1UdEwEB/wQFMAMBAf8w
DQYJKoZIhvcNAQELBQADgYEAPGeieTuMRu/wQ3PkOxTzZPczJ8nOmoghGQ1U2HoK
vgb56GDXli76CINqlqBa2ldn7+AvSvl3MniSgRCUynt0ZCaL8+9SZB7f01alPZLF
CixT/mZKEkNu/dncAAqCrKNBco52Kw/cscqFHOCuec6Ujrh6J6HN9JbZaM0bkSAE
fxY=
-----END CERTIFICATE-----

  • openssl verify cert.pem

C = AB, ST = C, L = D, O = E, OU = F, CN = G, emailAddress = H@i.com
error 18 at 0 depth lookup: self signed certificate
error cert.pem: verification failed

Why the verification failed?

 

  • Secure Web Server

  • openssl s_server -key privatekey.pem -cert cert.pem -www &

ACCEPTED

  • But on opening in browser

https://IP:4433