memcpy(iv, &key[ciphers->cipher[0].iv_offset], bs);
/* Initialize all ciphers in chain in ECB mode */
+ for (j = 0; j < ciphers->chain_count; j++)
+ cipher[j] = NULL;
for (j = 0; j < ciphers->chain_count; j++) {
r = crypt_cipher_init(&cipher[j], ciphers->cipher[j].name, "ecb",
&key[ciphers->cipher[j].key_offset],
const char *key, int legacy_modes)
{
struct tcrypt_phdr hdr2;
- int i, j, r;
+ int i, j, r = -EINVAL;
for (i = 0; tcrypt_cipher[i].chain_count; i++) {
if (!legacy_modes && tcrypt_cipher[i].legacy)
{ NULL, NULL, 0, 0 }
};
char *header = "# Tests are approximate using memory only (no storage IO).\n"
- "# Algorithm | Key | Encryption | Decryption\n";
+ "# Algorithm | Key | Encryption | Decryption\n";
char cipher[MAX_CIPHER_LEN], cipher_mode[MAX_CIPHER_LEN];
double enc_mbr = 0, dec_mbr = 0;
int key_size = (opt_key_size ?: DEFAULT_PLAIN_KEYBITS);
*c = '\0';
/* FIXME: not really clever :) */
- if (strstr(cipher, "des"))
+ if (strstr(cipher, "des") ||
+ strstr(cipher, "blowfish") ||
+ strstr(cipher, "cast5"))
iv_size = 8;
r = crypt_benchmark(NULL, cipher, cipher_mode,
log_std("%s", header);
strncat(cipher, "-", MAX_CIPHER_LEN);
strncat(cipher, cipher_mode, MAX_CIPHER_LEN);
- log_std("%11s %4db %5.1f MiB/s %5.1f MiB/s\n",
+ log_std("%12s %4db %5.1f MiB/s %5.1f MiB/s\n",
cipher, key_size, enc_mbr, dec_mbr);
} else if (r == -ENOENT)
log_err(_("Cipher %s is not available.\n"), opt_cipher);
snprintf(cipher, MAX_CIPHER_LEN, "%s-%s",
bciphers[i].cipher, bciphers[i].mode);
if (!r)
- log_std("%11s %4db %5.1f MiB/s %5.1f MiB/s\n",
+ log_std("%12s %4db %5.1f MiB/s %5.1f MiB/s\n",
cipher, bciphers[i].key_size*8, enc_mbr, dec_mbr);
else
- log_std("%11s %4db %12s %12s\n", cipher,
+ log_std("%12s %4db %12s %12s\n", cipher,
bciphers[i].key_size*8, _("N/A"), _("N/A"));
}
if (skipped && skipped == i)
function fail()
{
[ -n "$1" ] && echo "$1"
- echo "FAILED"
+ echo " [FAILED]"
remove_mapping
exit 2
}
+function skip()
+{
+ [ -n "$1" ] && echo "$1"
+ echo "Test skipped."
+ exit 0
+}
+
+function test_one()
+{
+ $CRYPTSETUP benchmark -c "$1" -s "$2" | grep -v "#" || skip
+}
+
+function test_required()
+{
+ echo "REQUIRED CIPHERS TEST"
+ echo "# Algorithm | Key | Encryption | Decryption"
+
+ test_one aes-cbc 256
+ test_one aes-lrw 384
+ test_one aes-xts 512
+
+ test_one twofish-cbc 256
+ test_one twofish-lrw 384
+ test_one twofish-xts 512
+
+ test_one serpent-cbc 256
+ test_one serpent-lrw 384
+ test_one serpent-xts 512
+
+ test_one blowfish-cbc 256
+
+ test_one des3_ede-cbc 192
+ test_one cast5 128
+}
+
+test_required
[ ! -d $TST_DIR ] && tar xjf tcrypt-images.tar.bz2
done
if [ $(id -u) != 0 ]; then
- echo "WARNING: You must be root to run this test, test skipped."
+ echo "WARNING: You must be root to run activation part of test, test skipped."
exit 0
fi