cryptsetup-benchmark - Linux


Overview

cryptsetup-benchmark evaluates the performance of cryptographic algorithms supported by cryptsetup. It provides detailed timing information for encryption, decryption, and key setup operations. This allows users to assess the suitability of different algorithms for their specific workloads and environments.

Syntax

cryptsetup-benchmark [options] algorithm

Options/Flags

  • -d, –device : Specify the storage device or file to use.
  • -t, –test-type : Select the test type: full, partial, or setup.
  • -F, –format : Output format: text, json, or csv.
  • -i, –iterations : Number of iterations to perform (default: 100).
  • -b, –block-size : Block size in bytes (default: 4096).
  • -s, –size : Data size in bytes (default: 4096).
  • -K, –key-size : Key size in bits (default: 256).
  • -v, –verbose: Enable verbose output.
  • -h, –help: Display help and usage information.

Examples

  • Benchmark AES-256 encryption for a 100MB file:
cryptsetup-benchmark aes-256 --device /dev/sda1 --test-type full --size 104857600
  • Generate JSON output for partial encryption of a 512MB device:
cryptsetup-benchmark twofish --device /dev/sdc1 --test-type partial --size 524288000 --format json
  • Run setup benchmark for Blowfish with 1000 iterations:
cryptsetup-benchmark blowfish --device /dev/sdb1 --test-type setup --iterations 1000

Common Issues

  • Slow performance: Ensure that the hardware supports AES-NI (Advanced Encryption Standard – New Instructions).
  • Insufficient permissions: Make sure you have sufficient privileges to access the device or file being benchmarked.
  • Incompatible algorithm: Verify that the specified algorithm is supported by cryptsetup.

Integration

  • Use cryptsetup-benchmark within scripts to automate performance evaluation for different algorithms.
  • Integrate the results into monitoring systems to track encryption performance over time.

Related Commands

  • cryptsetup(8): Manages encrypted partitions and devices.
  • hdparm(8): Reports and manages hard disk performance.
  • iostat(8): Reports I/O statistics of block devices.