summaryrefslogtreecommitdiffstats
path: root/tboot/include/sha256.h
diff options
context:
space:
mode:
authorRoss Philipson <philipsonr@ainfosec.com>2017-03-14 15:40:33 -0400
committerRoss Philipson <philipsonr@ainfosec.com>2017-03-14 15:40:33 -0400
commit4c87a1868835d05f1cadae7b8ad6a7c95d9d9c0e (patch)
tree4c090cd328f0695193d63832b0ff26c6f2f7207b /tboot/include/sha256.h
parenta04a74f8039947b0de64bab7756904ef424ab18c (diff)
downloadtboot-4c87a1868835d05f1cadae7b8ad6a7c95d9d9c0e.tar.gz
tboot-4c87a1868835d05f1cadae7b8ad6a7c95d9d9c0e.tar.bz2
tboot-4c87a1868835d05f1cadae7b8ad6a7c95d9d9c0e.zip
Initial commit of EFI TBOOT work from internal project.
Signed-off-by: Ross Philipson <philipsonr@ainfosec.com>
Diffstat (limited to 'tboot/include/sha256.h')
-rw-r--r--tboot/include/sha256.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/tboot/include/sha256.h b/tboot/include/sha256.h
new file mode 100644
index 0000000..2c3fc56
--- /dev/null
+++ b/tboot/include/sha256.h
@@ -0,0 +1,30 @@
+#ifndef __SHA256_H__
+#define __SHA256_H__
+
+#define STORE64H(x, y) \
+ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \
+ (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \
+ (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \
+ (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); }
+
+#define STORE32H(x, y) \
+ { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \
+ (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); }
+
+#define LOAD32H(x, y) \
+ { x = ((unsigned long)((y)[0] & 255)<<24) | \
+ ((unsigned long)((y)[1] & 255)<<16) | \
+ ((unsigned long)((y)[2] & 255)<<8) | \
+ ((unsigned long)((y)[3] & 255)); }
+
+typedef struct {
+ u64 length;
+ u32 state[8], curlen;
+ unsigned char buf[64];
+}sha256_state;
+
+void sha256_buffer(const unsigned char *buffer, size_t len,
+ unsigned char hash[32]);
+
+#endif /* __SHA256_H__ */
+