From 02eb90375d9975252647ac285d0ba9fa61435640 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 27 May 2010 12:32:28 +0200 Subject: Added data functionality and a test program. --- examples/Makefile | 6 ++- examples/cipher.c | 2 +- examples/hmac.c | 2 +- examples/new.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 examples/new.c (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 601fb07..3190c4a 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,12 +1,14 @@ KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build -hostprogs := cipher hmac +hostprogs := cipher hmac new example-cipher-objs := cipher.o example-hmac-objs := hmac.o +new-objs := new.o check: $(hostprogs) + ./new ./cipher ./hmac clean: - rm -f *.o *~ hmac cipher + rm -f *.o *~ hmac cipher new diff --git a/examples/cipher.c b/examples/cipher.c index d7982ae..c7ce2c2 100644 --- a/examples/cipher.c +++ b/examples/cipher.c @@ -10,7 +10,7 @@ #include #include -#include +#include "../cryptodev.h" #define DATA_SIZE 4096 #define BLOCK_SIZE 16 diff --git a/examples/hmac.c b/examples/hmac.c index 9975792..9757f90 100644 --- a/examples/hmac.c +++ b/examples/hmac.c @@ -10,7 +10,7 @@ #include #include -#include +#include "../cryptodev.h" #define DATA_SIZE 4096 #define BLOCK_SIZE 16 diff --git a/examples/new.c b/examples/new.c new file mode 100644 index 0000000..60f9437 --- /dev/null +++ b/examples/new.c @@ -0,0 +1,126 @@ +/* + * Demo on how to use /dev/crypto device for HMAC. + * + * Placed under public domain. + * + */ +#include +#include +#include +#include + +#include +#include "../ncr.h" +#include + +#define DATA_SIZE 4096 + +static void randomize_data(uint8_t * data, size_t data_size) +{ +int i; + + srand(time(0)*getpid()); + for (i=0;i