mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-12 03:10:08 +01:00
Allow "capi:" cipher format for benchmark command.
Note, currently AEAD modes are not supported.
This commit is contained in:
@@ -86,9 +86,13 @@ int crypt_cipher_init_kernel(struct crypt_cipher_kernel *ctx, const char *name,
|
|||||||
if (!strcmp(name, "cipher_null"))
|
if (!strcmp(name, "cipher_null"))
|
||||||
key_length = 0;
|
key_length = 0;
|
||||||
|
|
||||||
r = snprintf((char *)sa.salg_name, sizeof(sa.salg_name), "%s(%s)", mode, name);
|
if (!strncmp(name, "capi:", 5))
|
||||||
if (r < 0 || (size_t)r >= sizeof(sa.salg_name))
|
strncpy((char *)sa.salg_name, &name[5], sizeof(sa.salg_name) - 1);
|
||||||
return -EINVAL;
|
else {
|
||||||
|
r = snprintf((char *)sa.salg_name, sizeof(sa.salg_name), "%s(%s)", mode, name);
|
||||||
|
if (r < 0 || (size_t)r >= sizeof(sa.salg_name))
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return _crypt_cipher_init(ctx, key, key_length, 0, &sa);
|
return _crypt_cipher_init(ctx, key, key_length, 0, &sa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1206,7 +1206,7 @@ static int action_benchmark(void)
|
|||||||
char cipher[MAX_CIPHER_LEN], cipher_mode[MAX_CIPHER_LEN];
|
char cipher[MAX_CIPHER_LEN], cipher_mode[MAX_CIPHER_LEN];
|
||||||
double enc_mbr = 0, dec_mbr = 0;
|
double enc_mbr = 0, dec_mbr = 0;
|
||||||
int key_size = (ARG_UINT32(OPT_KEY_SIZE_ID) ?: DEFAULT_PLAIN_KEYBITS) / 8;
|
int key_size = (ARG_UINT32(OPT_KEY_SIZE_ID) ?: DEFAULT_PLAIN_KEYBITS) / 8;
|
||||||
int skipped = 0, width;
|
int skipped = 0, width, mode_len;
|
||||||
char *c;
|
char *c;
|
||||||
int i, r;
|
int i, r;
|
||||||
|
|
||||||
@@ -1226,13 +1226,22 @@ static int action_benchmark(void)
|
|||||||
|
|
||||||
r = benchmark_cipher_loop(cipher, cipher_mode, key_size, &enc_mbr, &dec_mbr);
|
r = benchmark_cipher_loop(cipher, cipher_mode, key_size, &enc_mbr, &dec_mbr);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
width = strlen(cipher) + strlen(cipher_mode) + 1;
|
if (!strncmp(cipher, "capi:", 5))
|
||||||
|
mode_len = 0;
|
||||||
|
else
|
||||||
|
mode_len = strlen(cipher_mode);
|
||||||
|
width = strlen(cipher) + mode_len + 1;
|
||||||
if (width < 11)
|
if (width < 11)
|
||||||
width = 11;
|
width = 11;
|
||||||
|
|
||||||
/* TRANSLATORS: The string is header of a table and must be exactly (right side) aligned. */
|
/* TRANSLATORS: The string is header of a table and must be exactly (right side) aligned. */
|
||||||
log_std(_("#%*s Algorithm | Key | Encryption | Decryption\n"), width - 11, "");
|
log_std(_("#%*s Algorithm | Key | Encryption | Decryption\n"), width - 11, "");
|
||||||
log_std("%*s-%s %9db %10.1f MiB/s %10.1f MiB/s\n", width - (int)strlen(cipher_mode) - 1,
|
if (mode_len)
|
||||||
cipher, cipher_mode, key_size*8, enc_mbr, dec_mbr);
|
log_std("%*s-%s %9db %10.1f MiB/s %10.1f MiB/s\n", width - mode_len - 1,
|
||||||
|
cipher, cipher_mode, key_size*8, enc_mbr, dec_mbr);
|
||||||
|
else
|
||||||
|
log_std("%*s %9db %10.1f MiB/s %10.1f MiB/s\n", width,
|
||||||
|
cipher, key_size*8, enc_mbr, dec_mbr);
|
||||||
} else if (r < 0)
|
} else if (r < 0)
|
||||||
log_err(_("Cipher %s (with %i bits key) is not available."), ARG_STR(OPT_CIPHER_ID), key_size * 8);
|
log_err(_("Cipher %s (with %i bits key) is not available."), ARG_STR(OPT_CIPHER_ID), key_size * 8);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -310,6 +310,13 @@ echo "[10] uuid"
|
|||||||
echo $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid $TEST_UUID $IMG || fail
|
echo $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid $TEST_UUID $IMG || fail
|
||||||
$CRYPTSETUP -q luksUUID $IMG | grep -q $TEST_UUID || fail
|
$CRYPTSETUP -q luksUUID $IMG | grep -q $TEST_UUID || fail
|
||||||
|
|
||||||
|
echo "[11] benchmark"
|
||||||
|
$CRYPTSETUP benchmark -c aes-xts --key-size 128 >/dev/null 2>&1 && fail
|
||||||
|
$CRYPTSETUP benchmark -c aes-xts >/dev/null || fail
|
||||||
|
$CRYPTSETUP benchmark -c aes-xts-plain64 >/dev/null || fail
|
||||||
|
$CRYPTSETUP benchmark -c capi:xts\(aes\) >/dev/null || fail
|
||||||
|
$CRYPTSETUP benchmark -c capi:xts\(aes\)-plain64 >/dev/null || fail
|
||||||
|
|
||||||
[ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skipped."
|
[ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skipped."
|
||||||
[ -z "$LOOPDEV" ] && skip "WARNING: Cannot find free loop device, test skipped."
|
[ -z "$LOOPDEV" ] && skip "WARNING: Cannot find free loop device, test skipped."
|
||||||
[ ! -x "$DIFFER" ] && skip "Cannot find $DIFFER, test skipped."
|
[ ! -x "$DIFFER" ] && skip "Cannot find $DIFFER, test skipped."
|
||||||
|
|||||||
Reference in New Issue
Block a user