summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/vb20_common2_tests.c13
-rw-r--r--tests/vb20_common3_tests.c19
-rw-r--r--tests/vb21_common2_tests.c12
3 files changed, 21 insertions, 23 deletions
diff --git a/tests/vb20_common2_tests.c b/tests/vb20_common2_tests.c
index 61e28d1a..2dea3172 100644
--- a/tests/vb20_common2_tests.c
+++ b/tests/vb20_common2_tests.c
@@ -142,9 +142,6 @@ static void test_verify_data(const struct vb2_packed_key *key1,
int test_algorithm(int key_algorithm, const char *keys_dir)
{
char filename[1024];
- int rsa_bits = 8 * vb2_rsa_sig_size(
- vb2_crypto_to_signature(key_algorithm));
-
struct vb2_private_key *private_key = NULL;
struct vb2_signature *sig = NULL;
struct vb2_packed_key *key1 = NULL;
@@ -154,16 +151,18 @@ int test_algorithm(int key_algorithm, const char *keys_dir)
printf("***Testing algorithm: %s\n",
vb2_get_crypto_algorithm_name(key_algorithm));
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.pem", keys_dir, rsa_bits);
+ snprintf(filename, sizeof(filename), "%s/key_%s.pem",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(key_algorithm));
private_key = vb2_read_private_key_pem(filename, key_algorithm);
if (!private_key) {
fprintf(stderr, "Error reading private_key: %s\n", filename);
goto cleanup_algorithm;
}
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.keyb", keys_dir, rsa_bits);
+ snprintf(filename, sizeof(filename), "%s/key_%s.keyb",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(key_algorithm));
key1 = vb2_read_packed_keyb(filename, key_algorithm, 1);
if (!key1) {
fprintf(stderr, "Error reading public_key: %s\n", filename);
diff --git a/tests/vb20_common3_tests.c b/tests/vb20_common3_tests.c
index b5ad1ebe..5533124a 100644
--- a/tests/vb20_common3_tests.c
+++ b/tests/vb20_common3_tests.c
@@ -513,10 +513,6 @@ int test_permutation(int signing_key_algorithm, int data_key_algorithm,
const char *keys_dir)
{
char filename[1024];
- int signing_rsa_len = 8 * vb2_rsa_sig_size(
- vb2_crypto_to_signature(signing_key_algorithm));
- int data_rsa_len = 8 * vb2_rsa_sig_size(
- vb2_crypto_to_signature(data_key_algorithm));
int retval = 1;
struct vb2_private_key *signing_private_key = NULL;
@@ -528,8 +524,9 @@ int test_permutation(int signing_key_algorithm, int data_key_algorithm,
printf("***With data key algorithm: %s\n",
vb2_get_crypto_algorithm_name(data_key_algorithm));
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.pem", keys_dir, signing_rsa_len);
+ snprintf(filename, sizeof(filename), "%s/key_%s.pem",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(signing_key_algorithm));
signing_private_key =
vb2_read_private_key_pem(filename, signing_key_algorithm);
if (!signing_private_key) {
@@ -538,8 +535,9 @@ int test_permutation(int signing_key_algorithm, int data_key_algorithm,
goto cleanup_permutation;
}
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.keyb", keys_dir, signing_rsa_len);
+ snprintf(filename, sizeof(filename), "%s/key_%s.keyb",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(signing_key_algorithm));
signing_public_key =
vb2_read_packed_keyb(filename, signing_key_algorithm, 1);
if (!signing_public_key) {
@@ -548,8 +546,9 @@ int test_permutation(int signing_key_algorithm, int data_key_algorithm,
goto cleanup_permutation;
}
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.keyb", keys_dir, data_rsa_len);
+ snprintf(filename, sizeof(filename), "%s/key_%s.keyb",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(data_key_algorithm));
data_public_key =
vb2_read_packed_keyb(filename, data_key_algorithm, 1);
if (!data_public_key) {
diff --git a/tests/vb21_common2_tests.c b/tests/vb21_common2_tests.c
index b121fa5a..7f1aefa2 100644
--- a/tests/vb21_common2_tests.c
+++ b/tests/vb21_common2_tests.c
@@ -239,8 +239,6 @@ static void test_verify_data(const struct vb2_public_key *pubk_orig,
int test_algorithm(int key_algorithm, const char *keys_dir)
{
char filename[1024];
- int rsa_bits = 8 * vb2_rsa_sig_size(
- vb2_crypto_to_signature(key_algorithm));
enum vb2_signature_algorithm sig_alg =
vb2_crypto_to_signature(key_algorithm);
@@ -254,16 +252,18 @@ int test_algorithm(int key_algorithm, const char *keys_dir)
printf("***Testing algorithm: %s\n",
vb2_get_crypto_algorithm_name(key_algorithm));
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.pem", keys_dir, rsa_bits);
+ snprintf(filename, sizeof(filename), "%s/key_%s.pem",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(key_algorithm));
TEST_SUCC(vb2_private_key_read_pem(&prik, filename),
"Read private key");
prik->hash_alg = hash_alg;
prik->sig_alg = sig_alg;
vb2_private_key_set_desc(prik, "private key");
- snprintf(filename, sizeof(filename),
- "%s/key_rsa%d.keyb", keys_dir, rsa_bits);
+ snprintf(filename, sizeof(filename), "%s/key_%s.keyb",
+ keys_dir,
+ vb2_get_crypto_algorithm_file(key_algorithm));
TEST_SUCC(vb2_public_key_read_keyb(&pubk, filename),
"Read public key");
pubk->hash_alg = hash_alg;