mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 18:55:24 +00:00
vboot2: Split crypto algorithms into their own header file
This allows the algorithm list to be shared by code which simply needs to look at the vboot structures. No functional changes; just moving enums around and adding comments. BUG=chromium:423882 BRANCH=none TEST=make runtests; VBOOT2=1 make runtests Change-Id: Ia8cefeffb28d5eceb290540195193ea13e68e2c1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223541 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
3638625d35
commit
f2f88042ed
31
firmware/2lib/include/2crypto.h
Normal file
31
firmware/2lib/include/2crypto.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/* Copyright (c) 2014 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.
|
||||||
|
*
|
||||||
|
* Crypto constants for verified boot
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VBOOT_REFERENCE_VBOOT_2CRYPTO_H_
|
||||||
|
#define VBOOT_REFERENCE_VBOOT_2CRYPTO_H_
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* Verified boot crypto algorithms */
|
||||||
|
enum vb2_crypto_algorithm {
|
||||||
|
VB2_ALG_RSA1024_SHA1 = 0,
|
||||||
|
VB2_ALG_RSA1024_SHA256 = 1,
|
||||||
|
VB2_ALG_RSA1024_SHA512 = 2,
|
||||||
|
VB2_ALG_RSA2048_SHA1 = 3,
|
||||||
|
VB2_ALG_RSA2048_SHA256 = 4,
|
||||||
|
VB2_ALG_RSA2048_SHA512 = 5,
|
||||||
|
VB2_ALG_RSA4096_SHA1 = 6,
|
||||||
|
VB2_ALG_RSA4096_SHA256 = 7,
|
||||||
|
VB2_ALG_RSA4096_SHA512 = 8,
|
||||||
|
VB2_ALG_RSA8192_SHA1 = 9,
|
||||||
|
VB2_ALG_RSA8192_SHA256 = 10,
|
||||||
|
VB2_ALG_RSA8192_SHA512 = 11,
|
||||||
|
|
||||||
|
/* Number of algorithms */
|
||||||
|
VB2_ALG_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* VBOOT_REFERENCE_VBOOT_2CRYPTO_H_ */
|
||||||
@@ -6,28 +6,10 @@
|
|||||||
#ifndef VBOOT_REFERENCE_2RSA_H_
|
#ifndef VBOOT_REFERENCE_2RSA_H_
|
||||||
#define VBOOT_REFERENCE_2RSA_H_
|
#define VBOOT_REFERENCE_2RSA_H_
|
||||||
|
|
||||||
|
#include "2crypto.h"
|
||||||
|
|
||||||
struct vb2_workbuf;
|
struct vb2_workbuf;
|
||||||
|
|
||||||
/* Algorithms for crypto lib */
|
|
||||||
enum vb2_crypto_algorithm {
|
|
||||||
VB2_ALG_RSA1024_SHA1 = 0,
|
|
||||||
VB2_ALG_RSA1024_SHA256,
|
|
||||||
VB2_ALG_RSA1024_SHA512,
|
|
||||||
VB2_ALG_RSA2048_SHA1,
|
|
||||||
VB2_ALG_RSA2048_SHA256,
|
|
||||||
VB2_ALG_RSA2048_SHA512,
|
|
||||||
VB2_ALG_RSA4096_SHA1,
|
|
||||||
VB2_ALG_RSA4096_SHA256,
|
|
||||||
VB2_ALG_RSA4096_SHA512,
|
|
||||||
VB2_ALG_RSA8192_SHA1,
|
|
||||||
VB2_ALG_RSA8192_SHA256,
|
|
||||||
VB2_ALG_RSA8192_SHA512,
|
|
||||||
// TODO: add algorithms for bare SHA with no RSA?
|
|
||||||
|
|
||||||
/* Number of algorithms */
|
|
||||||
VB2_ALG_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Public key structure in RAM */
|
/* Public key structure in RAM */
|
||||||
struct vb2_public_key {
|
struct vb2_public_key {
|
||||||
uint32_t arrsize; /* Length of n[] and rr[] in number of uint32_t */
|
uint32_t arrsize; /* Length of n[] and rr[] in number of uint32_t */
|
||||||
@@ -40,7 +22,7 @@ struct vb2_public_key {
|
|||||||
/**
|
/**
|
||||||
* Return the size of a RSA signature
|
* Return the size of a RSA signature
|
||||||
*
|
*
|
||||||
* @param algorithm Key algorithm
|
* @param algorithm Key algorithm (enum vb2_crypto_algorithm)
|
||||||
* @return The size of the signature, or 0 if error.
|
* @return The size of the signature, or 0 if error.
|
||||||
*/
|
*/
|
||||||
uint32_t vb2_rsa_sig_size(uint32_t algorithm);
|
uint32_t vb2_rsa_sig_size(uint32_t algorithm);
|
||||||
@@ -48,7 +30,7 @@ uint32_t vb2_rsa_sig_size(uint32_t algorithm);
|
|||||||
/**
|
/**
|
||||||
* Return the size of a pre-processed RSA public key.
|
* Return the size of a pre-processed RSA public key.
|
||||||
*
|
*
|
||||||
* @param algorithm Key algorithm
|
* @param algorithm Key algorithm (enum vb2_crypto_algorithm)
|
||||||
* @return The size of the preprocessed key, or 0 if error.
|
* @return The size of the preprocessed key, or 0 if error.
|
||||||
*/
|
*/
|
||||||
uint32_t vb2_packed_key_size(uint32_t algorithm);
|
uint32_t vb2_packed_key_size(uint32_t algorithm);
|
||||||
@@ -57,7 +39,7 @@ uint32_t vb2_packed_key_size(uint32_t algorithm);
|
|||||||
* Check pkcs 1.5 padding bytes
|
* Check pkcs 1.5 padding bytes
|
||||||
*
|
*
|
||||||
* @param sig Signature to verify
|
* @param sig Signature to verify
|
||||||
* @param algorithm Key algorithm
|
* @param algorithm Key algorithm (enum vb2_crypto_algorithm)
|
||||||
* @return VB2_SUCCESS, or non-zero if error.
|
* @return VB2_SUCCESS, or non-zero if error.
|
||||||
*/
|
*/
|
||||||
int vb2_check_padding(uint8_t *sig, int algorithm);
|
int vb2_check_padding(uint8_t *sig, int algorithm);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#ifndef VBOOT_REFERENCE_2SHA_H_
|
#ifndef VBOOT_REFERENCE_2SHA_H_
|
||||||
#define VBOOT_REFERENCE_2SHA_H_
|
#define VBOOT_REFERENCE_2SHA_H_
|
||||||
|
|
||||||
|
#include "2crypto.h"
|
||||||
|
|
||||||
/* Hash algorithms may be disabled individually to save code space */
|
/* Hash algorithms may be disabled individually to save code space */
|
||||||
|
|
||||||
#ifndef VB2_SUPPORT_SHA1
|
#ifndef VB2_SUPPORT_SHA1
|
||||||
@@ -73,7 +75,7 @@ struct vb2_digest_context {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Current hash algorithms */
|
/* Current hash algorithm (enum vb2_crypto_algorithm) */
|
||||||
uint32_t algorithm;
|
uint32_t algorithm;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,7 +118,7 @@ void vb2_sha512_finalize(struct vb2_sha512_context *ctx, uint8_t *digest);
|
|||||||
/**
|
/**
|
||||||
* Return the size of the digest for a key algorithm.
|
* Return the size of the digest for a key algorithm.
|
||||||
*
|
*
|
||||||
* @param algorithm Key algorithm
|
* @param algorithm Key algorithm (enum vb2_crypto_algorithm)
|
||||||
* @return The size of the digest, or 0 if error.
|
* @return The size of the digest, or 0 if error.
|
||||||
*/
|
*/
|
||||||
int vb2_digest_size(uint32_t algorithm);
|
int vb2_digest_size(uint32_t algorithm);
|
||||||
@@ -125,7 +127,7 @@ int vb2_digest_size(uint32_t algorithm);
|
|||||||
* Initialize a digest context for doing block-style digesting.
|
* Initialize a digest context for doing block-style digesting.
|
||||||
*
|
*
|
||||||
* @param dc Digest context
|
* @param dc Digest context
|
||||||
* @param algorithm Key algorithm
|
* @param algorithm Key algorithm (enum vb2_crypto_algorithm)
|
||||||
* @return VB2_SUCCESS, or non-zero on error.
|
* @return VB2_SUCCESS, or non-zero on error.
|
||||||
*/
|
*/
|
||||||
int vb2_digest_init(struct vb2_digest_context *dc, uint32_t algorithm);
|
int vb2_digest_init(struct vb2_digest_context *dc, uint32_t algorithm);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ struct vb2_packed_key {
|
|||||||
uint32_t key_size;
|
uint32_t key_size;
|
||||||
uint32_t reserved1;
|
uint32_t reserved1;
|
||||||
|
|
||||||
/* Signature algorithm used by the key */
|
/* Signature algorithm used by the key (enum vb2_crypto_algorithm) */
|
||||||
uint32_t algorithm;
|
uint32_t algorithm;
|
||||||
uint32_t reserved2;
|
uint32_t reserved2;
|
||||||
|
|
||||||
@@ -231,7 +231,10 @@ struct vb2_shared_data {
|
|||||||
/* Flags from GBB header */
|
/* Flags from GBB header */
|
||||||
uint32_t gbb_flags;
|
uint32_t gbb_flags;
|
||||||
|
|
||||||
/* Reason we are in recovery mode this boot, or 0 if we aren't */
|
/*
|
||||||
|
* Reason we are in recovery mode this boot (enum vb2_nv_recovery), or
|
||||||
|
* 0 if we aren't.
|
||||||
|
*/
|
||||||
uint32_t recovery_reason;
|
uint32_t recovery_reason;
|
||||||
|
|
||||||
/* Firmware slot used last boot (0=A, 1=B) */
|
/* Firmware slot used last boot (0=A, 1=B) */
|
||||||
|
|||||||
Reference in New Issue
Block a user