update libchdr
[pcsx_rearmed.git] / deps / libchdr / deps / lzma-22.01 / include / Sha256.h
diff --git a/deps/libchdr/deps/lzma-22.01/include/Sha256.h b/deps/libchdr/deps/lzma-22.01/include/Sha256.h
new file mode 100644 (file)
index 0000000..f529339
--- /dev/null
@@ -0,0 +1,76 @@
+/* Sha256.h -- SHA-256 Hash\r
+2021-01-01 : Igor Pavlov : Public domain */\r
+\r
+#ifndef __7Z_SHA256_H\r
+#define __7Z_SHA256_H\r
+\r
+#include "7zTypes.h"\r
+\r
+EXTERN_C_BEGIN\r
+\r
+#define SHA256_NUM_BLOCK_WORDS  16\r
+#define SHA256_NUM_DIGEST_WORDS  8\r
+\r
+#define SHA256_BLOCK_SIZE   (SHA256_NUM_BLOCK_WORDS * 4)\r
+#define SHA256_DIGEST_SIZE  (SHA256_NUM_DIGEST_WORDS * 4)\r
+\r
+typedef void (MY_FAST_CALL *SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks);\r
+\r
+/*\r
+  if (the system supports different SHA256 code implementations)\r
+  {\r
+    (CSha256::func_UpdateBlocks) will be used\r
+    (CSha256::func_UpdateBlocks) can be set by\r
+       Sha256_Init()        - to default (fastest)\r
+       Sha256_SetFunction() - to any algo\r
+  }\r
+  else\r
+  {\r
+    (CSha256::func_UpdateBlocks) is ignored.\r
+  }\r
+*/\r
+\r
+typedef struct\r
+{\r
+  SHA256_FUNC_UPDATE_BLOCKS func_UpdateBlocks;\r
+  UInt64 count;\r
+  UInt64 __pad_2[2];\r
+  UInt32 state[SHA256_NUM_DIGEST_WORDS];\r
+\r
+  Byte buffer[SHA256_BLOCK_SIZE];\r
+} CSha256;\r
+\r
+\r
+#define SHA256_ALGO_DEFAULT 0\r
+#define SHA256_ALGO_SW      1\r
+#define SHA256_ALGO_HW      2\r
+\r
+/*\r
+Sha256_SetFunction()\r
+return:\r
+  0 - (algo) value is not supported, and func_UpdateBlocks was not changed\r
+  1 - func_UpdateBlocks was set according (algo) value.\r
+*/\r
+\r
+BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo);\r
+\r
+void Sha256_InitState(CSha256 *p);\r
+void Sha256_Init(CSha256 *p);\r
+void Sha256_Update(CSha256 *p, const Byte *data, size_t size);\r
+void Sha256_Final(CSha256 *p, Byte *digest);\r
+\r
+\r
+\r
+\r
+// void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks);\r
+\r
+/*\r
+call Sha256Prepare() once at program start.\r
+It prepares all supported implementations, and detects the fastest implementation.\r
+*/\r
+\r
+void Sha256Prepare(void);\r
+\r
+EXTERN_C_END\r
+\r
+#endif\r