Skip to content

ARMv8 crypto support for AES with openssl backend #585

@nox-a

Description

@nox-a

We currently evaluate sqlcipher to use on aarch64 (on a Toradex Colibri IMX8X to be precise: https://www.toradex.com/computer-on-modules/colibri-arm-family/nxp-imx-8x)

The SoC has hardware crypt acceleration available, which generally also works when using openssl (v3.2.6), for example:

With hardware acceleration:
openssl speed -elapsed -evp aes-256-cbc
You have chosen to measure elapsed time instead of user CPU time.
Doing AES-256-CBC ops for 3s on 16 size blocks: 10988117 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 64 size blocks: 6580238 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 256 size blocks: 2512161 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 1024 size blocks: 728052 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 8192 size blocks: 95419 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 16384 size blocks: 47871 AES-256-CBC ops in 3.00s
version: 3.2.6
built on: Tue Aug  1 23:00:00 2023 UTC
options: bn(64,64)
compiler: aarch64-poky-linux-gcc  -march=armv8-a+crypto -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map  -fmacro-prefix-map=  -fdebug-prefix-map=  -fmacro-prefix-map=  -fdebug-prefix-map=  -fdebug-prefix-map=  -fmacro-prefix-map=  -fdebug-prefix-map=  -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
CPUINFO: OPENSSL_armcap=0xbd
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
AES-256-CBC      58603.29k   140378.41k   214371.07k   248508.42k   260557.48k   261439.49k

Without hardware, as a reference:
OPENSSL_armcap=0 openssl speed -elapsed -evp aes-256-cbc
You have chosen to measure elapsed time instead of user CPU time.
Doing AES-256-CBC ops for 3s on 16 size blocks: 3179890 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 64 size blocks: 948452 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 256 size blocks: 251006 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 1024 size blocks: 63676 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 8192 size blocks: 7990 AES-256-CBC ops in 3.00s
Doing AES-256-CBC ops for 3s on 16384 size blocks: 3993 AES-256-CBC ops in 3.00s
version: 3.2.6
built on: Tue Aug  1 23:00:00 2023 UTC
options: bn(64,64)
compiler: aarch64-poky-linux-gcc  -march=armv8-a+crypto -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map  -fmacro-prefix-map=  -fdebug-prefix-map=  -fmacro-prefix-map=  -fdebug-prefix-map=  -fdebug-prefix-map=  -fmacro-prefix-map=  -fdebug-prefix-map=  -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
CPUINFO: OPENSSL_armcap=0x0 env:0
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
AES-256-CBC      16959.41k    20233.64k    21419.18k    21734.74k    21818.03k    21807.10k

When we compile sqlcipher and run some tests, we get the same speed, regardless if we set OPENSSL_armcap=0 or not.
Is there a way to actually verify that sqlcipher was compiled correctly/uses hw crypto in openssl?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions