mirror of
https://github.com/rdolbeau/VexRiscvBPluginGenerator.git
synced 2025-04-18 18:44:42 -04:00
76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
/*
|
|
* crypto_hashblocks/try.c version 20200406
|
|
* D. J. Bernstein
|
|
* Public domain.
|
|
* Auto-generated by trygen.py; do not edit.
|
|
*/
|
|
|
|
#include "crypto_hashblocks.h"
|
|
#include "try.h"
|
|
|
|
const char *primitiveimplementation = crypto_hashblocks_IMPLEMENTATION;
|
|
|
|
#define TUNE_BYTES 1536
|
|
#ifdef SMALL
|
|
#define MAXTEST_BYTES 128
|
|
#else
|
|
#define MAXTEST_BYTES 4096
|
|
#endif
|
|
#ifdef SMALL
|
|
#define LOOPS 4096
|
|
#else
|
|
#define LOOPS 32768
|
|
#endif
|
|
|
|
static unsigned char *h;
|
|
static unsigned char *m;
|
|
static unsigned char *h2;
|
|
static unsigned char *m2;
|
|
#define hlen crypto_hashblocks_STATEBYTES
|
|
unsigned long long mlen;
|
|
|
|
void preallocate(void)
|
|
{
|
|
}
|
|
|
|
void allocate(void)
|
|
{
|
|
unsigned long long alloclen = 0;
|
|
if (alloclen < TUNE_BYTES) alloclen = TUNE_BYTES;
|
|
if (alloclen < MAXTEST_BYTES) alloclen = MAXTEST_BYTES;
|
|
if (alloclen < crypto_hashblocks_STATEBYTES) alloclen = crypto_hashblocks_STATEBYTES;
|
|
h = alignedcalloc(alloclen);
|
|
m = alignedcalloc(alloclen);
|
|
h2 = alignedcalloc(alloclen);
|
|
m2 = alignedcalloc(alloclen);
|
|
}
|
|
|
|
void predoit(void)
|
|
{
|
|
}
|
|
|
|
void doit(void)
|
|
{
|
|
crypto_hashblocks(h,m,TUNE_BYTES);
|
|
}
|
|
|
|
void test(void)
|
|
{
|
|
unsigned long long loop;
|
|
|
|
for (loop = 0;loop < LOOPS;++loop) {
|
|
mlen = myrandom() % (MAXTEST_BYTES + 1);
|
|
|
|
input_prepare(m2,m,mlen);
|
|
input_prepare(h2,h,hlen);
|
|
if (crypto_hashblocks(h,m,mlen) != mlen % crypto_hashblocks_BLOCKBYTES) fail("crypto_hashblocks returns unexpected value");
|
|
checksum(h,hlen);
|
|
output_compare(h2,h,hlen,"crypto_hashblocks");
|
|
input_compare(m2,m,mlen,"crypto_hashblocks");
|
|
|
|
double_canary(h2,h,hlen);
|
|
double_canary(m2,m,mlen);
|
|
if (crypto_hashblocks(h2,m2,mlen) != mlen % crypto_hashblocks_BLOCKBYTES) fail("crypto_hashblocks returns unexpected value");
|
|
if (memcmp(h2,h,hlen) != 0) fail("crypto_hashblocks is nondeterministic");
|
|
}
|
|
}
|