Commit ea37ea04 authored by Naga Suramouli's avatar Naga Suramouli
Browse files

update

parent 835ca373
......@@ -9,17 +9,12 @@
#include <stdint.h>
#include <inttypes.h>
#include "../include/cryptocore_ioctl_header.h"
#include "../../include/cryptocore_ioctl_header.h"
/* Prototypes for functions used to access physical memory addresses */
int open_physical (int);
void close_physical (int);
static struct TRNG_params{
__u32 prec;
__u32 rand[128];
};
int main(void)
{
int dd = -1;
......@@ -73,35 +68,194 @@ int main(void)
usleep(10);
struct TRNG_params TRNG_512_test = { 512,
{ } };
PointAdd_params_t PointAdd_128_test = {
128,
1,
0,
{ 0Xc302f41d, 0X932a36cd, 0Xa7a34630, 0X93d18db7,
0X8fce476d, 0Xe1a86297 },
clock_gettime(CLOCK_MONOTONIC, &tstart);
{ 0X6a911740, 0X76b1e0e1, 0X9c39c031, 0Xfe8685c1,
0Xcae040e5, 0Xc69a28ef },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000002 },
{ 0X94ca638a, 0X8bdce263, 0Xb148d879, 0X0903e452,
0X0d231ac9, 0X8ab235d5 },
{ 0X12455450, 0X86d5d78, 0X9df21c74, 0X4a7e338c,
0Xdd600479, 0Xab9c2505a },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001 },
{ 0X1f9c95e, 0X15f6e085, 0X4bb65761, 0X970b3bb3,
0X76e40c64, 0Xcd71602ad},
{ 0X449fd07e, 0X30fcbd45, 0Xfdc80787, 0X2f471400,
0Xb344852f, 0X60a06323 },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001 },
{ },
{ },
{ },
};
// Read TRNG FIRO
for(i=0; i<TRNG_512_test.prec/32; i++){
ret_val = ioctl(dd, IOCTL_READ_TRNG_FIFO, &trng_val);
if(ret_val == 0) {
TRNG_512_test.rand[i] = trng_val;
} else{
printf("Error occured\n");
}
printf("X3_addition: 0x");
for(i=0; i<PointAdd_128_test.prec/32; i++){
printf("%08x", PointAdd_128_test.XA[i]);
}
printf("\n\n");
printf("Y3_addition: 0x");
for(i=0; i<PointAdd_128_test.prec/32; i++){
printf("%08x", PointAdd_128_test.YA[i]);
}
printf("\n\n");
printf("Z3_addition: 0x");
for(i=0; i<PointAdd_128_test.prec/32; i++){
printf("%08x", PointAdd_128_test.ZA[i]);
}
printf("\n\n");
clock_gettime(CLOCK_MONOTONIC, &tstart);
ret_val = ioctl(dd, IOCTL_MWMAC_PointAdd, &PointAdd_128_test);
if(ret_val != 0) {
printf("Error occured\n");
}
clock_gettime(CLOCK_MONOTONIC, &tend);
// printf("ans = PointAdd(A,B,N,C): 0x");
//for(i=0; i<PointAdd_128_test.prec/32; i++){
// printf("%08x", PointAdd_128_test.answer[i]);
//}
//printf("\n\n");
seconds = ((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec);
if (seconds*1000000.0 > 1000.0)
printf("PointAdd func 128 took about %.5f ms\n\n", seconds*1000.0);
else
printf("PointAdd func 128 took about %.5f us\n\n", seconds*1000000.0);
// Clear c
for(i=0; i<PointAdd_128_test.prec/32; i++){
PointAdd_128_test.X3[i] = 0;
}
for(i=0; i<PointAdd_128_test.prec/32; i++){
PointAdd_128_test.Y3[i] = 0;
}
for(i=0; i<PointAdd_128_test.prec/32; i++){
PointAdd_128_test.Z3[i] = 0;
}
PointAdd_128_test.sec_calc = 1;
clock_gettime(CLOCK_MONOTONIC, &tstart);
ret_val = ioctl(dd, IOCTL_MWMAC_PointAdd, &PointAdd_128_test);
if(ret_val != 0) {
printf("Error occured\n");
}
clock_gettime(CLOCK_MONOTONIC, &tend);
printf("rand: ");
for(i=0; i<TRNG_512_test.prec/32; i++){
printf("%08x", TRNG_512_test.rand[i]);
PointDoub_params_t PointDoub_128_test = {
128,
1,
0,
{ 0Xc302f41d, 0X932a36cd, 0Xa7a34630, 0X93d18db7,
0X8fce476d, 0Xe1a86297 },
{ 0X6a911740, 0X76b1e0e1, 0X9c39c031, 0Xfe8685c1,
0Xcae040e5, 0Xc69a28ef },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000002 },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000003 },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000008 },
{ 0X94ca638a, 0X8bdce263, 0Xb148d879, 0X0903e452,
0X0d231ac9, 0X8ab235d5 },
{ 0X12455450, 0X86d5d78, 0X9df21c74, 0X4a7e338c,
0Xdd600479, 0Xab9c2505a },
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001 },
{ },
{ },
{ },
};
printf("X3D: 0x");
for(i=0; i<PointDoub_128_test.prec/32; i++){
printf("%08x", PointDoub_128_test.X3[i]);
}
printf("\n\n");
printf("Y3D: 0x");
for(i=0; i<PointDoub_128_test.prec/32; i++){
printf("%08x", PointDoub_128_test.Y3[i]);
}
printf("\n\n");
printf("Z3D: 0x");
for(i=0; i<PointDoub_128_test.prec/32; i++){
printf("%08x", PointDoub_128_test.Z3[i]);
}
printf("\n\n");
clock_gettime(CLOCK_MONOTONIC, &tstart);
ret_val = ioctl(dd, IOCTL_MWMAC_PointDoub, &PointDoub_128_test);
if(ret_val != 0) {
printf("Error occured\n");
}
clock_gettime(CLOCK_MONOTONIC, &tend);
seconds = ((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec);
if (seconds*1000000.0 > 1000.0)
printf("Reading 512 random bits took about %.5f ms\n", seconds*1000.0);
printf("PointDoub func 128 took about %.5f ms\n\n", seconds*1000.0);
else
printf("Reading 512 random bits took about %.5f us\n", seconds*1000000.0);
printf("PointDoub func 128 took about %.5f us\n\n", seconds*1000000.0);
// Clear c
for(i=0; i<PointDoub_128_test.prec/32; i++){
PointDoub_128_test.X3[i] = 0;
}
for(i=0; i<PointDoub_128_test.prec/32; i++){
PointDoub_128_test.Y3[i] = 0;
}
for(i=0; i<PointDoub_128_test.prec/32; i++){
PointDoub_128_test.Z3[i] = 0;
}
PointDoub_128_test.sec_calc = 1;
clock_gettime(CLOCK_MONOTONIC, &tstart);
ret_val = ioctl(dd, IOCTL_MWMAC_PointDoub, &PointDoub_128_test);
if(ret_val != 0) {
printf("Error occured\n");
}
clock_gettime(CLOCK_MONOTONIC, &tend);
seconds = ((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec);
if (seconds*1000000.0 > 1000.0)
printf("MontMult 128 (sec calc) took about %.5f ms\n\n", seconds*1000.0);
else
printf("MontMult 128 (sec calc) took about %.5f us\n\n", seconds*1000000.0);
close_physical (dd); // close /dev/cryptocore
return 0;
}
......@@ -118,8 +272,8 @@ int open_physical (int dd)
return dd;
}
// Close /dev/mem to give access to physical addresses
// Close /dev/cryptocore to give access to physical addresses
void close_physical (int dd)
{
close (dd);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment