mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 10:14:55 +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
38 lines
1.3 KiB
C
38 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.
|
|
*/
|
|
|
|
#ifndef VBOOT_REFERENCE_RSA_H_
|
|
#define VBOOT_REFERENCE_RSA_H_
|
|
|
|
#include <inttypes.h>
|
|
|
|
#define RSA1024NUMBYTES 128 /* 1024 bit key length */
|
|
#define RSA2048NUMBYTES 256 /* 2048 bit key length */
|
|
#define RSA4096NUMBYTES 512 /* 4096 bit key length */
|
|
#define RSA8192NUMBYTES 1024 /* 8192 bit key length */
|
|
|
|
#define RSA1024NUMWORDS (RSA1024NUMBYTES / sizeof(uint32_t))
|
|
#define RSA2048NUMWORDS (RSA2048NUMBYTES / sizeof(uint32_t))
|
|
#define RSA4096NUMWORDS (RSA4096NUMBYTES / sizeof(uint32_t))
|
|
#define RSA8192NUMWORDS (RSA8192NUMBYTES / sizeof(uint32_t))
|
|
|
|
typedef struct RSAPublicKey {
|
|
int len; /* Length of n[] in number of uint32_t */
|
|
uint32_t n0inv; /* -1 / n[0] mod 2^32 */
|
|
uint32_t* n; /* modulus as little endian array */
|
|
uint32_t* rr; /* R^2 as little endian array */
|
|
} RSAPublicKey;
|
|
|
|
/* Verify a RSA PKCS1.5 signature [sig] of [sig_type] and length [sig_len]
|
|
* against an expected [hash] using [key]. Returns 0 on failure, 1 on success.
|
|
*/
|
|
int RSAVerify(const RSAPublicKey *key,
|
|
const uint8_t* sig,
|
|
const int sig_len,
|
|
const uint8_t sig_type,
|
|
const uint8_t* hash);
|
|
|
|
#endif /* VBOOT_REFERENCE_RSA_H_ */
|