OpenSSL and PKA
OpenSSL library is used by applications to handle security communication like TLS/HTTPS along with certificate/key creation and management. BlueField enables high-performance computing by offloading requests to PKA hardware acceleration. The PKA library implements an OpenSSL engine to interact with the OpenSSL library and the PKA hardware.
The following are the layers of components from the application that interacts with the API/OpenSSL library down to the hardware: Application > OpenSSL Library > PKA Library > PKA driver > PKA hardware.
Command | Description |
| Linux command to display CPU information |
| Linux command to list loaded kernel modules |
| BlueField test program to verify PKA library and hardware in multithreaded scenario |
| OpenSSL command to interact with OpenSSL library. Provides certificate/key creation, testing and verification |
Logging is managed by applications using OpenSSL and PKA libraries, similar to Nginx or Apache web servers. You can find the log files in /var/log/nginx or /var/log/access_log.
OpenSSL offers APIs for tracing, which can be found at SSL_CTX_set_msg_callback. Applications should utilize these function calls to trace SSL/TLS protocols.
The PKA API functions communicate status and error information back to the OpenSSL library, which logs these messages if configured to do so. These messages are sent to stderr and depend on the application to redirect them to the application log.
Currently, counters are not exposed to users and are intended for development purposes only.
As an alternative to file logging, using packet capture tools like tcpdump can provide detailed information about the TLS handshake, including status and errors, which is often invaluable for debugging.
Common issues related to OpenSSL and PKA:
PKA Engine Loaded Incorrectly
Library Missing Error
The following indicates that the location for PKA engine shared library file is missing.
$ openssl engine pka
20B095A0FFFF0000:error:12800067:DSO support routines:dlfcn_load:could not load the shared library:../crypto/dso/dso_dlfcn.c:118:filename(/usr/lib/aarch64-linux-gnu/engines-3/pka.so): /usr/lib/aarch64-linux-gnu/engines-3/pka.so: cannot open shared object file: No such file or directory
Version Mismatch Error
The following indicates that the libPKA.so.1 shared library cannot find a definition of function ASYNC_WAIT_CTX_get_fd().
$ openssl speed -engine pka -async_jobs 8 rsa
Error configuring OpenSSL
281474842441520:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:187:filename(/usr/lib64/openssl/engines/libpka.so): /lib64/libPKA.so.1: undefined symbol: ASYNC_WAIT_CTX_get_fd
This is part of the OpenSSL 3.0 async_jobs feature. OpenSSL's shared library should provide this function definition.
Insufficient PKA Resources
PKA hardware has limited PKA ring resources. Bluefield 2 has 32 rings, Bluefield 3 MB has 64 rings, and Bluefield 3 HB has 96. Each process invokes opensll and pka engine will take 4 rings(default) during the lifetime of the process. When pka resource is exhausted. The pka engine will not be loaded correctly.
$ openssl engine pka
(pka) PKA handle is invalid
Known OpenSSL Issue
The following message is benign and can be ignored:
$ openssl engine pka
(pka) BlueField PKA engine support
2090E585FFFF0000:error:1280006A:DSO support routines:dlfcn_bind_func:could not bind to the requested symbol name:../crypto/dso/dso_dlfcn.c:188:symname(EVP_PKEY_base_id): /usr/lib/aarch64-linux-gnu/engines-3/pka.so: undefined symbol: EVP_PKEY_base_id
2090E585FFFF0000:error:1280006A:DSO support routines:DSO_bind_func:could not bind to the requested symbol name:../crypto/dso/dso_lib.c:176:
OpenSSL Utility Cannot Create Certificates
In rare cases, some crypto algorithms are not supported by the OpenSSL library due to compile time configuration. If you run into such an error, please report it to NVIDIA Enterprise Support.
Application Failure due to Error Returned by OpenSSL Function Calls
Example of this is the TLS/OpenSSL connection handshake. The Wireshark or tcpdump handshake will have the error code.
The following is an example response from the HTTPS/TLS server to TLS Client Hello request as captured by Wireshark:
TLSv1.2 Record Layer: Alert (Level: Fatal, Description: Handshake Failure)
Content Type: Alert (21)
Version: TLS 1.2 (0x0303)
Length: 2
Alert Message
Level: Fatal (2)
Description: Handshake Failure (40)
Possible TLS/HTTPS handshaking errors
Network related issue: interface provision, wiring, etc...
TLS errors: TLS versions between client and server, no matching cipher suites/supporting groups/signature algorithms/key management etc...
Please report this error with both information of both client and server-side information. Such as wget for HTTPS client, Apache webserver or google.com as HTTS server.
For all other issues, please follow the below steps to narrow down the errors and report it.
Diagnosing Issues with PKA Library
Make sure CPU support AES algorithm:
$ lscpu Architecture: aarch64 CPU op-mode(s):
32-bit,64-bit Byte Order: Little Endian CPU(s):8On-line CPU(s) list:0-7Vendor ID: ARM Model name: Cortex-A78AE Model:1Thread(s) per core:1Core(s) per socket:8Socket(s):1Stepping: r0p1 BogoMIPS:600.50Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddpCheck if PKA kernel module is loaded and devices(pka rings) are functioning.
$ lsmod | grep pka mlxbf_pka
1269760$ ls /dev/pka/0101214161822123252729303234363844143454749505254565866163811113151719202224262833133353739404244464855153555759606279Run PKA validation test program:
$ /usr/bin/pka_test_validation -c
8-r4-s1PKA system info --------------- PKA API version: v1 Cache line size:64CPU count:8Ring count:4Running PKA inst: pka_test_validation ----------------- Avail rings:4HW rings in use :000000000001111Mode: PKA_F_PROCESS_MODE_SINGLE(bit1) Sync: PKA_F_SYNC_MODE_ENABLE(bit8) num worker threads:8Starting thread_idx=0on cpu_num=0Starting thread_idx=1on cpu_num=1Starting thread_idx=2on cpu_num=2Starting thread_idx=3on cpu_num=3Starting thread_idx=4on cpu_num=4Starting thread_idx=6on cpu_num=6Starting thread_idx=7on cpu_num=7Starting thread_idx=5on cpu_num=5thread_start_routine thread_idx=0cpu_num=0done tests_passed=60tests_failed=0total_tests=60thread_start_routine thread_idx=1cpu_num=1done tests_passed=60tests_failed=0total_tests=60thread_start_routine thread_idx=2cpu_num=2done tests_passed=60tests_failed=0total_tests=60thread_start_routine thread_idx=3cpu_num=3done tests_passed=6tests_failed=0total_tests=60thread_start_routine thread_idx=4cpu_num=4done tests_passed=60tests_failed=0total_tests=60thread_start_routine thread_idx=5cpu_num=5done tests_passed=60tests_failed=0total_tests=60thread_start_routine thread_idx=6cpu_num=6done tests_passed=60tests_failed=0total_tests=60thread_start_routine thread_idx=7cpu_num=7done tests_passed=60tests_failed=0total_tests=60validation tests passed!
Diagnosing Issues with OpenSSL
Verify OpenSSl version
$ openssl version OpenSSL
3.0.215Mar2022(Library: OpenSSL3.0.215Mar2022)Verify if PKA is loaded by Openssl as default. News bfb would NOT have PKA loaded by default.
$ openssl engine (dynamic) Dynamic engine loading support
Check if OpenSSL can load PKA engine/library.
$ openssl engine pka (pka) BlueField PKA engine support
InfoThe printed errors are benign and can be ignored for now.
Check if OpenSSL speed test can load PKA and offload requests to PKA engine in
SYNCmode.$ openssl speed -engine pka rsa Engine
"pka"set. Doing512bitsprivatersa's for 10s: 131665 512 bits private RSA's in9.97s Doing512bitspublicrsa's for 10s: 556640 512 bits public RSA's in10.00s Doing1024bitsprivatersa's for 10s: 38463 1024 bits private RSA's in9.99s ... PKA_ENGINE: pka_modular_exp_crt failed, rc =-1504Key length reaches PKA hardware limitation RSA sign setup failure. No RSA sign will be done. 2040969CFFFF0000:error:1C880004:Provider routines:rsa_sign:RSA lib:../providers/implementations/signature/rsa_sig.c:652: RSA verify setup failure. No RSA verify will be done. version:3.0.2built on: Wed Jan3118:43:232024UTC options: bn(64,64) compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -ffile-prefix-map=/build/openssl-zqLXWk/openssl-3.0.2=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2-DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2CPUINFO: OPENSSL_armcap=0xbfsign verify sign/s verify/s rsa512bits0.000076s0.000018s13206.155664.0rsa1024bits0.000260s0.000033s3850.230368.3rsa2048bits0.001435s0.000087s696.911498.8rsa3072bits0.004575s0.000173s218.65764.5rsa4096bits0.010101s0.000274s99.03651.7InfoPKA library currently supports only up to 4096 bits RSA.
Check if OpenSSL speed test can load PKA and offload requests to PKA engine in
ASYNCmode withasync_jobs.$ openssl speed -engine pka -async_jobs
8dsa Engine"pka"set. Doing512bits sign dsa'sfor10s:152074512bits DSA signs in8.05s Doing512bits verify dsa'sfor10s:173404512bits DSA verify in7.04s Doing1024bits sign dsa'sfor10s:1423771024bits DSA signs in8.04s Doing1024bits verify dsa'sfor10s:1480431024bits DSA verify in7.08s Doing2048bits sign dsa'sfor10s:1165832048bits DSA signs in7.44s Doing2048bits verify dsa'sfor10s:688742048bits DSA verify in4.79s version:3.0.2built on: Wed Jan3118:43:232024UTC options: bn(64,64) compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -ffile-prefix-map=/build/openssl-zqLXWk/openssl-3.0.2=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2-DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2CPUINFO: OPENSSL_armcap=0xbfsign verify sign/s verify/s dsa512bits0.000053s0.000041s18891.224631.2dsa1024bits0.000056s0.000048s17708.620910.0dsa2048bits0.000064s0.000070s15669.814378.7NoteDue to an OpenSSL speed test issue with
async_jobsand RSA, DSA algorithm is used here.InfoPKA library currently support only up to 4096 bits RSA.