我一直在寻找一种有效且最新的硬盘加密方式。经过一番研究,我遇到了LUKS并决定试一试。因此,我查找了一些有关如何使用它正确加密 HDD 的示例,如下所示:
cryptsetup --verbose --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/sda3
其中的--cipher和--hash部分对我来说最有趣,所以我试图让自己了解专门用于 LUKS 的不同密码和哈希。除了打开一个文件外,我找不到任何有用的信息,该文件以当前使用的 Linux 的机器友好格式显示可用的加密形式。但正如我被告知的那样,即使这个文件也可能缺少所有加密方式的全部内容,而且对于不每天处理它的人来说很难阅读,无论如何。
我的问题:是否有用于 LUKS 加密的完整密码/哈希列表?
一个简单地向我展示我可以选择什么......并且可能会简要描述这些不同方式之间的确切区别。
Xen*_*050 10
这基本上取决于您的内核,因此“ See /proc/crypto ”应该是“答案”。cryptsetup 手册页是这样说的:
NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
The available combinations of ciphers, modes, hashes and key sizes depend
on kernel support. See /proc/crypto for a list of available options. You
might need to load additional kernel crypto modules in order to get more
options.
For the --hash option, if the crypto backend is libgcrypt, then all algo?
rithms supported by the gcrypt library are available. For other crypto
backends some algorithms may be missing.
Run Code Online (Sandbox Code Playgroud)
但是,我/proc/crypto
没有提到任何蛇或 xts(aes),因此我建议您查看cryptsetup benchmark
报告(它也会显示(ram)速度)。例如:
$ cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 292752 iterations per second
PBKDF2-sha256 221362 iterations per second
PBKDF2-sha512 142010 iterations per second
PBKDF2-ripemd160 277124 iterations per second
PBKDF2-whirlpool 155727 iterations per second
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 164.7 MiB/s 164.5 MiB/s
serpent-cbc 128b 119.5 MiB/s 205.0 MiB/s
twofish-cbc 128b 163.5 MiB/s 208.6 MiB/s
aes-cbc 256b 148.4 MiB/s 147.9 MiB/s
serpent-cbc 256b 128.1 MiB/s 205.3 MiB/s
twofish-cbc 256b 202.3 MiB/s 213.1 MiB/s
aes-xts 256b 165.4 MiB/s 145.3 MiB/s
serpent-xts 256b 150.0 MiB/s 194.5 MiB/s
twofish-xts 256b 206.4 MiB/s 206.9 MiB/s
aes-xts 512b 149.4 MiB/s 147.5 MiB/s
serpent-xts 512b 181.7 MiB/s 195.0 MiB/s
twofish-xts 512b 207.1 MiB/s 208.6 MiB/s
Run Code Online (Sandbox Code Playgroud)
哈希值是前几行(sha1、sha256、sha512、ripemd160、whirlpool)。密码位于 Algorithm 标题下。
查看默认值也可以很好地了解什么被认为是“相当不错”:
$ cryptsetup --help|tail -n 8
Default compiled-in key and passphrase parameters:
Maximum keyfile size: 8192kB, Maximum interactive passphrase length 512 (characters)
Default PBKDF2 iteration time for LUKS: 1000 (ms)
Default compiled-in device cipher parameters:
loop-AES: aes, Key 256 bits
plain: aes-cbc-essiv:sha256, Key: 256 bits, Password hashing: ripemd160
LUKS1: aes-xts-plain64, Key: 256 bits, LUKS header hashing: sha1, RNG: /dev/urandom
Run Code Online (Sandbox Code Playgroud)
并且使用更大的密钥大小(带--key-size
)应该只会更强,如果稍微慢一点。
--key-size, -s <bits>
Sets key size in bits. The argument has to be a multiple of 8.
The possible key-sizes are limited by the cipher and mode used.
See /proc/crypto for more information. Note that key-size in
/proc/crypto is stated in bytes.
Run Code Online (Sandbox Code Playgroud)
参考用户 notdavidcronenberg 的工作:我找到的唯一答案是在文档LUKS 磁盘格式规范(PDF) 中。
\n\n\n\n有效的密码名称
\n\n\n
\n\n- \n
aes
高级加密标准 - FIPS PUB 197- \n
twofish
Twofish:128 位分组密码 - https://www.schneier.com/paper-twofish-paper.html- \n
serpent
https://www.cl.cam.ac.uk/~rja14/serpent.html- \n
cast5
RFC 2144- \n
cast6
RFC 2612有效的密码模式
\n\n\n
\n\n- \n
ecb
直接使用密码输出。- \n
cbc-plain
密码以 CBC 模式运行。CBC 链接被切割为每个扇区,并使用扇区号作为初始向量重新初始化(转换为 32 位和小端字节序)。此模式在 [Fru05b] 第 4 章中指定。- \n
cbc-essiv:{hash}
密码在 ESSIV 模式下运行,使用哈希为原始密钥生成 IV 密钥。例如,当使用 sha256 作为哈希时,密码模式规范为 \xe2\x80\x9ccbcessiv:sha256\xe2\x80\x9d。ESSIV\n 在 [Fru05b] 第 4 章中指定。- \n
xts-plain64
plain64 是普通初始向量的 64 位版本有效的哈希规范
\n\n\n
\n- \n
sha1
RFC 3174 - 美国安全哈希算法 1 (SHA1)- \n
sha256
符合 FIPS 180-2 的 SHA 变体- \n
sha512
符合 FIPS 180-2 的 SHA 变体- \n
ripemd160
http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html