cosmetics

This commit is contained in:
sagar 2025-07-14 14:18:44 +00:00
parent 8a1f63b557
commit ce06064fcf
3 changed files with 20 additions and 15 deletions

View file

@ -1,8 +1,9 @@
#include <stdio.h>
#include <string.h>
#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]);

View file

@ -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 <stdlib.h>
#include <string.h>
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);
}
}

8
sha0/types.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef TYPES_H
#define TYPES_H
typedef unsigned long long UINT64;
typedef unsigned char UCHAR;
typedef unsigned int UINT;
#endif