mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
This CL does the following: 1) It adds a SignatureBuf function which uses the OpenSSL library to generate RSA signature. This is more robust than the previous way of invoking the command line "openssl" utility and capturing its output. No more unnecessary temporary files for signature operations. 2) It adds functions that allow direct manipulation of binary verified Firmware and Kernel Image blobs in memory. 3) It changes the structure field members for FirmwareImage to make it consistent with KernelImage. Now it's clearer which key is used when. 4) Minor bug fixes and slightly improved API for dealing verified boot firmware and kernel images. 5) Renames the RSA_verify function to prevent conflicts with OpenSSL since it's linked into the firmware utility binary. Review URL: http://codereview.chromium.org/661353
46 lines
1.3 KiB
C
46 lines
1.3 KiB
C
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "rsa_padding_test.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "file_keys.h"
|
|
#include "rsa_utility.h"
|
|
|
|
int main(int argc, char* argv[]) {
|
|
int i;
|
|
int error = 0;
|
|
RSAPublicKey* key;
|
|
if (argc != 2) {
|
|
fprintf(stderr, "Usage: %s <test public key>\n", argv[0]);
|
|
return 1;
|
|
}
|
|
key = RSAPublicKeyFromFile(argv[1]);
|
|
if (!key) {
|
|
fprintf(stderr, "Couldn't read RSA public key for the test.\n");
|
|
return 1;
|
|
}
|
|
|
|
/* The first test signature is valid. */
|
|
if (!RSAVerify(key, signatures[0], RSA1024NUMBYTES, 0,
|
|
test_message_sha1_hash)) {
|
|
fprintf(stderr, "RSA Padding Test vector 0 FAILED!\n");
|
|
error = 255; /* Test failure. */
|
|
}
|
|
/* All other signatures should fail verification. */
|
|
for (i = 1; i < sizeof(signatures) / sizeof(signatures[0]); i++) {
|
|
if (RSAVerify(key, signatures[i], RSA1024NUMBYTES, 0,
|
|
test_message_sha1_hash)) {
|
|
fprintf(stderr, "RSA Padding Test vector %d FAILED!\n", i);
|
|
error = 255; /* Test failure. */
|
|
}
|
|
}
|
|
if (!error)
|
|
fprintf(stderr, "RSA Padding Test PASSED for all test vectors.");
|
|
|
|
return error;
|
|
}
|