Revert "Verified boot wrapper - replace utility functions"

This reverts commit bd81b3a7d3.

Change-Id: I2be2c076a37bf0e49569248691fceac417254f0b
Reviewed-on: http://gerrit.chromium.org/gerrit/3295
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
This commit is contained in:
mukesh agrawal
2011-06-27 20:00:52 -07:00
parent 1c1a883bc7
commit a7b9481f34
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;