Initalk commit.
FossilOrigin-Name: 149a31d217702281fa2edf5544d87217e317853d6546be83c8e87531fecedadf
This commit is contained in:
parent
56837e0984
commit
8fad2b38ed
11
src/capwap/capwap_crypto.h
Normal file
11
src/capwap/capwap_crypto.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __CAPWAP_CRYPTO_H
|
||||
#define __CAPWAP_CRYPTO_H
|
||||
|
||||
#include <nettle/md5.h>
|
||||
|
||||
#define CW_MD5_DIGEST_SIZE MD5_DIGEST_SIZE
|
||||
|
||||
int cw_fgetmd5sum(uint8_t *digest, FILE *infile);
|
||||
|
||||
|
||||
#endif
|
30
src/capwap/md5sum.c
Normal file
30
src/capwap/md5sum.c
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nettle/md5.h>
|
||||
|
||||
#include "capwap_crypto.h"
|
||||
|
||||
|
||||
#define BLOCK_SIZE 4096
|
||||
|
||||
|
||||
int cw_fgetmd5sum(uint8_t *digest, FILE *infile)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
uint8_t buffer[BLOCK_SIZE];
|
||||
md5_init(&ctx);
|
||||
|
||||
while (!feof(infile)){
|
||||
int bytes = fread(buffer,1,sizeof(buffer),infile);
|
||||
md5_update(&ctx,bytes,buffer);
|
||||
}
|
||||
|
||||
if (ferror(infile))
|
||||
return errno;
|
||||
|
||||
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user