diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-13 10:09:38 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-13 10:09:38 -0400 |
commit | d4fe483efd3e0062f12430efe9deb66d43d914d7 (patch) | |
tree | e6aa9ac716ae82cdb15c6e6cb5d9d1d9d29f053b /nacl/crypto_stream/measure.c | |
parent | 835ef0320d47372eac14bef31c979b8217d04498 (diff) |
NaCl moved to other repo.
Diffstat (limited to 'nacl/crypto_stream/measure.c')
-rw-r--r-- | nacl/crypto_stream/measure.c | 73 |
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 | |||
6 | extern void printentry(long long,const char *,long long *,long long); | ||
7 | extern unsigned char *alignedcalloc(unsigned long long); | ||
8 | extern const char *primitiveimplementation; | ||
9 | extern const char *implementationversion; | ||
10 | extern const char *sizenames[]; | ||
11 | extern const long long sizes[]; | ||
12 | extern void allocate(void); | ||
13 | extern void measure(void); | ||
14 | |||
15 | const char *primitiveimplementation = crypto_stream_IMPLEMENTATION; | ||
16 | const char *implementationversion = crypto_stream_VERSION; | ||
17 | const char *sizenames[] = { "keybytes", "noncebytes", 0 }; | ||
18 | const 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 | |||
27 | static unsigned char *k; | ||
28 | static unsigned char *n; | ||
29 | static unsigned char *m; | ||
30 | static unsigned char *c; | ||
31 | |||
32 | void preallocate(void) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | void 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 | ||
45 | static long long cycles[TIMINGS + 1]; | ||
46 | |||
47 | void 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 | } | ||