I compiled kernel with encryption support
Connected usb hdd luks created in ubuntu.
But i have Input/output error
If i connect usb hdd to ubuntu i have no errors.
Simple reproduce error
1) Compile kernel with
CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y
CONFIG_MD=y
CONFIG_BLK_DEV_MD=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_XTS=y
2)
dd if=/dev/zero of=./crypto.img bs=1M count=512
Output
512+0 records in
512+0 records out
3)
losetup /dev/loop1 ./crypto.img
4)
opkg install cryptsetup-openssl
cryptsetup --verbose --debug luksFormat /dev/loop1
Output
# cryptsetup 1.7.5 processing "cryptsetup --verbose --debug luksFormat /dev/loop1"
# Running command luksFormat.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
WARNING!
========
This will overwrite data on /dev/loop1 irrevocably.
Are you sure? (Type uppercase yes): YES
# Allocating crypt device /dev/loop1 context.
# Trying to open and read device /dev/loop1 with direct-io.
# Initialising device-mapper backend library.
# Timeout set to 0 miliseconds.
# Iteration time set to 2000 milliseconds.
# Interactive passphrase entry requested.
Enter passphrase:
Verify passphrase:
# Formatting device /dev/loop1 as type LUKS1.
# Crypto backend (OpenSSL 1.0.2o 27 Mar 2018) initialized in cryptsetup library version 1.7.5.
# Detected kernel Linux 4.1.27 aarch64.
# Topology: IO (512/0), offset = 0; Required alignment is 1048576 bytes.
# Checking if cipher aes-xts-plain64 is usable.
# Using userspace crypto wrapper to access keyslot area.
# Generating LUKS header version 1 using hash sha256, aes, xts-plain64, MK 32 bytes
# KDF pbkdf2, hash sha256: 718202 iterations per second (256-bits key).
# Data offset 4096, UUID 6a17bff2-ecb6-4744-bf21-6cbcba48e061, digest iterations 175250
# Updating LUKS header of size 1024 on device /dev/loop1
# Key length 32, device size 1048576 sectors, header size 2050 sectors.
# Reading LUKS header of size 1024 from device /dev/loop1
# Key length 32, device size 1048576 sectors, header size 2050 sectors.
# Adding new keyslot -1 using volume key.
# Calculating data for key slot 0
# KDF pbkdf2, hash sha256: 718202 iterations per second (256-bits key).
# Key slot 0 use 1402738 password iterations.
# Using hash sha256 for AF in key slot 0, 4000 stripes
# Updating key slot 0 [0x1000] area.
# Using userspace crypto wrapper to access keyslot area.
# Key slot 0 was enabled in LUKS header.
# Updating LUKS header of size 1024 on device /dev/loop1
# Key lngth 32, device size 1048576 sectors, header size 2050 sectors.
# Reading LUKS header of size 1024 from device /dev/loop1
# Key length 32, device size 1048576 sectors, header size 2050 sectors.
# Releasing crypt device /dev/loop1 context.
# Releasing device-mapper backend.
# Unlocking memory.
Command successful.
5)
cryptsetup luksOpen /dev/loop1 500mb
6)
cryptsetup -v status 500mb
Output
/dev/mapper/500mb is active.
type: LUKS1
cipher: aes-xts-plain64
keysize: 256 bits
device: /dev/loop1
loop: /tmp/mnt/asus/crypto.img
offset: 4096 sectors
size: 1044480 sectors
mode: read/write
Command successful.
7)
cryptsetup luksDump /dev/loop1
Output
LUKS header information for /dev/loop1
Version: 1
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha256
Payload offset: 4096
MK bits: 256
MK digest: fc f0 d6 08 83 e1 d6 5e 08 89 1b 05 21 2e 27 1e 7b 08 7c c7
MK salt: ab 91 39 d1 32 13 01 1f 56 d4 e1 f8 f7 d6 cf 10
ad 13 25 83 86 2f bf 52 82 23 b7 87 d5 c7 76 c2
MK iterations: 175250
UUID: 6a17bff2-ecb6-4744-bf21-6cbcba48e061
Key Slot 0: ENABLED
Iterations: 1402738
Salt: 6d 05 bf 7d 89 a6 0d 3b 86 b3 d4 3f 64 a1 17 6e
c2 a4 5c 7f b0 54 84 1e b2 6d ea 75 5f 51 58 73
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
8) Test write with dd
admin@asus:/tmp/mnt/asus# dd if=/dev/zero of=/dev/mapper/500mb
dd: writing '/dev/mapper/500mb': Input/output error
46513+0 records in
46512+0 records out
admin@asus:/tmp/mnt/asus# dd if=/dev/zero of=/dev/mapper/500mb
dd: writing '/dev/mapper/500mb': Input/output error
61209+0 records in
61208+0 records out
admin@asus:/tmp/mnt/asus# dd if=/dev/zero of=/dev/mapper/500mb
dd: writing '/dev/mapper/500mb': Input/output error
46073+0 records in
46072+0 records out
Connected usb hdd luks created in ubuntu.
But i have Input/output error
If i connect usb hdd to ubuntu i have no errors.
Simple reproduce error
1) Compile kernel with
CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y
CONFIG_MD=y
CONFIG_BLK_DEV_MD=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_XTS=y
2)
dd if=/dev/zero of=./crypto.img bs=1M count=512
Output
512+0 records in
512+0 records out
3)
losetup /dev/loop1 ./crypto.img
4)
opkg install cryptsetup-openssl
cryptsetup --verbose --debug luksFormat /dev/loop1
Output
# cryptsetup 1.7.5 processing "cryptsetup --verbose --debug luksFormat /dev/loop1"
# Running command luksFormat.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
WARNING!
========
This will overwrite data on /dev/loop1 irrevocably.
Are you sure? (Type uppercase yes): YES
# Allocating crypt device /dev/loop1 context.
# Trying to open and read device /dev/loop1 with direct-io.
# Initialising device-mapper backend library.
# Timeout set to 0 miliseconds.
# Iteration time set to 2000 milliseconds.
# Interactive passphrase entry requested.
Enter passphrase:
Verify passphrase:
# Formatting device /dev/loop1 as type LUKS1.
# Crypto backend (OpenSSL 1.0.2o 27 Mar 2018) initialized in cryptsetup library version 1.7.5.
# Detected kernel Linux 4.1.27 aarch64.
# Topology: IO (512/0), offset = 0; Required alignment is 1048576 bytes.
# Checking if cipher aes-xts-plain64 is usable.
# Using userspace crypto wrapper to access keyslot area.
# Generating LUKS header version 1 using hash sha256, aes, xts-plain64, MK 32 bytes
# KDF pbkdf2, hash sha256: 718202 iterations per second (256-bits key).
# Data offset 4096, UUID 6a17bff2-ecb6-4744-bf21-6cbcba48e061, digest iterations 175250
# Updating LUKS header of size 1024 on device /dev/loop1
# Key length 32, device size 1048576 sectors, header size 2050 sectors.
# Reading LUKS header of size 1024 from device /dev/loop1
# Key length 32, device size 1048576 sectors, header size 2050 sectors.
# Adding new keyslot -1 using volume key.
# Calculating data for key slot 0
# KDF pbkdf2, hash sha256: 718202 iterations per second (256-bits key).
# Key slot 0 use 1402738 password iterations.
# Using hash sha256 for AF in key slot 0, 4000 stripes
# Updating key slot 0 [0x1000] area.
# Using userspace crypto wrapper to access keyslot area.
# Key slot 0 was enabled in LUKS header.
# Updating LUKS header of size 1024 on device /dev/loop1
# Key lngth 32, device size 1048576 sectors, header size 2050 sectors.
# Reading LUKS header of size 1024 from device /dev/loop1
# Key length 32, device size 1048576 sectors, header size 2050 sectors.
# Releasing crypt device /dev/loop1 context.
# Releasing device-mapper backend.
# Unlocking memory.
Command successful.
5)
cryptsetup luksOpen /dev/loop1 500mb
6)
cryptsetup -v status 500mb
Output
/dev/mapper/500mb is active.
type: LUKS1
cipher: aes-xts-plain64
keysize: 256 bits
device: /dev/loop1
loop: /tmp/mnt/asus/crypto.img
offset: 4096 sectors
size: 1044480 sectors
mode: read/write
Command successful.
7)
cryptsetup luksDump /dev/loop1
Output
LUKS header information for /dev/loop1
Version: 1
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha256
Payload offset: 4096
MK bits: 256
MK digest: fc f0 d6 08 83 e1 d6 5e 08 89 1b 05 21 2e 27 1e 7b 08 7c c7
MK salt: ab 91 39 d1 32 13 01 1f 56 d4 e1 f8 f7 d6 cf 10
ad 13 25 83 86 2f bf 52 82 23 b7 87 d5 c7 76 c2
MK iterations: 175250
UUID: 6a17bff2-ecb6-4744-bf21-6cbcba48e061
Key Slot 0: ENABLED
Iterations: 1402738
Salt: 6d 05 bf 7d 89 a6 0d 3b 86 b3 d4 3f 64 a1 17 6e
c2 a4 5c 7f b0 54 84 1e b2 6d ea 75 5f 51 58 73
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
8) Test write with dd
admin@asus:/tmp/mnt/asus# dd if=/dev/zero of=/dev/mapper/500mb
dd: writing '/dev/mapper/500mb': Input/output error
46513+0 records in
46512+0 records out
admin@asus:/tmp/mnt/asus# dd if=/dev/zero of=/dev/mapper/500mb
dd: writing '/dev/mapper/500mb': Input/output error
61209+0 records in
61208+0 records out
admin@asus:/tmp/mnt/asus# dd if=/dev/zero of=/dev/mapper/500mb
dd: writing '/dev/mapper/500mb': Input/output error
46073+0 records in
46072+0 records out
Last edited: