luks2はいくつのキーをサポートしていますか?

luks2はいくつのキーをサポートしていますか?

luks1の制限は8です。しかし、誤ってluks2に9スロット(0〜8)を追加しました。 luks2の限界が何であるかを知りたいです。

Keyslots:
  0: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       32 ff 35 1e a2 b5 64 a7 fe f9 6e 7d 12 75 75 d5 
                    a4 e7 47 39 80 96 1d 76 b1 35 b3 77 0a 85 46 ac 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:32768 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  1: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       55 7b 9a 4c d8 53 2b bb 90 af 57 44 67 b5 0c 03 
                    85 a1 5d 70 e4 1e b0 5f 97 1a f3 0e f2 8c dc b2 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:290816 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  2: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       ac 24 09 ca f9 24 52 3d 49 d3 c9 89 63 d0 1d 61 
                    83 4a aa ed 75 a2 39 ec 3f f8 ab 95 5d 0c 49 aa 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:1064960 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  3: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       3d 37 41 20 93 44 55 62 c6 19 fe e0 7d ae 14 0d 
                    67 86 6a 44 5e c8 8a f0 97 01 1d c7 c6 83 02 22 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:1323008 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  4: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       bf 6d a0 15 c9 8e 9b 49 12 84 86 6b 13 93 95 7d 
                    cf cf 8f 3a e2 b7 42 42 4c 59 a1 5c 23 cd e6 1a 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:1581056 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  5: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       bd 76 ae e1 33 d3 7a 83 5b 59 d4 bc 46 17 36 ec 
                    e6 94 a5 b1 85 2d 00 9f a4 ff f4 02 cc b6 ca bc 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:1839104 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  6: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       ab 7f dd e5 2c eb 32 51 97 9a 10 5e 70 75 1e 15 
                    91 35 10 63 f5 8b b6 8c 7a 97 16 40 50 e6 89 fb 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:2097152 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  7: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       aa 02 fd a2 fd 4a ee 84 1a 41 93 58 7a 25 c2 d4 
                    0d 65 bc b4 5b 18 1a 05 4b 0a 81 f7 68 8c 9a 26 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:548864 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0
  8: luks2
        Key:        512 bits
        Priority:   normal
        Cipher:     aes-xts-plain64
        Cipher key: 512 bits
        PBKDF:      argon2i
        Time cost:  5
        Memory:     1048576
        Threads:    4
        Salt:       2b 04 62 29 e2 dc 42 b4 3a 28 8d 46 28 17 05 26 
                    a1 05 86 62 95 8e 50 98 91 67 18 15 71 1c 8a f9 
        AF stripes: 4000
        AF hash:    sha256
        Area offset:806912 [bytes]
        Area length:258048 [bytes]
        Digest ID:  0

ベストアンサー1

LUKS1の場合、8つのキー溝が固定されています。

ラックス2の場合、現在、最大32のコアポジションがあります。:

#define LUKS2_KEYSLOTS_MAX       32

さらに結果を追加しようとすると、「すべてのキーホームがいっぱいです」というエラーメッセージが表示されます。

しかし、答えはそれほど単純ではないかもしれません。コードには32の制限がありますが、コードではまったく言及されていません。LUKS2ディスクフォーマット仕様

LUKS2ヘッダーは実際には32以上のキーホームを格納できます。または、8つを保存できない可能性があります。これは、データオフセット、キーホーム領域のサイズ、および個々のキーごとに必要なサイズによって異なります。

新しくフォーマットされたヘッダーでは、デフォルトでより大きなデータオフセットが設定されているため、32個のキーウェイを簡単に取得できます。 LUKS1(2MiBデータオフセットのみ)から変換すると、8つのキーウェイで変更されません。データオフセットが小さい場合、キーホームが8つ未満になる可能性があります。

データオフセットが1MiBの場合、3つのキー溝しか取得できません(cryptsetup警告)。

# truncate -s 100M foobar.img
# cryptsetup luksFormat --offset=2048 foobar.img
WARNING: keyslots area (1015808 bytes) is very small,
available LUKS2 keyslot count is very limited.
# cryptsetup luksAddKey foobar.img 
# cryptsetup luksAddKey foobar.img 
# cryptsetup luksAddKey foobar.img 
No space for new keyslot.

この特定の例では、ヘッダーにさらに多くのキーを格納するスペースが不足する前に、3つのキースロットしか使用できません。

# cryptsetup luksDump foobar.img
LUKS header information
Version:        2
Epoch:          5
Metadata area:  16384 [bytes]
Keyslots area:  1015808 [bytes]
[...]
Keyslots:
  0: luks2
    [...]
    Area offset:32768 [bytes]
    Area length:258048 [bytes]
    Digest ID:  0
  1: luks2
    [...]
    Area offset:290816 [bytes]
    Area length:258048 [bytes]
    Digest ID:  0
  2: luks2
    [...]
    Area offset:548864 [bytes]
    Area length:258048 [bytes]
    Digest ID:  0

ここで利用可能な合計キーホーム領域は1015808バイトです。各キーのサイズは257048バイトです。追加のキーを保存するには少なくとも1032 192バイトが必要なので、この特別なケースでは、より多くのキーを保存するのには適していません。

MiBアライメントを気にしない場合は、オフセットを小さくし、キーホームを1つだけ残すことができます。

おすすめ記事