loc*_*eed 8 linux encryption dm-crypt luks cryptsetup
我决定用 LUKS+LVM 加密我的根分区。
我的 ThinkPad 设置:
但是我读得越多,我对以下两个主题的了解就越少:
由于cryptsetup
FAQ中的引用,我打算使用 SHA1 而不是 2/512(如某些人建议的那样):
5.20 LUKS 坏了!它使用 SHA-1!
不它不是。SHA-1(学术上)因发现冲突而被破坏,但不能在密钥派生函数中使用它。并且该碰撞漏洞仅供非迭代使用。并且您需要逐字逐句的哈希值。
这基本上意味着,如果您已经有一个插槽密钥,并且您已将 PBKDF2 迭代计数设置为 1(通常 > 10'000),您可以(也许)派生出不同的密码短语,为您提供相同的插槽 -钥匙。但是如果你有槽钥匙,你就可以解锁钥匙槽并获得万能钥匙,打破一切。所以基本上,这个 SHA-1 漏洞允许你在已经打开一个 LUKS 容器的情况下,费力地打开它。
这里真正的问题是人们不了解加密,并声称某些东西被破坏了只是因为使用了某些已被破坏用于特定不同用途的机制。该机制的使用方式非常重要。一次使用而被破坏的散列对于其他用途来说是完全安全的,这就是它。
我读为“除了 SHA-1 之外,没有任何意义”。但后来有人告诉我,事实并非如此。所以我不再知道该怎么想了。
此外,我找不到任何信息,一旦磁盘解锁并登录系统,密码是否对磁盘读/写/搜索性能有任何影响。
那么密码的复杂性是只影响密码输入阶段的“性能”,还是系统正常使用时的“性能”呢?
这几天我一直在阅读这个,但我读得越多,我就越困惑。我读到的一切都说 AES 是最快的,而 Serpent 是最慢的。但不是根据我的笔记本电脑:
$ cryptsetup benchmark
Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 344926 iterations per second
PBKDF2-sha256 198593 iterations per second
PBKDF2-sha512 129007 iterations per second
PBKDF2-ripemd160 271933 iterations per second
PBKDF2-whirlpool 134295 iterations per second
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 149.8 MiB/s 147.9 MiB/s
serpent-cbc 128b 51.0 MiB/s 196.4 MiB/s
twofish-cbc 128b 127.6 MiB/s 152.5 MiB/s
aes-cbc 256b 114.3 MiB/s 113.8 MiB/s
serpent-cbc 256b 51.2 MiB/s 198.9 MiB/s
twofish-cbc 256b 129.8 MiB/s 167.5 MiB/s
aes-xts 256b 153.3 MiB/s 150.6 MiB/s
serpent-xts 256b 176.4 MiB/s 184.1 MiB/s
twofish-xts 256b 160.8 MiB/s 159.8 MiB/s
aes-xts 512b 115.4 MiB/s 112.1 MiB/s
serpent-xts 512b 178.6 MiB/s 184.2 MiB/s
twofish-xts 512b 160.7 MiB/s 158.9 MiB/s
Run Code Online (Sandbox Code Playgroud)
所以看起来 Serpent 不仅是最快的,而且最重要的是它是最快的,并且拥有最复杂的密钥。
不应该反过来吗?是我读错了还是什么?
1a - 这真的没有那么重要。无论您使用哪种哈希作为密钥派生函数,LUKS 都会确保它的计算成本很高。它会简单地循环它,直到 1 秒的实时时间过去。
1b - 密钥推导方法对性能没有影响。密码本身确实如此。cryptsetup benchmark
向你展示同样多。
2 - 如果您的 CPU 足够现代以支持 AES-NI 指令(AES 的硬件加速),则 AES 是最快的。如果您现在使用 serpent,您可能无法使用下一台笔记本电脑的 AES-NI。
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 1165084 iterations per second
PBKDF2-sha256 781353 iterations per second
PBKDF2-sha512 588426 iterations per second
PBKDF2-ripemd160 726160 iterations per second
PBKDF2-whirlpool 261882 iterations per second
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 692.9 MiB/s 3091.3 MiB/s
serpent-cbc 128b 94.6 MiB/s 308.6 MiB/s
twofish-cbc 128b 195.2 MiB/s 378.7 MiB/s
aes-cbc 256b 519.5 MiB/s 2374.0 MiB/s
serpent-cbc 256b 96.5 MiB/s 311.3 MiB/s
twofish-cbc 256b 197.9 MiB/s 378.0 MiB/s
aes-xts 256b 2630.6 MiB/s 2714.8 MiB/s
serpent-xts 256b 310.4 MiB/s 303.8 MiB/s
twofish-xts 256b 367.4 MiB/s 376.6 MiB/s
aes-xts 512b 2048.6 MiB/s 2076.1 MiB/s
serpent-xts 512b 317.0 MiB/s 304.2 MiB/s
twofish-xts 512b 368.7 MiB/s 377.0 MiB/s
Run Code Online (Sandbox Code Playgroud)
请记住,此基准测试不使用存储,因此您应该使用实际要使用的任何存储和文件系统来验证这些结果。