Blame SOURCES/libsodium-1.0.18/test/default/siphashx24.c

rdobuilder 775784
rdobuilder 775784
#define TEST_NAME "siphashx24"
rdobuilder 775784
#include "cmptest.h"
rdobuilder 775784
rdobuilder 775784
#define MAXLEN 64
rdobuilder 775784
rdobuilder 775784
int
rdobuilder 775784
main(void)
rdobuilder 775784
{
rdobuilder 775784
    unsigned char in[MAXLEN];
rdobuilder 775784
    unsigned char out[crypto_shorthash_siphashx24_BYTES];
rdobuilder 775784
    unsigned char k[crypto_shorthash_siphashx24_KEYBYTES];
rdobuilder 775784
    size_t        i;
rdobuilder 775784
    size_t        j;
rdobuilder 775784
rdobuilder 775784
    for (i = 0; i < crypto_shorthash_siphashx24_KEYBYTES; ++i) {
rdobuilder 775784
        k[i] = (unsigned char) i;
rdobuilder 775784
    }
rdobuilder 775784
    for (i = 0; i < MAXLEN; ++i) {
rdobuilder 775784
        in[i] = (unsigned char) i;
rdobuilder 775784
        crypto_shorthash_siphashx24(out, in, (unsigned long long) i, k);
rdobuilder 775784
        for (j = 0; j < crypto_shorthash_siphashx24_BYTES; ++j) {
rdobuilder 775784
            printf("%02x", (unsigned int) out[j]);
rdobuilder 775784
        }
rdobuilder 775784
        printf("\n");
rdobuilder 775784
    }
rdobuilder 775784
    assert(crypto_shorthash_siphashx24_KEYBYTES >= crypto_shorthash_siphash24_KEYBYTES);
rdobuilder 775784
    assert(crypto_shorthash_siphashx24_BYTES > crypto_shorthash_siphash24_BYTES);
rdobuilder 775784
    assert(crypto_shorthash_siphashx24_bytes() == crypto_shorthash_siphashx24_BYTES);
rdobuilder 775784
    assert(crypto_shorthash_siphashx24_keybytes() == crypto_shorthash_siphashx24_KEYBYTES);
rdobuilder 775784
rdobuilder 775784
    return 0;
rdobuilder 775784
}