hash.cpp 1023 Bytes
Newer Older
lwc-tester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/*
Implementation by Ronny Van Keer, hereby denoted as "the implementer".

For more information, feedback or questions, please refer to our website:
https://keccak.team/

To the extent possible under law, the implementer has waived all copyright
and related or neighboring rights to the source code in this file.
http://creativecommons.org/publicdomain/zero/1.0/
*/

#include "crypto_hash.h"

#ifndef crypto_hash_BYTES
    #define crypto_hash_BYTES 32
#endif

#include "Xoodyak.h"

int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
{
	Xoodyak	instance = Xoodyak(BitString(), BitString(), BitString());

    instance.Absorb(BitString(in, 8 * (size_t)inlen));
    BitString outString = instance.Squeeze(crypto_hash_BYTES);
    if (outString.size() != 0) std::copy(outString.array(), outString.array() + (outString.size() + 7) / 8, out);
	#if 0
	{
		unsigned int i;
		for (i = 0; i < crypto_hash_BYTES; ++i )
		{
			printf("\\x%02x", out[i] );
		}
		printf("\n");
	}
	#endif
	return 0;
}