From 3995593b6861e62b6a97207d5d6e28385be229bf Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Thu, 3 Apr 2008 23:01:23 +0000 Subject: Add a SHA-1 implementation to libpayload. Signed-off-by: Uwe Hermann Acked-by: Peter Stuge git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3212 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- payloads/libpayload/include/libpayload.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'payloads/libpayload/include') diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index fb3403a005..5595ff6978 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -41,6 +41,14 @@ #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 +#ifdef CONFIG_TARGET_I386 +#define BYTE_ORDER LITTLE_ENDIAN +#else +#define BYTE_ORDER BIG_ENDIAN +#endif + /* Some NVRAM byte definitions */ #define NVRAM_RTC_SECONDS 0 #define NVRAM_RTC_MINUTES 2 @@ -117,6 +125,20 @@ int vsprintf(char *str, const char *fmt, va_list ap); int printf(const char *fmt, ...); int vprintf(const char *fmt, va_list ap); +/* libc/sha1.c */ +#define SHA1_BLOCK_LENGTH 64 +#define SHA1_DIGEST_LENGTH 20 +typedef struct { + u32 state[5]; + u64 count; + u8 buffer[SHA1_BLOCK_LENGTH]; +} SHA1_CTX; +void SHA1Init(SHA1_CTX *context); +void SHA1Transform(u32 state[5], const u8 buffer[SHA1_BLOCK_LENGTH]); +void SHA1Update(SHA1_CTX *context, const u8 *data, size_t len); +void SHA1Final(u8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context); +u8 *sha1(const u8 *data, size_t len, u8 *buf); + /* libc/string.c */ size_t strnlen(const char *str, size_t maxlen); size_t strlen(const char *str); -- cgit v1.2.3