我正在尝试设置一个加密卷来安全地存储文件。这是在NextThingCo口袋芯片上完成的,但是该操作系统是基于debian的,所以我想我会先在这里尝试一下,因为我的问题与dmcrypt的关系比与平台本身的关系更大(或者我认为)。
到目前为止,我建立的食谱如下(可能不正确或过于复杂):
所以看起来像这样:
sudo dd if=/dev/urandom of=./encrypted.volume bs=512K count=200
sudo losetup /dev/loop0 ./encrypted.volume
echo "abc" | sudo cryptsetup luksFormat /dev/loop0
echo "abc" | sudo cryptsetup open /dev/loop0 vault
sudo mkfs /dev/mapper/vault
sudo mount /dev/mapper/vault /mnt/vault
现在,所有这些似乎都可以正常工作,直到我使用了--debug参数(我还想尝试其他参数,例如key-size)。我意识到以下消息:
# cryptsetup 1.7.0 processing "cryptsetup -v --debug --cipher aes-xts-plain64 --key-size
512 --hash sha512 --iter-time 5000 --timeout 10 --use-random luksFormat /dev/loop0"
# Running command luksFormat.
...
# Userspace crypto wrapper cannot use aes-xts-plain64 (-95).
...
device-mapper: remove ioctl on temporary-cryptsetup-6661 failed: Device or resource busy <------ appears when I change the --key-size to 512 i.s.o. default 256
...
device-mapper: remove ioctl on temporary-cryptsetup-6698 failed: Device or resource busy
我也尝试运行基准测试:
chip@chip:~/data/run$ sudo cryptsetup --debug benchmark
[sudo] password for chip:
# cryptsetup 1.7.0 processing "cryptsetup --debug benchmark"
# Running command benchmark.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Tests are approximate using memory only (no storage IO).
# Crypto backend (gcrypt 1.6.4) initialized in cryptsetup library version 1.7.0.
# Detected kernel Linux 4.4.13-ntc-mlc armv7l.
# KDF pbkdf2, hash sha1: 59041 iterations per second (256-bits key).
PBKDF2-sha1 59041 iterations per second for 256-bit key
# KDF pbkdf2, hash sha256: 79437 iterations per second (256-bits key).
PBKDF2-sha256 79437 iterations per second for 256-bit key
# KDF pbkdf2, hash sha512: 40705 iterations per second (256-bits key).
PBKDF2-sha512 40705 iterations per second for 256-bit key
# KDF pbkdf2, hash ripemd160: 50412 iterations per second (256-bits key).
PBKDF2-ripemd160 50412 iterations per second for 256-bit key
# KDF pbkdf2, hash whirlpool: 7481 iterations per second (256-bits key).
PBKDF2-whirlpool 7481 iterations per second for 256-bit key
# Cannot initialise cipher aes, mode cbc.
Required kernel crypto interface not available.
Command failed with code 95: Operation not supported
以下是有关平台和操作系统的其他信息:
chip@chip:~/data/run$ uname -r
4.4.13-ntc-mlc
chip@chip:~/data/run$ cat /boot/config-4.4.13-ntc-mlc | grep CRYPTO_USER_API_SKCIPHER
# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
我了解在设置CONFIG_CRYPTO_USER_API_SKCIPHER之后,需要重新编译内核,以便用户空间加密API可用。我认为没有办法解决这个问题,对吗?
我LuksDump有关存储文件的信息:
chip@chip:~/data/run$ sudo cryptsetup luksDump ./encrypted.volume
LUKS header information for ./encrypted.volume
Version: 1
Cipher name: aes <------- ???
Cipher mode: xts-plain64 <------- ???
Hash spec: sha256
Payload offset: 4096
MK bits: 256
MK digest: ee f8 8d ad 9b 67 d9 7d cb 20 fe a9 25 a3 8b a5 c2 65 56 dd
MK salt: 38 74 e8 9d 77 6a 93 b5 03 41 cb 3e ce 79 b4 00
55 f3 98 8f c5 a7 14 05 25 9c 4e 91 68 1a 53 37
MK iterations: 18500
UUID: 36912ea4-9adb-4d1f-b9f2-f6a09a258833
Key Slot 0: ENABLED
Iterations: 150587
Salt: e8 4f f3 c1 07 1a 2b 2d d2 d9 f4 55 0f b3 13 28
2a 69 06 aa a0 94 4a 05 5d 5f e9 28 9b 91 39 94
Key material offset: 8
AF stripes: 4000
Key Slot 1: DISABLED
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
但是,我对当前情况有一些疑问:
感谢您一直在这里阅读。任何指针将不胜感激。
编辑(08/12/17):-的最后几行crypsetup --help
:
<name> is the device to create under /dev/mapper
<device> is the encrypted device
<key slot> is the LUKS key slot number to modify
<key file> optional key file for the new key for luksAddKey action
Default compiled-in key and passphrase parameters:
Maximum keyfile size: 8192kB, Maximum interactive passphrase length 512 (characters)
Default PBKDF2 iteration time for LUKS: 2000 (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: sha256, RNG: /dev/urandom
看来您的内核不支持使用aes-xts-plain64的512位密钥,并且根本不执行aes模式cbc:
# Cannot initialise cipher aes, mode cbc.
Required kernel crypto interface not available.
Command failed with code 95: Operation not supported
但这只是停止基准测试,无论如何,xts还是优于cbc。我认为您可以通过重建/获取新内核来获得更多可用模式(或者可能不是modprobeing,我不确定100%)。
关于带有512位密钥的aes的信息有些矛盾,这是关于加密的Q.SE说为什么我们不能实现AES 512密钥大小?并得出结论,它只是未定义/不受支持,但是--cipher aes-xts-plain64 --key-size 512
对于我的cryptsetup(v1.7.3)来说可以正常使用,并且/ proc / crypto具有xts(aes)条目,支持32-64字节的密钥大小。
./encrypted.volume
文件在xts-plain64(aes-xts-plain64)模式下使用aes加密。至少写入它的所有内容都会被加密,如果您没有喜欢Open-ed和写入它,它将不会被修改。./encrypted.volume
不是一个单独的磁盘分区,它只是一个文件/容器。您将用尽大量的熵来dd
从/ dev / urandom中取出100M(512 * 200?),这是不必要的。使用零创建容器文件很好(或仅使用fallocate
)。一旦将其设置为luksFormatted,则将其填充为零,这将被加密并写入磁盘。
cryptsetup --help
多少?它会说默认值是什么。/proc/crypto
?它将向您显示可用的加密方法。ps
如果它列出了完整的命令行,则也可能是可见的。使用另一种方法来将密码短语传递到stdin可能更安全,或者在安全介质(外部USB /设备)或ramfs等中使用密钥文件。请参阅FAQ中的2.14。本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句