cosmetics
This commit is contained in:
parent
8a1f63b557
commit
ce06064fcf
3 changed files with 20 additions and 15 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
// Declare the function from sha0.c
|
// 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
|
#define SHA0_DIGEST_SIZE 20
|
||||||
|
|
||||||
|
|
@ -12,8 +13,8 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char digest[SHA0_DIGEST_SIZE];
|
UCHAR digest[SHA0_DIGEST_SIZE];
|
||||||
Internal_Sha0(digest, (const unsigned char *)argv[1], strlen(argv[1]));
|
MY_SHA0_hash((const UCHAR *)argv[1], strlen(argv[1]), digest);
|
||||||
|
|
||||||
for (int i = 0; i < SHA0_DIGEST_SIZE; i++) {
|
for (int i = 0; i < SHA0_DIGEST_SIZE; i++) {
|
||||||
printf("%02x", digest[i]);
|
printf("%02x", digest[i]);
|
||||||
|
|
|
||||||
20
sha0/sha0.c
20
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 //
|
// SHA0 implementation //
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
@ -34,13 +40,8 @@
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.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))))
|
#define rol(bits, value) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||||
|
|
||||||
typedef struct MY_SHA0_CTX {
|
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);
|
MY_SHA0_update(&ctx, data, len);
|
||||||
memcpy(digest, MY_SHA0_final(&ctx), MY_SHA0_DIGEST_SIZE);
|
memcpy(digest, MY_SHA0_final(&ctx), MY_SHA0_DIGEST_SIZE);
|
||||||
return digest;
|
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
8
sha0/types.h
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue