1 #include "crypto_onetimeauth.h"
2 #include "randombytes.h"
5 extern void printentry(long long,const char *,long long *,long long);
6 extern unsigned char *alignedcalloc(unsigned long long);
7 extern const char *primitiveimplementation
;
8 extern const char *implementationversion
;
9 extern const char *sizenames
[];
10 extern const long long sizes
[];
11 extern void allocate(void);
12 extern void measure(void);
14 const char *primitiveimplementation
= crypto_onetimeauth_IMPLEMENTATION
;
15 const char *implementationversion
= crypto_onetimeauth_VERSION
;
16 const char *sizenames
[] = { "outputbytes", "keybytes", 0 };
17 const long long sizes
[] = { crypto_onetimeauth_BYTES
, crypto_onetimeauth_KEYBYTES
};
19 #define MAXTEST_BYTES 4096
26 static unsigned char *k
;
27 static unsigned char *m
;
28 static unsigned char *h
;
30 void preallocate(void)
36 k
= alignedcalloc(crypto_onetimeauth_KEYBYTES
);
37 m
= alignedcalloc(MAXTEST_BYTES
);
38 h
= alignedcalloc(crypto_onetimeauth_BYTES
);
42 static long long cycles
[TIMINGS
+ 1];
50 for (loop
= 0;loop
< LOOPS
;++loop
) {
51 for (mlen
= 0;mlen
<= MAXTEST_BYTES
;mlen
+= 1 + mlen
/ MGAP
) {
52 randombytes(k
,crypto_onetimeauth_KEYBYTES
);
54 randombytes(h
,crypto_onetimeauth_BYTES
);
55 for (i
= 0;i
<= TIMINGS
;++i
) {
56 cycles
[i
] = cpucycles();
57 crypto_onetimeauth(h
,m
,mlen
,k
);
59 for (i
= 0;i
< TIMINGS
;++i
) cycles
[i
] = cycles
[i
+ 1] - cycles
[i
];
60 printentry(mlen
,"cycles",cycles
,TIMINGS
);
61 for (i
= 0;i
<= TIMINGS
;++i
) {
62 cycles
[i
] = cpucycles();
63 crypto_onetimeauth_verify(h
,m
,mlen
,k
);
65 for (i
= 0;i
< TIMINGS
;++i
) cycles
[i
] = cycles
[i
+ 1] - cycles
[i
];
66 printentry(mlen
,"verify_cycles",cycles
,TIMINGS
);