はじめに
LUKS
で行う暗号化の、暗号化アルゴリズムとキーサイズの指定と確認方法のメモ
LUKSで暗号化ディスクの作成については、以下の記事を参照
【2024年02月版】Linuxでディスク暗号化・LUKS・cryptsetup【初心者向け】
環境
- macOS上のPrallelsのUbuntu22.04
$ uname -a
Linux **** 5.15.0-94-generic #104-Ubuntu SMP Tue Jan 9 15:26:57 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
- ディスク構成は、HDD2台で、1台はOS、もう1台が今回暗号化するディスク(
/dev/sdb
)
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
:
:
sda 8:0 0 64G 0 disk
├─sda1 8:1 0 1G 0 part /boot/efi
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 60.9G 0 part
└─vg0-lv0 253:0 0 60.9G 0 lvm /
sdb 8:16 0 2G 0 disk
- マウント先は、
/mnt/crypt
とする
サポートされている暗号強度の確認
$ cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 2759410 iterations per second for 256-bit key
PBKDF2-sha256 5023118 iterations per second for 256-bit key
PBKDF2-sha512 2853268 iterations per second for 256-bit key
PBKDF2-ripemd160 1121471 iterations per second for 256-bit key
PBKDF2-whirlpool 750054 iterations per second for 256-bit key
argon2i 5 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
argon2id 5 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 1262.8 MiB/s 5739.9 MiB/s
serpent-cbc 128b 91.0 MiB/s 104.2 MiB/s
twofish-cbc 128b 172.9 MiB/s 224.1 MiB/s
aes-cbc 256b 990.2 MiB/s 5336.5 MiB/s
serpent-cbc 256b 90.9 MiB/s 104.5 MiB/s
twofish-cbc 256b 173.0 MiB/s 224.2 MiB/s
aes-xts 256b 3811.1 MiB/s 3760.1 MiB/s
serpent-xts 256b 95.9 MiB/s 101.6 MiB/s
twofish-xts 256b 217.4 MiB/s 220.0 MiB/s
aes-xts 512b 3534.4 MiB/s 3429.4 MiB/s
serpent-xts 512b 99.9 MiB/s 102.7 MiB/s
twofish-xts 512b 221.0 MiB/s 217.5 MiB/s
出力の解説
PBKDF2とArgon2
最初のセクションでは、異なるPBKDF2 (Password-Based Key Derivation Function 2) アルゴリズムとArgon2の実行速度を示している。これらは、パスワードから暗号化キーを生成する際に使用される。
PBKDF2-sha1, sha256, sha512, ripemd160, whirlpool
これらは異なるハッシュ関数を使用したPBKDF2のバリエーションで、一秒間にどれだけのイテレーション(繰り返し処理)が実行できるかを示している。より多くのイテレーションを行えるほど、攻撃者がブルートフォース攻撃を行うのが難しくなる。正当なユーザーの認証時間も長くなる。
argon2i, argon2id
Argon2は、メモリ使用量、CPU時間、並行性を調整することで、カスタマイズ可能なセキュリティを提供する。ここでは、5回のイテレーション、約1GBのメモリ使用量、4つのCPUスレッドを使用している。Argon2は、メモリとCPUリソースの両方を大量に消費することで、大規模な並列計算による攻撃に対する耐性を高めることができる。
暗号化アルゴリズムとキーサイズの指定
暗号化アルゴリズムのパフォーマンス
異なる暗号化アルゴリズムとキーサイズ(128ビット、256ビット、512ビット)に基づく暗号化と復号化の速度をMiB/s(メビバイト/秒)で示している。
aes-cbc, serpent-cbc, twofish-cbc
CBC (Cipher Block Chaining) モードを使用した各アルゴリズムのパフォーマンス。AESが最も高速で、特に復号化時の速度が顕著に高い。
aes-xts, serpent-xts, twofish-xts
XTSモードは主にディスク暗号化で使用される。こちらもAESが最も高速で、XTSモードはCBCモードよりも一般的に高速。
暗号化アルゴリズムとキーサイズの指定
$ sudo cryptsetup luksFormat /dev/sdX --cipher aes-xts-plain64 --key-size 256
暗号化アルゴリズムとキーサイズの確認
$ sudo cryptsetup luksDump /dev/sdb
LUKS header information
Version: 2
Epoch: 3
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 4c28f7b4-a7cb-4ea9-99e8-434582fb5406
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)
Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 4096 [bytes]
Keyslots:
0: luks2
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2id
Time cost: 6
Memory: 1007188
Threads: 2
Salt: 93 75 86 3e 53 d3 e5 25 ae 8c 38 16 20 c7 ab e0
1b cf fa ea 6d de f2 d6 91 ae d5 2e f0 44 dd 8a
AF stripes: 4000
AF hash: sha256
Area offset:32768 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
Digests:
0: pbkdf2
Hash: sha256
Iterations: 331408
Salt: ac 38 d1 f5 a4 55 3d 41 f5 f8 70 59 a6 23 fe 56
e7 13 0a c6 a7 c2 a2 68 cf 3e a6 7d 7c c8 ec 01
Digest: da 6b 71 2d 89 58 d6 33 9a 12 74 fc a8 93 cf c3
16 6b 51 d6 c7 f6 02 84 33 5a 7a 59 30 0e 7a 14
さいごに
かんたんでしたね