2 #include "randombytes.h"
4 #include "crypto_hash.h"
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);
15 const char *primitiveimplementation
= crypto_hash_IMPLEMENTATION
;
16 const char *implementationversion
= crypto_hash_VERSION
;
17 const char *sizenames
[] = { "outputbytes", 0 };
18 const long long sizes
[] = { crypto_hash_BYTES
};
20 #define MAXTEST_BYTES 4096
27 static unsigned char *h
;
28 static unsigned char *m
;
30 void preallocate(void)
36 h
= alignedcalloc(crypto_hash_BYTES
);
37 m
= alignedcalloc(MAXTEST_BYTES
);
41 static long long cycles
[TIMINGS
+ 1];
43 static void printcycles(long long mlen
)
46 for (i
= 0;i
< TIMINGS
;++i
) cycles
[i
] = cycles
[i
+ 1] - cycles
[i
];
47 printentry(mlen
,"cycles",cycles
,TIMINGS
);
56 for (loop
= 0;loop
< LOOPS
;++loop
) {
57 for (mlen
= 0;mlen
<= MAXTEST_BYTES
;mlen
+= 1 + mlen
/ MGAP
) {
59 for (i
= 0;i
<= TIMINGS
;++i
) {
60 cycles
[i
] = cpucycles();
61 crypto_hash(h
,m
,mlen
);