summaryrefslogtreecommitdiff
path: root/nacl/crypto_stream/measure.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-13 10:09:38 -0400
committerirungentoo <irungentoo@gmail.com>2013-07-13 10:09:38 -0400
commitd4fe483efd3e0062f12430efe9deb66d43d914d7 (patch)
treee6aa9ac716ae82cdb15c6e6cb5d9d1d9d29f053b /nacl/crypto_stream/measure.c
parent835ef0320d47372eac14bef31c979b8217d04498 (diff)
NaCl moved to other repo.
Diffstat (limited to 'nacl/crypto_stream/measure.c')
-rw-r--r--nacl/crypto_stream/measure.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/nacl/crypto_stream/measure.c b/nacl/crypto_stream/measure.c
deleted file mode 100644
index ff3ab610..00000000
--- a/nacl/crypto_stream/measure.c
+++ /dev/null
@@ -1,73 +0,0 @@
1#include <stdlib.h>
2#include "randombytes.h"
3#include "cpucycles.h"
4#include "crypto_stream.h"
5
6extern void printentry(long long,const char *,long long *,long long);
7extern unsigned char *alignedcalloc(unsigned long long);
8extern const char *primitiveimplementation;
9extern const char *implementationversion;
10extern const char *sizenames[];
11extern const long long sizes[];
12extern void allocate(void);
13extern void measure(void);
14
15const char *primitiveimplementation = crypto_stream_IMPLEMENTATION;
16const char *implementationversion = crypto_stream_VERSION;
17const char *sizenames[] = { "keybytes", "noncebytes", 0 };
18const long long sizes[] = { crypto_stream_KEYBYTES, crypto_stream_NONCEBYTES };
19
20#define MAXTEST_BYTES 4096
21#ifdef SUPERCOP
22#define MGAP 8192
23#else
24#define MGAP 8
25#endif
26
27static unsigned char *k;
28static unsigned char *n;
29static unsigned char *m;
30static unsigned char *c;
31
32void preallocate(void)
33{
34}
35
36void allocate(void)
37{
38 k = alignedcalloc(crypto_stream_KEYBYTES);
39 n = alignedcalloc(crypto_stream_NONCEBYTES);
40 m = alignedcalloc(MAXTEST_BYTES);
41 c = alignedcalloc(MAXTEST_BYTES);
42}
43
44#define TIMINGS 15
45static long long cycles[TIMINGS + 1];
46
47void measure(void)
48{
49 int i;
50 int loop;
51 int mlen;
52
53 for (loop = 0;loop < LOOPS;++loop) {
54 for (mlen = 0;mlen <= MAXTEST_BYTES;mlen += 1 + mlen / MGAP) {
55 randombytes(k,crypto_stream_KEYBYTES);
56 randombytes(n,crypto_stream_NONCEBYTES);
57 randombytes(m,mlen);
58 randombytes(c,mlen);
59 for (i = 0;i <= TIMINGS;++i) {
60 cycles[i] = cpucycles();
61 crypto_stream(c,mlen,n,k);
62 }
63 for (i = 0;i < TIMINGS;++i) cycles[i] = cycles[i + 1] - cycles[i];
64 printentry(mlen,"cycles",cycles,TIMINGS);
65 for (i = 0;i <= TIMINGS;++i) {
66 cycles[i] = cpucycles();
67 crypto_stream_xor(c,m,mlen,n,k);
68 }
69 for (i = 0;i < TIMINGS;++i) cycles[i] = cycles[i + 1] - cycles[i];
70 printentry(mlen,"xor_cycles",cycles,TIMINGS);
71 }
72 }
73}