summaryrefslogtreecommitdiff
path: root/arm9/lib/include
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/lib/include')
-rw-r--r--arm9/lib/include/MATH_crc.h38
-rw-r--r--arm9/lib/include/MATH_dgt.h45
-rw-r--r--arm9/lib/include/MATH_pop.h8
-rw-r--r--arm9/lib/include/dgt.h37
-rw-r--r--arm9/lib/include/math.h9
5 files changed, 137 insertions, 0 deletions
diff --git a/arm9/lib/include/MATH_crc.h b/arm9/lib/include/MATH_crc.h
new file mode 100644
index 00000000..800b738b
--- /dev/null
+++ b/arm9/lib/include/MATH_crc.h
@@ -0,0 +1,38 @@
+#ifndef GUARD_MATH_CRC_H
+#define GUARD_MATH_CRC_H
+
+#include "types.h"
+
+typedef u8 MATHCRC8Context;
+typedef u16 MATHCRC16Context;
+typedef u32 MATHCRC32Context;
+
+struct MATHCRC8Table {
+ u8 table[256];
+};
+
+struct MATHCRC16Table {
+ u16 table[256];
+};
+
+struct MATHCRC32Table {
+ u32 table[256];
+};
+
+u32 MATH_CalcCRC32(const struct MATHCRC32Table *table, const void *data, u32 dataLength);
+void MATHi_CRC32UpdateRev(const struct MATHCRC32Table *table, MATHCRC32Context *context, const void *input, u32 length);
+u16 MATH_CalcCRC16CCITT(const struct MATHCRC16Table *table, const void *data, u32 dataLength);
+void MATHi_CRC16Update(const struct MATHCRC16Table *table, MATHCRC16Context *context, const void *input, u32 length);
+u16 MATH_CalcCRC16(const struct MATHCRC16Table *table, const void *data, u32 dataLength);
+void MATHi_CRC16UpdateRev(const struct MATHCRC16Table *table, MATHCRC16Context *context, const void *input, u32 length);
+u8 MATH_CalcCRC8(const struct MATHCRC8Table *table, const void *data, u32 dataLength);
+void MATHi_CRC8Update(const struct MATHCRC8Table *table, MATHCRC8Context *context, const void *input, u32 length);
+void MATHi_CRC32InitTableRev(struct MATHCRC32Table *table, u32 poly);
+void MATHi_CRC16UpdateRev(const struct MATHCRC16Table *table, MATHCRC16Context *context, const void *input, u32 length);
+void MATHi_CRC16Update(const struct MATHCRC16Table *table, MATHCRC16Context *context, const void *input, u32 length);
+void MATHi_CRC16InitTableRev(struct MATHCRC16Table *table, u16 poly);
+void MATHi_CRC16InitTable(struct MATHCRC16Table *table, u16 poly);
+void MATHi_CRC8Update(const struct MATHCRC8Table *table, MATHCRC8Context *context, const void *input, u32 length);
+void MATHi_CRC8InitTable(struct MATHCRC8Table *table, u8 poly);
+
+#endif
diff --git a/arm9/lib/include/MATH_dgt.h b/arm9/lib/include/MATH_dgt.h
new file mode 100644
index 00000000..9eb3d2ef
--- /dev/null
+++ b/arm9/lib/include/MATH_dgt.h
@@ -0,0 +1,45 @@
+#ifndef GUARD_MATH_DGT_H
+#define GUARD_MATH_DGT_H
+
+#include "dgt.h"
+#include "types.h"
+
+typedef struct DGTHash1Context MATHMD5Context;
+typedef struct DGTHash2Context MATHSHA1Context;
+
+static inline void MATH_MD5Init(MATHMD5Context *context) {
+ DGT_Hash1Reset(context);
+}
+
+static inline void MATH_MD5Update(MATHMD5Context *context, const void *input, u32 length) {
+ DGT_Hash1SetSource(context, (u8*)input, length);
+}
+
+static inline void MATH_MD5GetHash(MATHMD5Context *context, void *digest) {
+ DGT_Hash1GetDigest_R((u8*)digest, context);
+}
+
+static inline void MATH_MD5GetDigest(MATHMD5Context *context, void *digest) {
+ MATH_MD5GetHash(context, digest);
+}
+
+static inline void MATH_SHA1Init(MATHSHA1Context *context) {
+ DGT_Hash2Reset(context);
+}
+
+static inline void MATH_SHA1Update(MATHSHA1Context *context, const void *input, u32 length) {
+ DGT_Hash2SetSource(context, (u8*)input, length);
+}
+
+static inline void MATH_SHA1GetHash(MATHSHA1Context *context, void *digest) {
+ DGT_Hash2GetDigest(context, (u8*)digest);
+}
+
+static inline void MATH_SHA1GetDigest(MATHSHA1Context *context, void *digest) {
+ MATH_SHA1GetHash(context, digest);
+}
+
+void MATH_CalcMD5(void *digest, const void *data, u32 dataLength);
+void MATH_CalcSHA1(void *digest, const void *data, u32 dataLength);
+
+#endif
diff --git a/arm9/lib/include/MATH_pop.h b/arm9/lib/include/MATH_pop.h
new file mode 100644
index 00000000..89dab0c0
--- /dev/null
+++ b/arm9/lib/include/MATH_pop.h
@@ -0,0 +1,8 @@
+#ifndef GUARD_MATH_POP_H
+#define GUARD_MATH_POP_H
+
+#include "types.h"
+
+u8 MATH_CountPopulation(u32);
+
+#endif
diff --git a/arm9/lib/include/dgt.h b/arm9/lib/include/dgt.h
new file mode 100644
index 00000000..a764e85a
--- /dev/null
+++ b/arm9/lib/include/dgt.h
@@ -0,0 +1,37 @@
+#ifndef GUARD_DGT_H
+#define GUARD_DGT_H
+
+#include "types.h"
+
+struct DGTHash1Context {
+ union {
+ struct {
+ unsigned long a, b, c, d;
+ };
+ unsigned long state[4];
+ };
+ unsigned long long length;
+ union {
+ unsigned long buffer32[16];
+ unsigned char buffer8[64];
+ };
+};
+
+struct DGTHash2Context {
+ unsigned long Intermediate_Hash[5];
+ unsigned long Length_Low;
+ unsigned long Length_High;
+ int Message_Block_Index;
+ unsigned char Message_Block[64];
+ int Computed;
+ int Corrupted;
+};
+
+void DGT_Hash1Reset(struct DGTHash1Context *context);
+void DGT_Hash1SetSource(struct DGTHash1Context *context, u8 *input, u32 length);
+void DGT_Hash1GetDigest_R(u8 *digest, struct DGTHash1Context *context);
+void DGT_Hash2Reset(struct DGTHash2Context *context);
+void DGT_Hash2SetSource(struct DGTHash2Context *context, u8 *input, u32 length);
+void DGT_Hash2GetDigest(struct DGTHash2Context *context, u8 *digest);
+
+#endif
diff --git a/arm9/lib/include/math.h b/arm9/lib/include/math.h
new file mode 100644
index 00000000..085aa24f
--- /dev/null
+++ b/arm9/lib/include/math.h
@@ -0,0 +1,9 @@
+#ifndef GUARD_MATH_H
+#define GUARD_MATH_H
+
+#include "dgt.h"
+#include "MATH_pop.h"
+#include "MATH_crc.h"
+#include "MATH_dgt.h"
+
+#endif