diff --git a/sha0/main.c b/sha0/main.c index 6aa82ff..d4bc99f 100644 --- a/sha0/main.c +++ b/sha0/main.c @@ -1,8 +1,9 @@ #include #include +#include "types.h" // Declare the function from sha0.c -void Internal_Sha0(unsigned char *dest, const unsigned char *src, const unsigned int size); +const UCHAR* MY_SHA0_hash(const void* data, int len, UCHAR* digest); #define SHA0_DIGEST_SIZE 20 @@ -12,8 +13,8 @@ int main(int argc, char **argv) { return 1; } - unsigned char digest[SHA0_DIGEST_SIZE]; - Internal_Sha0(digest, (const unsigned char *)argv[1], strlen(argv[1])); + UCHAR digest[SHA0_DIGEST_SIZE]; + MY_SHA0_hash((const UCHAR *)argv[1], strlen(argv[1]), digest); for (int i = 0; i < SHA0_DIGEST_SIZE; i++) { printf("%02x", digest[i]); diff --git a/sha0/sha0.c b/sha0/sha0.c index b1e46b0..37a0ff7 100644 --- a/sha0/sha0.c +++ b/sha0/sha0.c @@ -1,4 +1,10 @@ -// Copied from softether's Encrypt.c +// Copied from softether's src/Cedar/Encrypt.c + +// define custom types as defined in SoftEther's code +#include "types.h" + +// rest is copied as is + ///////////////////////// // SHA0 implementation // ///////////////////////// @@ -34,13 +40,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include -typedef unsigned long long UINT64; -typedef unsigned char UCHAR; -typedef unsigned int UINT; - #define rol(bits, value) (((value) << (bits)) | ((value) >> (32 - (bits)))) typedef struct MY_SHA0_CTX { @@ -144,9 +145,4 @@ const UCHAR* MY_SHA0_hash(const void* data, int len, UCHAR* digest) { MY_SHA0_update(&ctx, data, len); memcpy(digest, MY_SHA0_final(&ctx), MY_SHA0_DIGEST_SIZE); return digest; -} - -void Internal_Sha0(unsigned char *dest, const unsigned char *src, const UINT size) -{ - MY_SHA0_hash(src, (int)size, dest); -} +} \ No newline at end of file diff --git a/sha0/types.h b/sha0/types.h new file mode 100644 index 0000000..4c0523b --- /dev/null +++ b/sha0/types.h @@ -0,0 +1,8 @@ +#ifndef TYPES_H +#define TYPES_H + +typedef unsigned long long UINT64; +typedef unsigned char UCHAR; +typedef unsigned int UINT; + +#endif