Link Search Menu Expand Document (external link)

Hardware Acceleration

Table of contents

  1. Introduction
  2. Information about CPU capabilities
  3. Information about AES hardware support
  4. Configuration of hardware support for chacha20

Introduction

Encryption algorithms often require a significant amount of computational power, which can have a major impact on overall performance. It therefore makes sense to take advantage of the specialized instructions found in most modern processors to speed up the execution of cryptographic algorithms.

In SQLite3 Multiple Ciphers, this was used for the AES based cipher schemes almost from the very beginning, initially for x86 processors and shortly thereafter for ARM processors as well.

Version 2.0.0 introduced the new AEGIS cipher scheme. It includes specialized implementations for a wide variety of processor generations, ensuring efficient execution. The implementation best suited for the given architecture is selected at runtime.

Special implementations were also introduced in version 2.6.0 for the ChaCha20-Poly1305 default cipher scheme. The implementations were taken from the well-known libsodium library and adapted for integration into SQLite3 Multiple Ciphers (to be compilable in the source amalgamation).

Information about CPU capabilities

Starting with version 2.6.0, a PRAGMA statement is available that can be used to query the available CPU features:

PRAGMA mc_cpu_info = { passphrase | 'passphrase' };

The result is a string containing a list of the detected CPU features.

Feature IdPlatform
sse2x86, x86_64
ssse3x86, x86_64
sse41x86, x86_64
sse42x86, x86_64
avxx86, x86_64
avx2x86, x86_64
avx512fx86, x86_64
aesnix86, x86_64
neonARM, ARM64
armcryptoARM, ARM64
altivecAltiVec

However, just because the CPU supports certain features does not mean that implementations capable of taking advantage of those features are actually available.

Information about AES hardware support

Starting with version 2.6.0, a PRAGMA statement is available that can be used to query whether AES algorithms use hardware acceleration:

PRAGMA mc_aes_info;

The result is a string containing either hardware or software.

hardware means that hardware acceleration is used for the AES algorithms of the cipher schemes aes128cbc, aes256cbc, and sqlcipher. In contrast, software means that a table-based implementation is used for the AES algorithms.

Configuration of hardware support for chacha20

Starting with version 2.6.0, a PRAGMA statement is available that can be used to query or to set which one of available CPU features should be used for accelerating the chacha20 cipher scheme:

PRAGMA mc_chacha20_hwaccel [ = newValue ];

where newValue can be set to one value of the following list:

New valuePlatform
offDo not use hardware acceleration
ssse3Choose given feature for x86, x86_64, WASM SIMD128
avx2Choose given feature for x86, x86_64
avx512fChoose given feature for x86, x86_64
neonChoose given feature for ARM, ARM64
autoChoose the best available implementation automatically
maxChoose maximal hardware acceleration, even if still experimental

The result is a string naming the actually used implementation.

Note

mc_chacha20_hwaccel can also be used as a URI parameter to select the CPU feature for accelerating the ChaCha20 algorithm.


Copyright © 2020-2026 Ulrich Telle. Distributed under an MIT license.