Skip to content

Commit

Permalink
Rename SHA_DIGEST_LENGTH to SHA1_DIGEST_LENGTH
Browse files Browse the repository at this point in the history
  • Loading branch information
lxylxy123456 committed Oct 9, 2022
1 parent 33db641 commit c97a021
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions hypapps/lockdown/src/app/approvedexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void approvedexec_setup(VCPU *vcpu, APP_PARAM_BLOCK *apb){
//pagebase_paddr (assumed to be page-aligned).
//return: 1 if there is a matching hash for this page else 0
u32 approvedexec_checkhashes(u32 pagebase_paddr, u32 *index, u32 *fullhash){
u8 sha1sum[SHA_DIGEST_LENGTH];
u8 sha1sum[SHA1_DIGEST_LENGTH];

u32 i;

Expand All @@ -177,7 +177,7 @@ u32 approvedexec_checkhashes(u32 pagebase_paddr, u32 *index, u32 *fullhash){

//first scan the full hashlist to find a match
for(i=0; i <hashlist_full_totalelements; i++){
if (memcmp(hashlist_full[i].shanum, sha1sum, SHA_DIGEST_LENGTH) == 0){
if (memcmp(hashlist_full[i].shanum, sha1sum, SHA1_DIGEST_LENGTH) == 0){
*index = i;
*fullhash = 1;
//AX_DEBUG(("\nSUCCESS(Full Hash List) for %s", hashlist_full[i].name));
Expand All @@ -191,7 +191,7 @@ u32 approvedexec_checkhashes(u32 pagebase_paddr, u32 *index, u32 *fullhash){
sha1_buffer((const u8 *)hashlist_partial[i].pageoffset+pagebase_paddr, hashlist_partial[i].size,
sha1sum);

if (memcmp(hashlist_partial[i].shanum, sha1sum, SHA_DIGEST_LENGTH) == 0){
if (memcmp(hashlist_partial[i].shanum, sha1sum, SHA1_DIGEST_LENGTH) == 0){
*index = i;
*fullhash=0;
//AX_DEBUG(("\nSUCCESS(Part Hash List) for %s", hashlist_partial[i].name));
Expand Down
4 changes: 2 additions & 2 deletions hypapps/lockdown/src/guestos/windows/genhashes/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#define __SHA1_H__

#define SHA1_RESULTLEN (160/8)
#define SHA_DIGEST_LENGTH SHA1_RESULTLEN
#define SHA1_DIGEST_LENGTH SHA1_RESULTLEN

int sha1_buffer(const unsigned char *buffer, size_t len,
unsigned char md[SHA_DIGEST_LENGTH]);
unsigned char md[SHA1_DIGEST_LENGTH]);


#endif /* __SHA1_H__ */
2 changes: 1 addition & 1 deletion xmhf/src/libbaremetal/libtv_utpm/utpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ TPM_RESULT utpm_quote(TPM_NONCE* externalnonce, TPM_PCR_SELECTION* tpmsel, /* hy

{
unsigned long outlen_long = *outlen;
uint8_t md[SHA_DIGEST_LENGTH];
uint8_t md[SHA1_DIGEST_LENGTH];

sha1_buffer( (uint8_t*)&quote_info, sizeof(TPM_QUOTE_INFO), md);

Expand Down
18 changes: 9 additions & 9 deletions xmhf/src/libbaremetal/libxmhfcrypto/hashandprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <sha1.h>

void hashandprint(const char* prefix, const u8 *bytes, size_t len) {
u8 digest[SHA_DIGEST_LENGTH];
u8 digest[SHA1_DIGEST_LENGTH];

#ifdef __AMD64__
printf("hashandprint: processing 0x%016x bytes at addr %016x\n", len, (u64)bytes);
Expand All @@ -62,20 +62,20 @@ void hashandprint(const char* prefix, const u8 *bytes, size_t len) {

EU_VERIFYN( sha1_buffer(bytes, len, digest));

printf("%s: %*D\n", prefix, SHA_DIGEST_LENGTH, digest, " ");
/* print_hex( prefix, digest, SHA_DIGEST_LENGTH); */
printf("%s: %*D\n", prefix, SHA1_DIGEST_LENGTH, digest, " ");
/* print_hex( prefix, digest, SHA1_DIGEST_LENGTH); */

/* Simulate PCR 17 value on AMD processor */
/* if(len == 0x10000) { */
/* u8 zeros[SHA_DIGEST_LENGTH]; */
/* u8 pcr17[SHA_DIGEST_LENGTH]; */
/* memset(zeros, 0, SHA_DIGEST_LENGTH); */
/* u8 zeros[SHA1_DIGEST_LENGTH]; */
/* u8 pcr17[SHA1_DIGEST_LENGTH]; */
/* memset(zeros, 0, SHA1_DIGEST_LENGTH); */

/* SHA1_Init(&ctx); */
/* SHA1_Update(&ctx, zeros, SHA_DIGEST_LENGTH); */
/* SHA1_Update(&ctx, digest, SHA_DIGEST_LENGTH); */
/* SHA1_Update(&ctx, zeros, SHA1_DIGEST_LENGTH); */
/* SHA1_Update(&ctx, digest, SHA1_DIGEST_LENGTH); */
/* SHA1_Final(pcr17, &ctx); */

/* print_hex("[AMD] Expected PCR-17: ", pcr17, SHA_DIGEST_LENGTH); */
/* print_hex("[AMD] Expected PCR-17: ", pcr17, SHA1_DIGEST_LENGTH); */
/* } */
}
6 changes: 3 additions & 3 deletions xmhf/src/libbaremetal/libxmhfcrypto/include/hmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@

typedef struct _HMAC_SHA1_CTX {
SHA_CTX ctx;
uint8_t key[SHA_DIGEST_LENGTH];
uint8_t key[SHA1_DIGEST_LENGTH];
unsigned int key_len;
} HMAC_SHA1_CTX;

void HMAC_SHA1_Init(HMAC_SHA1_CTX *, const uint8_t *, unsigned int);
void HMAC_SHA1_Update(HMAC_SHA1_CTX *, const uint8_t *, unsigned int);
void HMAC_SHA1_Final(uint8_t [SHA_DIGEST_LENGTH], HMAC_SHA1_CTX *);
void HMAC_SHA1_Final(uint8_t [SHA1_DIGEST_LENGTH], HMAC_SHA1_CTX *);
void HMAC_SHA1(const uint8_t *key, uint32_t keylen,
const uint8_t *msg, uint32_t len,
uint8_t md[SHA_DIGEST_LENGTH]);
uint8_t md[SHA1_DIGEST_LENGTH]);
#endif //__ASSEMBLY__

#endif /* _HMAC_H_ */
4 changes: 2 additions & 2 deletions xmhf/src/libbaremetal/libxmhfcrypto/include/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#define __SHA1_H__

#define SHA1_RESULTLEN (160/8)
#define SHA_DIGEST_LENGTH SHA1_RESULTLEN
#define SHA1_DIGEST_LENGTH SHA1_RESULTLEN

int sha1_buffer(const unsigned char *buffer, size_t len,
unsigned char md[SHA_DIGEST_LENGTH]);
unsigned char md[SHA1_DIGEST_LENGTH]);

// utility function to perform a SHA-1 hash and print result
void hashandprint(const char* prefix, const u8 *bytes, size_t len);
Expand Down
2 changes: 1 addition & 1 deletion xmhf/src/libbaremetal/libxmhfcrypto/sha1_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <euchk.h>

int sha1_buffer(const unsigned char *buffer, size_t len,
unsigned char md[SHA_DIGEST_LENGTH])
unsigned char md[SHA1_DIGEST_LENGTH])
{
int rv=0;
hash_state hs;
Expand Down
2 changes: 1 addition & 1 deletion xmhf/src/xmhf-core/include/xmhf-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
//"golden" digest values injected using CFLAGS during build process
//NOTE: NO WAY TO SELF-CHECK slbelow64K; JUST A SANITY-CHECK
typedef struct _integrity_measurement_values {
u8 sha_slbelow64K[20]; // TODO: play nice with SHA_DIGEST_LENGTH in sha1.h
u8 sha_slbelow64K[20]; // TODO: play nice with SHA1_DIGEST_LENGTH in sha1.h
u8 sha_slabove64K[20];
u8 sha_runtime[20];
} INTEGRITY_MEASUREMENT_VALUES;
Expand Down
6 changes: 3 additions & 3 deletions xmhf/src/xmhf-core/xmhf-bootloader/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,17 +913,17 @@ void cstartup(multiboot_info_t *mbi){
#ifndef __SKIP_BOOTLOADER_HASH__
/* runtime */
print_hex(" INIT(early): *UNTRUSTED* gold runtime: ",
g_init_gold.sha_runtime, SHA_DIGEST_LENGTH);
g_init_gold.sha_runtime, SHA1_DIGEST_LENGTH);
hashandprint(" INIT(early): *UNTRUSTED* comp runtime: ",
(u8*)hypervisor_image_baseaddress+0x200000, sl_rt_size-0x200000);
/* SL low 64K */
print_hex(" INIT(early): *UNTRUSTED* gold SL low 64K: ",
g_init_gold.sha_slbelow64K, SHA_DIGEST_LENGTH);
g_init_gold.sha_slbelow64K, SHA1_DIGEST_LENGTH);
hashandprint(" INIT(early): *UNTRUSTED* comp SL low 64K: ",
(u8*)hypervisor_image_baseaddress, 0x10000);
/* SL above 64K */
print_hex(" INIT(early): *UNTRUSTED* gold SL above 64K: ",
g_init_gold.sha_slabove64K, SHA_DIGEST_LENGTH);
g_init_gold.sha_slabove64K, SHA1_DIGEST_LENGTH);
hashandprint(" INIT(early): *UNTRUSTED* comp SL above 64K): ",
(u8*)hypervisor_image_baseaddress+0x10000, 0x200000-0x10000);
#endif /* !__SKIP_BOOTLOADER_HASH__ */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// author: Eric Li (xiaoyili@andrew.cmu.edu)
#include <xmhf.h>

unsigned char ucode_recognized_sha1s[][SHA_DIGEST_LENGTH] = {
unsigned char ucode_recognized_sha1s[][SHA1_DIGEST_LENGTH] = {
{0x63, 0x7e, 0x40, 0x17, 0x6f, 0x07, 0x6f, 0x5e, 0x6f, 0xee, 0xcc, 0x3e, 0x78, 0x8d, 0x33, 0xaa, 0x0b, 0xe2, 0xad, 0x79}, /* file 06-03-02, bytes 0 - 2048 */
{0xc6, 0xc5, 0x66, 0x49, 0xcf, 0x68, 0xbb, 0x80, 0xe9, 0x5a, 0xb8, 0x79, 0xa6, 0x9c, 0xa2, 0xaa, 0x26, 0xb9, 0xd2, 0x28}, /* file 06-05-00, bytes 0 - 2048 */
{0x4f, 0x63, 0x32, 0x98, 0x0d, 0xd6, 0x79, 0x5d, 0xb8, 0x5a, 0xbe, 0x90, 0xd8, 0x78, 0x4b, 0x9a, 0x92, 0xb0, 0x76, 0xfa}, /* file 06-05-00, bytes 2048 - 4096 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include <hptw.h>
#include <hpt_emhf.h>

extern unsigned char ucode_recognized_sha1s[][SHA_DIGEST_LENGTH];
extern unsigned char ucode_recognized_sha1s[][SHA1_DIGEST_LENGTH];
extern u32 ucode_recognized_sha1s_len;

/*
Expand Down Expand Up @@ -99,11 +99,11 @@ typedef struct __attribute__ ((packed)) {
static int ucode_check_sha1(intel_ucode_update_t *header)
{
const unsigned char *buffer = (const unsigned char *) header;
unsigned char md[SHA_DIGEST_LENGTH];
unsigned char md[SHA1_DIGEST_LENGTH];
HALT_ON_ERRORCOND(sha1_buffer(buffer, header->total_size, md) == 0);
print_hex("SHA1(update) = ", md, SHA_DIGEST_LENGTH);
print_hex("SHA1(update) = ", md, SHA1_DIGEST_LENGTH);
for (u32 i = 0; i < ucode_recognized_sha1s_len; i++) {
if (memcmp(md, ucode_recognized_sha1s[i], SHA_DIGEST_LENGTH) == 0) {
if (memcmp(md, ucode_recognized_sha1s[i], SHA1_DIGEST_LENGTH) == 0) {
return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion xmhf/src/xmhf-core/xmhf-secureloader/arch/x86/sl-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ u32 xmhf_sl_arch_x86_setup_runtime_paging(RPB *rpb, u32 runtime_spa, u32 runtime
tpm_pcr_value_t pcr17, pcr18;
(void)g_sl_gold;
print_hex("SL: Golden Runtime SHA-1: ", g_sl_gold.sha_runtime, SHA_DIGEST_LENGTH);
print_hex("SL: Golden Runtime SHA-1: ", g_sl_gold.sha_runtime, SHA1_DIGEST_LENGTH);
printf("SL: CR0 %08lx, CD bit %ld\n", read_cr0(), read_cr0() & CR0_CD);
hashandprint("SL: Computed Runtime SHA-1: ",
Expand Down

0 comments on commit c97a021

Please sign in to comment.