Revert "Verified boot wrapper - replace utility functions"

This reverts commit 0184886c8cb35e8e01d610622df448a7cb063e06

(This works with uboot-next, but not uboot, which doesn't implement its half of the new wrapper API.  So rolling back to leave uboot working.

Change-Id: I1f9e3c63e5bbdb20b9195cd68787bef89f24afee
Reviewed-on: http://gerrit.chromium.org/gerrit/3588
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Randall Spangler
2011-07-01 15:35:43 -07:00
parent f8c6549159
commit cfd841d3c2
15 changed files with 137 additions and 83 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
/* 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.
*
@@ -8,12 +8,11 @@
#include "cryptolib.h"
#include "stateful_util.h"
#include "utility.h"
#include "vboot_api.h"
uint64_t RSAProcessedKeySize(uint64_t algorithm, uint64_t* out_size) {
int key_len; /* Key length in bytes. (int type matches siglen_map) */
uint64_t key_len; /* Key length in bytes. */
if (algorithm < kNumAlgorithms) {
key_len = siglen_map[algorithm];
key_len = siglen_map[algorithm];
/* Total size needed by a RSAPublicKey structure is =
* 2 * key_len bytes for the n and rr arrays
* + sizeof len + sizeof n0inv.
@@ -25,7 +24,7 @@ uint64_t RSAProcessedKeySize(uint64_t algorithm, uint64_t* out_size) {
}
RSAPublicKey* RSAPublicKeyNew(void) {
RSAPublicKey* key = (RSAPublicKey*) VbExMalloc(sizeof(RSAPublicKey));
RSAPublicKey* key = (RSAPublicKey*) Malloc(sizeof(RSAPublicKey));
key->n = NULL;
key->rr = NULL;
return key;
@@ -33,9 +32,9 @@ RSAPublicKey* RSAPublicKeyNew(void) {
void RSAPublicKeyFree(RSAPublicKey* key) {
if (key) {
VbExFree(key->n);
VbExFree(key->rr);
VbExFree(key);
Free(key->n);
Free(key->rr);
Free(key);
}
}
@@ -60,8 +59,8 @@ RSAPublicKey* RSAPublicKeyFromBuf(const uint8_t* buf, uint64_t len) {
return NULL;
}
key->n = (uint32_t*) VbExMalloc(key_len);
key->rr = (uint32_t*) VbExMalloc(key_len);
key->n = (uint32_t*) Malloc(key_len);
key->rr = (uint32_t*) Malloc(key_len);
StatefulMemcpy(&st, &key->n0inv, sizeof(key->n0inv));
StatefulMemcpy(&st, key->n, key_len);
@@ -107,7 +106,7 @@ int RSAVerifyBinary_f(const uint8_t* key_blob,
success = RSAVerify(verification_key, sig, (uint32_t)sig_size,
(uint8_t)algorithm, digest);
VbExFree(digest);
Free(digest);
if (!key)
RSAPublicKeyFree(verification_key); /* Only free if we allocated it. */
return success;