summaryrefslogtreecommitdiffstats
path: root/tboot/include/sha256.h
diff options
context:
space:
mode:
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__ */
+