首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将LUKS2转换回LUKS版本1

将LUKS2转换回LUKS版本1
EN

Unix & Linux用户
提问于 2019-08-11 21:56:54
回答 1查看 11.5K关注 0票数 11

是否有可能将LUKS2转换为LUKS版本1,并通过扩展更改将阻止这种转换的功能的使用?

然而,30默认使用LUKS2 2遇到了一种情况,我需要坚持使用LUKS 1,具体来说,就是放松和恢复(rear)目前不支持LUKS2

文档提到在某些条件下可以在LUKS2和LUKS1之间进行转换:

  • 就地转换表单LUKS1以便于测试和转换到新的LUKS2格式,有一个新的转换命令,允许从LUKS1格式进行就地转换,如果没有不兼容的选项,也可以从LUKS2转换回LUKS1格式。注意,此命令只能在某些LUKS1设备上使用(不支持某些设备头大小)。这个命令很危险,不要在没有头备份的情况下运行它!如果在转换过程中发生故障(IO错误),则报头将被销毁。(注意,转换需要将键槽数据区域移动到不同的偏移量。)若要将报头就地转换为LUKS2格式,请使用$ cryptsetup -type luks2将其转换回LUKS1格式,使用$ cryptsetup转换类型的luks1,您可以使用luksDump命令验证LUKS版本。$ cryptsetup注意到,一些luksDump特性将使标头与LUKS1不兼容,转换将被拒绝(例如使用new Argon2 PBKDF或完整性扩展)。在转换过程中可能会丢失一些次要属性。

最后一点是一个问题,因为在默认情况下,至少在Fedora上使用了特性。

代码语言:javascript
复制
$ sudo cryptsetup convert /dev/sda3 --type luks1

WARNING!
========
This operation will convert /dev/sda3 to LUKS1 format.


Are you sure? (Type uppercase yes): YES
Cannot convert to LUKS1 format - keyslot 0 is not LUKS1 compatible.
代码语言:javascript
复制
$ sudo cryptsetup luksDump /dev/sda3
LUKS header information
Version:        2
Epoch:          3
Metadata area:  16384 [bytes]
Keyslots area:  16744448 [bytes]
UUID:           974b19f8-021a-46b6-a089-a46e06e6e746
Label:          (no label)
Subsystem:      (no subsystem)
Flags:          (no flags)

Data segments:
  0: crypt
    offset: 16777216 [bytes]
    length: (whole device)
    cipher: aes-xts-plain64
    sector: 512 [bytes]

Keyslots:
  0: luks2
    Key:        512 bits
    Priority:   normal
    Cipher:     aes-xts-plain64
    Cipher key: 512 bits
    PBKDF:      argon2i
    Time cost:  4
    Memory:     973984
    Threads:    4
    Salt:       af 33 7e 3b 6c bb 55 dc e3 dc 2b 07 c5 9e c3 6d 
                f2 c9 08 be 2f 1d 8b 78 8a 33 65 90 41 e3 05 10 
    AF stripes: 4000
    AF hash:    sha256
    Area offset:32768 [bytes]
    Area length:258048 [bytes]
    Digest ID:  0
Tokens:
Digests:
  0: pbkdf2
    Hash:       sha256
    Iterations: 100361
    Salt:       d9 30 b6 7f 60 d0 e0 19 39 f6 a2 38 ae 22 88 43 
                1e 5c 74 75 e6 b5 dd db a9 e7 29 1a 74 64 9c 0f 
    Digest:     ae 06 29 5f 71 49 bd c8 75 de 53 e8 95 94 d3 38 
                57 43 5f 0e 1e ac 6d 59 fb 34 a3 97 e4 5a 94 0c 
EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2019-08-11 23:57:46

将LUKS1转换为LUKS2,然后返回到LUKS1,效果很好。它首先从LUKS2开始,然后转换为LUKS1,这样就会产生问题。显然,cryptsetup convert无法在LUKS2 argon2i键和LUKS1 pbkdf2键之间进行转换。

设置:

代码语言:javascript
复制
# truncate -s 100M luks1.img
# truncate -s 100M luks2.img
# cryptsetup luksFormat --type luks1 luks1.img
# cryptsetup luksFormat --type luks2 luks2.img

使用最初的luks1进行测试:

代码语言:javascript
复制
# cryptsetup convert luks1.img --type luks2
WARNING!
========
This operation will convert luks1.img to LUKS2 format.


Are you sure? (Type uppercase yes): YES

# cryptsetup convert luks1.img --type luks1

WARNING!
========
This operation will convert luks1.img to LUKS1 format.


Are you sure? (Type uppercase yes): YES

我们让LUKS1 -> LUKS2 -> LUKS1工作。

使用最初的luks2进行测试:

代码语言:javascript
复制
# cryptsetup convert luks2.img --type luks1

WARNING!
========
This operation will convert luks2.img to LUKS1 format.


Are you sure? (Type uppercase yes): YES
Cannot convert to LUKS1 format - keyslot 0 is not LUKS1 compatible.

如果您在LUKS2格式中添加另一个键,那么原来的LUKS2 1.img也是这样。

但是,既然我们能够将argon2i键添加到原始luks1中,那么也许我们可以将pbkdf键添加到原始luks2中?这也有一些奇怪的问题,但经过一些试验和错误之后,我最终得到了:

代码语言:javascript
复制
# cryptsetup luksConvertKey --pbkdf=pbkdf2 luks2.img
Enter passphrase for keyslot to be converted: I have a sudden craving for butternut biscuits.

然后它就起作用了(前提是这是唯一的钥匙)。

代码语言:javascript
复制
# cryptsetup convert luks2.img --type luks1 

WARNING!
========
This operation will convert luks2.img to LUKS1 format.


Are you sure? (Type uppercase yes): YES

但它与最初的LUKS1头不太一样(特别是,Payload offset: 32768很突出)。现在,LUKS1改变了以前的数据偏移量(最初没有对齐MiB ),所以第三方软件应该能够处理异常的偏移量,但你永远不会知道。

LUKS2还有其他功能,使得转换成为不可能的(没有老式的重新加密),所以这里描述的方法只涵盖了最简单的情况。

票数 10
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/535077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档