-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil.c
More file actions
34 lines (30 loc) · 792 Bytes
/
util.c
File metadata and controls
34 lines (30 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "util.h"
#include "crypto/hash/hmac-sha1.h"
#include "crypto/enc/rc4.h"
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
char* hex_to_char(const char* hex, int len) {
char *_a = malloc(len / 2);
int num = 0;
unsigned _b;
while(num < len) {
sscanf(&hex[num], "%02X", &_b);
_a[num/2] = _b;
num += 2;
}
return _a;
}
/*
* HMAC SHA1, Takes a cpu key and hashes the hmac_key, outputs digest.
*/
unsigned char* HMAC_SHA1(char* cpukey, unsigned char* hmac_key) {
unsigned char* digest = malloc(16);
//digest = HMAC(EVP_sha1(), cpukey, 16, hmac_key, 16, NULL, NULL);
HMAC_SHA1_Hash(cpukey, hmac_key, digest, 16);
return digest;
}