|
3 | 3 |
|
4 | 4 | This file contains benchmarks for various Rust encryption libraries using Criterion, |
5 | 5 | comparing AEAD (Authenticated Encryption with Associated Data) ciphers commonly used |
6 | | -in the Noise Protocol Framework and TLS 1.2/1.3. |
| 6 | +in TLS 1.2/1.3 and the Noise Protocol Framework. |
7 | 7 |
|
8 | 8 | The benchmarks focus on: |
9 | 9 | - **AES-256-GCM**: Hardware-accelerated AEAD cipher |
10 | 10 | - **ChaCha20-Poly1305**: Software-optimized AEAD cipher |
11 | 11 |
|
12 | | -For accurate stats aggregation, on each iteration, the whole file is scanned. |
13 | | -Be warned, for large files, it may take a while! |
14 | | -
|
15 | 12 | The benchmarks are organized into three categories: |
16 | 13 |
|
17 | 14 | **Key Generation/Setup**: |
18 | | -- ring key generation |
| 15 | +- Ring key generation |
19 | 16 | - OpenSSL cipher initialization |
20 | 17 |
|
21 | 18 | **Encryption** (encrypting dataset tokens): |
22 | | -- ChaCha20-Poly1305 via ring |
23 | | -- AES-256-GCM via ring |
| 19 | +- ChaCha20-Poly1305 via Ring |
| 20 | +- AES-256-GCM via Ring |
24 | 21 | - ChaCha20-Poly1305 IETF via OpenSSL |
25 | 22 | - AES-256-GCM via OpenSSL |
26 | 23 | - ChaCha20-Poly1305 IETF via libsodium |
27 | 24 | - XChaCha20-Poly1305 IETF via libsodium (extended nonce) |
28 | 25 |
|
29 | 26 | **Decryption** (decrypting previously encrypted data): |
30 | | -- ChaCha20-Poly1305 via ring |
31 | | -- AES-256-GCM via ring |
| 27 | +- ChaCha20-Poly1305 via Ring |
| 28 | +- AES-256-GCM via Ring |
32 | 29 | - ChaCha20-Poly1305 IETF via OpenSSL |
33 | 30 | - AES-256-GCM via OpenSSL |
34 | 31 | - ChaCha20-Poly1305 IETF via libsodium |
35 | 32 | - XChaCha20-Poly1305 IETF via libsodium (extended nonce) |
36 | 33 |
|
37 | | -## Noise Protocol Framework & TLS Context |
| 34 | +## System Dependencies |
38 | 35 |
|
39 | | -These ciphers are commonly used in: |
40 | | -- **Noise Protocol Framework**: ChaCha20-Poly1305 (most common), AES-256-GCM |
41 | | -- **TLS 1.2/1.3**: AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305 |
42 | | -- Often paired with SHA-256 for hashing/HMAC operations |
| 36 | +Before running these benchmarks, ensure the following system packages are installed: |
| 37 | +
|
| 38 | +```sh |
| 39 | +sudo apt install -y build-essential pkg-config libssl-dev libsodium-dev # for Ubuntu/Debian |
| 40 | +sudo dnf install -y gcc pkg-config openssl-devel libsodium-devel # for RHEL/Fedora |
| 41 | +brew install pkg-config openssl libsodium # for macOS |
| 42 | +``` |
43 | 43 |
|
44 | 44 | ## Usage Examples |
45 | 45 |
|
@@ -70,8 +70,6 @@ RUSTFLAGS="-C target-cpu=native" \ |
70 | 70 | STRINGWARS_FILTER="(cryption/openssl|cryption/ring)" \ |
71 | 71 | cargo criterion --features bench_encryption bench_encryption |
72 | 72 | ``` |
73 | | -
|
74 | | -Note: AES-GCM benefits significantly from hardware acceleration (AES-NI on x86_64, AES extensions on ARM). |
75 | 73 | "#] |
76 | 74 | use std::hint::black_box; |
77 | 75 |
|
|
0 commit comments