File: speed_des.c

package info (click to toggle)
cryptgps 0.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 292 kB
  • ctags: 420
  • sloc: ml: 2,627; sh: 180; ansic: 172; makefile: 120
file content (35 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (5)
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
35
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include "des.h"



main () {
    des_key_schedule k;
    unsigned char in[1024*1024];
    unsigned char out[1024*1024];
    unsigned char ivec[8];
    int i;
    struct timeval tv;
    double t1,t2;

    des_set_key("abcdefgh",k);


    /* CBC TEST */
    

    for (i=0; i<8; i++) ivec[i] = 0;
    for (i=0; i<1024*1024; i++) in[i] = ' ';

    gettimeofday(&tv, NULL);
    t1 = tv.tv_sec + tv.tv_usec * 1E-6;

    des_cbc_encrypt(in, out, 1024*1024, k, ivec, 1);

    gettimeofday(&tv, NULL);
    t2 = tv.tv_sec + tv.tv_usec * 1E-6;

    printf("%f\n", t2-t1);
}