mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 10:14:55 +00:00
cryptolib: put constant arrays in rodata segment
The SHA256 constants and some algo definitions are currently in the .data segment, this wastes precious RAM on the EC where read-only data are stored in flash only. BUG=chrome-os-partner:12271 TEST=sudo emerge vboot_reference && emerge-daisy vboot_reference vboot_reference-firmware chromeos-ec and manually check the content of the .data segment in the EC binary. Change-Id: I67b8c0f2843312651e8ac287cea2f8cb5f075453 Reviewed-on: https://gerrit.chromium.org/gerrit/29273 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
@@ -29,12 +29,12 @@ extern const int kNumAlgorithms;
|
|||||||
|
|
||||||
extern const int digestinfo_size_map[];
|
extern const int digestinfo_size_map[];
|
||||||
extern const int siglen_map[];
|
extern const int siglen_map[];
|
||||||
extern const uint8_t* padding_map[];
|
extern const uint8_t* const padding_map[];
|
||||||
extern const int padding_size_map[];
|
extern const int padding_size_map[];
|
||||||
extern const int hash_type_map[];
|
extern const int hash_type_map[];
|
||||||
extern const int hash_size_map[];
|
extern const int hash_size_map[];
|
||||||
extern const int hash_blocksize_map[];
|
extern const int hash_blocksize_map[];
|
||||||
extern const uint8_t* hash_digestinfo_map[];
|
extern const uint8_t* const hash_digestinfo_map[];
|
||||||
extern const char* algo_strings[];
|
extern const char* const algo_strings[];
|
||||||
|
|
||||||
#endif /* VBOOT_REFERENCE_PADDING_H_ */
|
#endif /* VBOOT_REFERENCE_PADDING_H_ */
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ RSA8192NUMBYTES,
|
|||||||
RSA8192NUMBYTES,
|
RSA8192NUMBYTES,
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t* padding_map[NUMALGORITHMS] = {
|
const uint8_t* const padding_map[NUMALGORITHMS] = {
|
||||||
#ifdef CHROMEOS_EC
|
#ifdef CHROMEOS_EC
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -233,7 +233,7 @@ SHA256_BLOCK_SIZE,
|
|||||||
SHA512_BLOCK_SIZE,
|
SHA512_BLOCK_SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t* hash_digestinfo_map[NUMALGORITHMS] = {
|
const uint8_t* const hash_digestinfo_map[NUMALGORITHMS] = {
|
||||||
SHA1_digestinfo,
|
SHA1_digestinfo,
|
||||||
SHA256_digestinfo,
|
SHA256_digestinfo,
|
||||||
SHA512_digestinfo,
|
SHA512_digestinfo,
|
||||||
@@ -248,7 +248,7 @@ SHA256_digestinfo,
|
|||||||
SHA512_digestinfo,
|
SHA512_digestinfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* algo_strings[NUMALGORITHMS] = {
|
const char* const algo_strings[NUMALGORITHMS] = {
|
||||||
"RSA1024 SHA1",
|
"RSA1024 SHA1",
|
||||||
"RSA1024 SHA256",
|
"RSA1024 SHA256",
|
||||||
"RSA1024 SHA512",
|
"RSA1024 SHA512",
|
||||||
|
|||||||
@@ -82,11 +82,11 @@
|
|||||||
wv[h] = t1 + t2; \
|
wv[h] = t1 + t2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sha256_h0[8] = {
|
static const uint32_t sha256_h0[8] = {
|
||||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
||||||
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
|
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
|
||||||
|
|
||||||
uint32_t sha256_k[64] = {
|
static const uint32_t sha256_k[64] = {
|
||||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||||
|
|||||||
@@ -98,13 +98,13 @@
|
|||||||
wv[h] = t1 + t2; \
|
wv[h] = t1 + t2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t sha512_h0[8] = {
|
static const uint64_t sha512_h0[8] = {
|
||||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
||||||
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
||||||
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL};
|
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL};
|
||||||
|
|
||||||
uint64_t sha512_k[80] = {
|
static const uint64_t sha512_k[80] = {
|
||||||
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
|
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
|
||||||
0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
|
0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
|
||||||
0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
|
0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user