diff options
author | Randall Spangler <rspangler@chromium.org> | 2016-10-14 15:37:25 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-29 19:41:09 -0700 |
commit | 5a9f498182586f64865b51c874619d674f5d842c (patch) | |
tree | 79f69ff6aa363b6f53e010773f20f5f22771e06c /tests/vb20_rsa_padding_tests.c | |
parent | 13b109762a3bfec025a9bfcb3ead927d0291280e (diff) | |
download | vboot-5a9f498182586f64865b51c874619d674f5d842c.tar.gz |
host,test: Remove unneeded vb1 rsa functions
Another in a continued stream of refactoring. This change removes more
of the vb1 rsa library code and associated tests, in favor of their vb2
equivalents. This change touches only host-side code and its tests, not
firmware.
BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge
Change-Id: I1973bc2f03c60da62232e30bab0fa5fe791b6b34
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400901
Diffstat (limited to 'tests/vb20_rsa_padding_tests.c')
-rw-r--r-- | tests/vb20_rsa_padding_tests.c | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/tests/vb20_rsa_padding_tests.c b/tests/vb20_rsa_padding_tests.c index 6fe2e970..a70da58c 100644 --- a/tests/vb20_rsa_padding_tests.c +++ b/tests/vb20_rsa_padding_tests.c @@ -7,6 +7,8 @@ #include <stdint.h> #include <stdio.h> +#define _STUB_IMPLEMENTATION_ + #include "cryptolib.h" #include "file_keys.h" #include "rsa_padding_test.h" @@ -15,29 +17,10 @@ #include "2sysincludes.h" #include "2rsa.h" +#include "host_key.h" #include "vb2_common.h" /** - * Convert an old-style RSA public key struct to a new one. - * - * The new one does not allocate memory, so you must keep the old one around - * until you're done with the new one. - * - * @param k2 Destination new key - * @param key Source old key - */ -void vb2_public_key_to_vb2(struct vb2_public_key *k2, - const struct RSAPublicKey *key) -{ - k2->arrsize = key->len; - k2->n0inv = key->n0inv; - k2->n = key->n; - k2->rr = key->rr; - k2->sig_alg = vb2_crypto_to_signature(key->algorithm); - k2->hash_alg = vb2_crypto_to_hash(key->algorithm); -} - -/** * Test valid and invalid signatures. */ static void test_signatures(const struct vb2_public_key *key) @@ -122,37 +105,32 @@ static void test_verify_digest(struct vb2_public_key *key) { int main(int argc, char *argv[]) { - int error = 0; - RSAPublicKey *key; struct vb2_public_key k2; + struct vb2_packed_key *pk; /* Read test key */ if (argc != 2) { fprintf(stderr, "Usage: %s <test public key>\n", argv[0]); return 1; } - key = RSAPublicKeyFromFile(argv[1]); - - if (!key) { + pk = vb2_read_packed_keyb(argv[1], VB2_ALG_RSA1024_SHA1, 0); + if (!pk) { fprintf(stderr, "Couldn't read RSA public key for the test.\n"); return 1; } - // TODO: why is test key algorithm wrong? - key->algorithm = 0; - - /* Convert test key to Vb2 format */ - vb2_public_key_to_vb2(&k2, key); + if (VB2_SUCCESS != vb2_unpack_key(&k2, (const uint8_t *)pk, + pk->key_offset + pk->key_size)) { + fprintf(stderr, "Couldn't unpack RSA public key.\n"); + free(pk); + return 1; + } /* Run tests */ test_signatures(&k2); test_verify_digest(&k2); /* Clean up and exit */ - RSAPublicKeyFree(key); - - if (!gTestSuccess) - error = 255; - - return error; + free(pk); + return gTestSuccess ? 0 : 255; } |