mirror of https://github.com/D4-project/d4-core
initialize hmac computations
parent
82c67a4b31
commit
8e00adae42
|
@ -1,2 +1,5 @@
|
|||
d4: d4.c
|
||||
gcc -Wall -o d4 d4.c -luuid
|
||||
d4: d4.o others/hmac/sha2.o others/hmac/hmac.o
|
||||
gcc -Wall -o d4 d4.o others/hmac/hmac.o others/hmac/sha2.o -luuid
|
||||
|
||||
d4.o: d4.c
|
||||
gcc -Wall -c d4.c
|
||||
|
|
|
@ -143,6 +143,12 @@ void d4_prepare_header(d4_t* d4)
|
|||
}
|
||||
// If UUID cannot be parsed it is set to 0
|
||||
d4->header.type = atoi(d4->conf[TYPE]);
|
||||
|
||||
d4->ctx = calloc(sizeof(hmac_sha256_ctx),1);
|
||||
if (d4->ctx) {
|
||||
//FIXME check cast of the key
|
||||
hmac_sha256_init(d4->ctx, (uint8_t*)d4->conf[KEY], strlen(d4->conf[KEY]));
|
||||
}
|
||||
}
|
||||
|
||||
void d4_update_header(d4_t* d4, ssize_t nread) {
|
||||
|
@ -150,7 +156,6 @@ void d4_update_header(d4_t* d4, ssize_t nread) {
|
|||
bzero(&tv,sizeof(struct timeval));
|
||||
gettimeofday(&tv,NULL);
|
||||
d4->header.timestamp = tv.tv_sec;
|
||||
//TODO hmac
|
||||
d4->header.size=nread;
|
||||
}
|
||||
|
||||
|
@ -172,6 +177,7 @@ void d4_transfert(d4_t* d4)
|
|||
nread = read(d4->source.fd, buf, d4->snaplen);
|
||||
if ( nread > 0 ) {
|
||||
d4_update_header(d4, nread);
|
||||
//TODO hmac header and payload
|
||||
write(d4->destination.fd, &d4->header, sizeof(d4->header));
|
||||
write(d4->destination.fd,buf,nread);
|
||||
} else{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef D4_H
|
||||
#define D4_H
|
||||
|
||||
#include "others/hmac/hmac_sha2.h"
|
||||
|
||||
#define ND4PARAMS 7
|
||||
#define NERRORS 100
|
||||
#define SZCONFVALUE 1024
|
||||
|
@ -49,6 +51,7 @@ typedef struct d4_s {
|
|||
char errors[NERRORS][SZERRVALUE];
|
||||
int err_idx;
|
||||
d4_header_t header;
|
||||
hmac_sha256_ctx *ctx;
|
||||
} d4_t;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue