siphash24.c revision 933f9caeeb2b3c1b951d330e04beb04226e5a890
/*
SipHash reference C implementation
Written in 2012 by
Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
Daniel J. Bernstein <djb@cr.yp.to>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
(Minimal changes made by Lennart Poettering, to make clean for inclusion in systemd)
(Refactored by Tom Gundersen to split up in several functions and follow systemd
coding style)
*/
#include "sparse-endian.h"
#include "siphash24.h"
#include "unaligned.h"
#include "util.h"
assert(b < 64);
return (x << b) | (x >> (64 - b));
}
}
assert(k);
/* "somepseudorandomlygeneratedbytes" */
}
uint64_t m;
/* update total length */
/* if padding exists, fill it out */
if (left > 0) {
/* we did not have enough input to fill out the padding completely */
return;
#ifdef DEBUG
printf("(%3zu) compress padding %08x %08x\n", state->inlen, (uint32_t) (state->padding >> 32), (uint32_t)state->padding);
#endif
}
m = unaligned_read_le64(in);
#ifdef DEBUG
#endif
}
switch(left)
{
case 0: break;
}
}
uint64_t b;
#ifdef DEBUG
printf("(%3zu) padding %08x %08x\n", state->inlen, (uint32_t) (state->padding >> 32), (uint32_t) state->padding);
#endif
#ifdef DEBUG
#endif
}
/* SipHash-2-4 */
siphash24_init(&state, k);
return siphash24_finalize(&state);
}