mirror of
https://github.com/pret/pmd-sky.git
synced 2026-09-29 05:41:47 -05:00
move more files to src
This commit is contained in:
19
lib/include/nitro/dgt/common.h
Normal file
19
lib/include/nitro/dgt/common.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef NITRO_DGT_COMMON_H_
|
||||
#define NITRO_DGT_COMMON_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DGT_HASH1_DIGEST_SIZE (128 / 8)
|
||||
#define DGT_HASH2_DIGEST_SIZE (160 / 8)
|
||||
|
||||
#define DGT_HASH_DIGEST_SIZE_MAX DGT_HASH2_DIGEST_SIZE
|
||||
|
||||
#define DGT_HASH_BLOCK_SIZE (512 / 8)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
77
lib/include/nitro/dgt/dgt.h
Normal file
77
lib/include/nitro/dgt/dgt.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef NITRO_DGT_DGT_H_
|
||||
#define NITRO_DGT_DGT_H_
|
||||
|
||||
#include <nitro/dgt/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef 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];
|
||||
};
|
||||
} DGTHash1Context;
|
||||
|
||||
#if defined(SDK_DGT_HASH2_CODE_SAFE) || defined(SDK_WIN32) || defined(SDK_FROM_TOOL)
|
||||
typedef 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;
|
||||
} DGTHash2Context;
|
||||
#else
|
||||
typedef struct DGTHash2Context {
|
||||
unsigned long h0, h1, h2, h3, h4;
|
||||
unsigned long Nl, Nh;
|
||||
int num;
|
||||
unsigned long data[64 / 4];
|
||||
int dummy[2];
|
||||
} DGTHash2Context;
|
||||
#endif
|
||||
|
||||
#ifdef SDK_DGT_HASH1_CODE_SAFE
|
||||
void DGT_Hash1Reset(DGTHash1Context *);
|
||||
void DGT_Hash1SetSource(DGTHash1Context *, unsigned char *, unsigned long);
|
||||
void DGT_Hash1GetDigest_R(unsigned char digest[16], DGTHash1Context *);
|
||||
#else
|
||||
void DGT_Hash1Reset(DGTHash1Context *);
|
||||
void DGT_Hash1SetSource(DGTHash1Context *, const void *, unsigned long);
|
||||
void DGT_Hash1GetDigest_R(void * digest, DGTHash1Context *);
|
||||
#endif
|
||||
|
||||
#if defined(SDK_DGT_HASH2_CODE_SAFE) || defined(SDK_WIN32) || defined(SDK_FROM_TOOL)
|
||||
void DGT_Hash2Reset(DGTHash2Context *);
|
||||
void DGT_Hash2SetSource(DGTHash2Context *, unsigned char *, unsigned long);
|
||||
void DGT_Hash2GetDigest(DGTHash2Context *, unsigned char digest[20]);
|
||||
#else
|
||||
void DGT_Hash2Reset(DGTHash2Context *);
|
||||
void DGT_Hash2SetSource(DGTHash2Context *, const unsigned char *, unsigned long);
|
||||
void DGT_Hash2GetDigest(DGTHash2Context *, unsigned char * digest);
|
||||
#endif
|
||||
|
||||
void DGT_Hash1CalcHmac(void * digest, void * bin_ptr, int bin_len, void * key_ptr, int key_len);
|
||||
void DGT_Hash2CalcHmac(void * digest, void * bin_ptr, int bin_len, void * key_ptr, int key_len);
|
||||
|
||||
int DGT_Hash1CalcHmacForRms(void * digest, void * romh_ptr, int romh_len, void * mbin_ptr, int mbin_len, void * sbin_ptr, int sbin_len, void * key_ptr, int key_len);
|
||||
int DGT_Hash2CalcHmacForRms(void * digest, void * romh_ptr, int romh_len, void * mbin_ptr, int mbin_len, void * sbin_ptr, int sbin_len, void * key_ptr, int key_len);
|
||||
int DGT_Hash1TestHmacForRms(void * digest, void * romh_ptr, int romh_len, void * mbin_ptr, int mbin_len, void * sbin_ptr, int sbin_len, void * key_ptr, int key_len);
|
||||
int DGT_Hash2TestHmacForRms(void * digest, void * romh_ptr, int romh_len, void * mbin_ptr, int mbin_len, void * sbin_ptr, int sbin_len, void * key_ptr, int key_len);
|
||||
int DGT_SetOverlayTableMode(int flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -3,5 +3,7 @@
|
||||
|
||||
u8 Math_CountPopulation (u32 x);
|
||||
|
||||
#include <nitro/math/dgt.h>
|
||||
|
||||
#endif //NITRO_MATH_H_
|
||||
|
||||
|
||||
79
lib/include/nitro/math/dgt.h
Normal file
79
lib/include/nitro/math/dgt.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef NITRO_MATH_DGT_H_
|
||||
#define NITRO_MATH_DGT_H_
|
||||
|
||||
#include <nitro/misc.h>
|
||||
#include <nitro/types.h>
|
||||
#include <nitro/dgt/common.h>
|
||||
#include <nitro/dgt/dgt.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MATH_MD5_DIGEST_SIZE DGT_HASH1_DIGEST_SIZE
|
||||
#define MATH_SHA1_DIGEST_SIZE DGT_HASH2_DIGEST_SIZE
|
||||
|
||||
#define MATH_MD5_BLOCK_SIZE DGT_HASH_BLOCK_SIZE
|
||||
#define MATH_SHA1_BLOCK_SIZE DGT_HASH_BLOCK_SIZE
|
||||
|
||||
typedef DGTHash1Context MATHMD5Context;
|
||||
typedef 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);
|
||||
|
||||
static inline void MATH_CalcHMACMD5 (void * digest, const void * data, u32 dataLength, const void * key, u32 keyLength)
|
||||
{
|
||||
DGT_Hash1CalcHmac(digest, (void *)data, (int)dataLength, (void *)key, (int)keyLength);
|
||||
}
|
||||
|
||||
static inline void MATH_CalcHMACSHA1 (void * digest, const void * data, u32 dataLength, const void * key, u32 keyLength)
|
||||
{
|
||||
DGT_Hash2CalcHmac(digest, (void *)data, (int)dataLength, (void *)key, (int)keyLength);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user