alf*_*lfC 5 linux encryption ssd partitioning luks
在 Linux (Fedora 28) 中,我的主目录 LUKS 已加密,当使用 Gnome Disk(屏幕截图)时,我可以分别对底层 LUKS 分区(上方蓝色矩形)和解密的主分区(下方白色矩形)进行基准测试。
LUKS 分区的访问时间为 500MB/s,但解密后的访问速度为 350MB/s。需要明确的是,这是 500GB SSD 的同一分区。
得出加密使数据访问速度降低 30% (= 150/500)的结论是否公平?
这种类型的数字是否有记录,或者我做错了什么。这比我预期的要慢得多。
编辑:这是我的输出
$ cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 384375 iterations per second for 256-bit key
PBKDF2-sha256 494611 iterations per second for 256-bit key
PBKDF2-sha512 323634 iterations per second for 256-bit key
PBKDF2-ripemd160 293225 iterations per second for 256-bit key
PBKDF2-whirlpool 185917 iterations per second for 256-bit key
argon2i 4 iterations, 748334 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
argon2id 4 iterations, 745443 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 195.0 MiB/s 664.0 MiB/s
serpent-cbc 128b 28.8 MiB/s 94.7 MiB/s
twofish-cbc 128b 58.8 MiB/s 111.6 MiB/s
aes-cbc 256b 146.5 MiB/s 507.3 MiB/s
serpent-cbc 256b 33.3 MiB/s 110.2 MiB/s
twofish-cbc 256b 59.3 MiB/s 123.6 MiB/s
aes-xts 256b 433.7 MiB/s 416.8 MiB/s
serpent-xts 256b 101.0 MiB/s 94.7 MiB/s
twofish-xts 256b 111.8 MiB/s 110.3 MiB/s
aes-xts 512b 349.5 MiB/s 356.6 MiB/s
serpent-xts 512b 101.6 MiB/s 96.0 MiB/s
twofish-xts 512b 111.2 MiB/s 108.1 MiB/s
Run Code Online (Sandbox Code Playgroud)
$ lscpu | grep aes
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall
nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology
nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est
tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer
aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp
tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm
ida arat pln pts flush_l1d
Run Code Online (Sandbox Code Playgroud)
编辑 2020:我更换了计算机,并且得到了完全不同的 crypto 基准测试结果,远远超出了更快的处理器所能解释的范围。所以,我认为我的旧硬件没有专用的加密芯片:
$ cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 1756408 iterations per second for 256-bit key
PBKDF2-sha256 2264742 iterations per second for 256-bit key
PBKDF2-sha512 1653905 iterations per second for 256-bit key
PBKDF2-ripemd160 949797 iterations per second for 256-bit key
PBKDF2-whirlpool 711381 iterations per second for 256-bit key
argon2i 8 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
argon2id 8 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 1256.4 MiB/s 3669.2 MiB/s
serpent-cbc 128b 101.6 MiB/s 771.8 MiB/s
twofish-cbc 128b 230.0 MiB/s 418.4 MiB/s
aes-cbc 256b 947.9 MiB/s 2961.6 MiB/s
serpent-cbc 256b 105.1 MiB/s 785.0 MiB/s
twofish-cbc 256b 235.7 MiB/s 424.5 MiB/s
aes-xts 256b 2209.9 MiB/s 2218.9 MiB/s
serpent-xts 256b 762.0 MiB/s 776.6 MiB/s
twofish-xts 256b 415.7 MiB/s 384.0 MiB/s
aes-xts 512b 1701.8 MiB/s 1677.2 MiB/s
serpent-xts 512b 713.7 MiB/s 769.6 MiB/s
twofish-xts 512b 407.9 MiB/s 414.2 MiB/s
Run Code Online (Sandbox Code Playgroud)
加密会增加额外的 CPU 负载,因为每个磁盘块在访问时都需要由操作系统解密。对于 an\xc2\xa0i7 上的通用 AES 处理,您的测试结果(~600 MB/s 解密)相当平均。
\n\n为了避免这个问题,现代 CPU 通常内置了基于硬件的 AES 支持。英特尔将此功能称为“AES-NI”(显示为lscpu“aes”),它允许达到 2\xe2\x80\x933 GB/s相同 AES 解密的速率。
首先运行lscpu并检查它是否在功能标志中提到“aes”。Intel ARK显示它存在于您的 CPU 型号中,但它可能会被固件 (BIOS) 设置禁用。(ARK 有脚注:“某些产品可以通过处理器配置更新支持 AES 新指令 \xe2\x80\xa6 请联系 OEM 以获取包含最新处理器配置更新的 BIOS。”)
Linux 使用“aesni_intel”模块来启用硬件加速。通过运行来检查它是否在您的内核中启用zgrep AES_NI_INTEL /proc/config.gz。如果它显示“ =y”,则它是主内核映像的一部分并且应该可用。
如果输出显示“ =m”,则它已被编译为模块 \xe2\x80\x93 尝试通过运行 手动加载模块sudo modprobe -v aesni_intel。如果该命令无法找到该模块,您可能必须重新启动。(重新启动后,确保uname -r显示与中相同的内核版本ls /lib/modules。)
| 归档时间: |
|
| 查看次数: |
7718 次 |
| 最近记录: |