mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
Vboot Reference: Refactor Code.
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
This commit is contained in:
@@ -174,10 +174,10 @@ int main(int argc, char* argv[]) {
|
||||
uint8_t* kernel_sign_key_buf = NULL;
|
||||
uint8_t* firmware_key_blob = NULL;
|
||||
uint8_t* kernel_blob = NULL;
|
||||
int kernel_blob_len = 0;
|
||||
KernelImage* image = NULL;
|
||||
RSAPublicKey* firmware_key = NULL;
|
||||
int error_code = 1;
|
||||
char* tmp_kernelblob_file = ".tmpKernelBlob";
|
||||
|
||||
if(argc != 7) {
|
||||
fprintf(stderr, "Usage: %s <firmware signing algorithm> " /* argv[1] */
|
||||
@@ -217,24 +217,13 @@ int main(int argc, char* argv[]) {
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (!AddKernelSignature(image, argv[5], image->kernel_sign_algorithm)) {
|
||||
if (!AddKernelSignature(image, argv[5])) {
|
||||
fprintf(stderr, "Couldn't create firmware and preamble signature.\n");
|
||||
error_code = 1;
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* Generate a firmware binary blob from image.
|
||||
*
|
||||
* TODO(gauravsh): Add a function to directly generate a binary
|
||||
* blob buffer from a KernelImage instead of indirectly writing to a file
|
||||
* and reading it into a buffer.
|
||||
*/
|
||||
if (!WriteKernelImage(tmp_kernelblob_file, image)) {
|
||||
fprintf(stderr, "Couldn't create a temporary kernel blob file.\n");
|
||||
error_code = 1;
|
||||
goto failure;
|
||||
}
|
||||
kernel_blob = BufferFromFile(tmp_kernelblob_file, &len);
|
||||
kernel_blob = GetKernelBlob(image, &kernel_blob_len);
|
||||
|
||||
/* Test Kernel blob verify operations. */
|
||||
if (!VerifyKernelTest(kernel_blob, firmware_key_blob))
|
||||
|
||||
Reference in New Issue
Block a user