diff options
author | Egor Ananyin <ananinegor@gmail.com> | 2020-05-22 19:46:43 +0300 |
---|---|---|
committer | Egor Ananyin <ananinegor@gmail.com> | 2020-05-22 19:46:43 +0300 |
commit | 7c1d3869d8cf4341acedbe7c662e8ac1ca935666 (patch) | |
tree | effbe3f4c72ebc7916c88518751e87890de4af8b /arm9/lib/include | |
parent | 79a7e3dac84f719ca4d0131ac2e30e2c6a4bd73e (diff) |
Decompile libmath
Diffstat (limited to 'arm9/lib/include')
-rw-r--r-- | arm9/lib/include/MATH.h | 8 | ||||
-rw-r--r-- | arm9/lib/include/MATH_crc.h | 38 | ||||
-rw-r--r-- | arm9/lib/include/MATH_dgt.h | 45 | ||||
-rw-r--r-- | arm9/lib/include/dgt.h | 30 | ||||
-rw-r--r-- | arm9/lib/include/math.h | 8 |
5 files changed, 129 insertions, 0 deletions
diff --git a/arm9/lib/include/MATH.h b/arm9/lib/include/MATH.h new file mode 100644 index 00000000..037492f5 --- /dev/null +++ b/arm9/lib/include/MATH.h @@ -0,0 +1,8 @@ +#ifndef GUARD_MATH_H +#define GUARD_MATH_H + +#include "types.h" + +u8 MATH_CountPopulation(u32); + +#endif 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/dgt.h b/arm9/lib/include/dgt.h new file mode 100644 index 00000000..5e63f3f7 --- /dev/null +++ b/arm9/lib/include/dgt.h @@ -0,0 +1,30 @@ +#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; +}; + +#endif diff --git a/arm9/lib/include/math.h b/arm9/lib/include/math.h new file mode 100644 index 00000000..80d7cc26 --- /dev/null +++ b/arm9/lib/include/math.h @@ -0,0 +1,8 @@ +#ifndef GUARD_LIBMATH_H +#define GUARD_LIBMATH_H + +#include "MATH.h" +#include "MATH_crc.h" +#include "MATH_dgt.h" + +#endif |