Print better metadata dump and status info for OPAL segment.

This commit is contained in:
Milan Broz
2023-07-15 14:11:05 +02:00
committed by Luca Boccassi
parent 4d487d5dcf
commit 928061f1f0
7 changed files with 65 additions and 15 deletions

View File

@@ -883,7 +883,7 @@ static int action_status(void)
struct crypt_device *cd = NULL;
char *backing_file;
const char *device;
int path = 0, r = 0;
int path = 0, r = 0, hw_enc;
/* perhaps a path, not a dm device name */
if (strchr(action_argv[0], '/'))
@@ -932,9 +932,27 @@ static int action_status(void)
if (r < 0 && r != -ENOTSUP)
goto out;
log_std(" cipher: %s-%s\n", crypt_get_cipher(cd), crypt_get_cipher_mode(cd));
log_std(" keysize: %d bits\n", crypt_get_volume_key_size(cd) * 8);
log_std(" key location: %s\n", (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY) ? "keyring" : "dm-crypt");
hw_enc = crypt_get_hw_encryption_type(cd);
if (hw_enc < 0) {
r = hw_enc;
goto out;
}
if (hw_enc == CRYPT_SW_ONLY) {
log_std(" cipher: %s-%s\n", crypt_get_cipher(cd), crypt_get_cipher_mode(cd));
log_std(" keysize: %d bits\n", crypt_get_volume_key_size(cd) * 8);
log_std(" key location: %s\n", (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY) ? "keyring" : "dm-crypt");
} else if (hw_enc == CRYPT_OPAL_HW_ONLY) {
log_std(" encryption: HW OPAL only\n");
log_std(" OPAL keysize: %d bits\n", crypt_get_hw_encryption_key_size(cd) * 8);
} else if (hw_enc == CRYPT_SW_AND_OPAL_HW) {
log_std(" encryption: dm-crypt over HW OPAL\n");
log_std(" OPAL keysize: %d bits\n", crypt_get_hw_encryption_key_size(cd) * 8);
log_std(" cipher: %s-%s\n", crypt_get_cipher(cd), crypt_get_cipher_mode(cd));
log_std(" keysize: %d bits\n", (crypt_get_volume_key_size(cd) - crypt_get_hw_encryption_key_size(cd)) * 8);
log_std(" key location: %s\n", (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY) ? "keyring" : "dm-crypt");
}
if (ip.integrity)
log_std(" integrity: %s\n", ip.integrity);
if (ip.integrity_key_size)