clang-format

This commit is contained in:
Kelvin Sherlock 2017-04-08 15:43:38 -04:00
parent 7c5fef9b71
commit 6f6e2d30a8

View File

@ -27,8 +27,7 @@
#ifdef LTC_BLAKE2B
enum blake2b_constant
{
enum blake2b_constant {
BLAKE2B_BLOCKBYTES = 128,
BLAKE2B_OUTBYTES = 64,
BLAKE2B_KEYBYTES = 64,
@ -36,9 +35,7 @@
BLAKE2B_PERSONALBYTES = 16
};
struct blake2b_param
{
struct blake2b_param {
unsigned char digest_length;
unsigned char key_length;
unsigned char fanout;
@ -138,21 +135,15 @@ static const unsigned char blake2b_sigma[12][16] =
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
};
static void blake2b_set_lastnode( hash_state *md )
{
md->blake2b.f[1] = CONST64(0xffffffffffffffff);
}
static void blake2b_set_lastnode(hash_state *md) { md->blake2b.f[1] = CONST64(0xffffffffffffffff); }
/* Some helper functions, not necessarily useful */
static int blake2b_is_lastblock( const hash_state *md )
{
return md->blake2b.f[0] != 0;
}
static int blake2b_is_lastblock(const hash_state *md) { return md->blake2b.f[0] != 0; }
static void blake2b_set_lastblock(hash_state *md)
{
if( md->blake2b.last_node ) blake2b_set_lastnode( md );
if (md->blake2b.last_node)
blake2b_set_lastnode(md);
md->blake2b.f[0] = CONST64(0xffffffffffffffff);
}
@ -168,7 +159,8 @@ static void blake2b_init0( hash_state *md )
unsigned long i;
XMEMSET(&md->blake2b, 0, sizeof(md->blake2b));
for( i = 0; i < 8; ++i ) md->blake2b.h[i] = blake2b_IV[i];
for (i = 0; i < 8; ++i)
md->blake2b.h[i] = blake2b_IV[i];
}
/* init xors IV with input parameter block */
@ -190,8 +182,6 @@ int blake2b_init_param( hash_state *md, const struct blake2b_param *P )
return CRYPT_OK;
}
int blake2b_init(hash_state *md, unsigned long outlen)
{
struct blake2b_param P;
@ -217,9 +207,6 @@ int blake2b_384_init(hash_state *md) { return blake2b_init(md, 48); }
int blake2b_512_init(hash_state *md) { return blake2b_init(md, 64); }
#define G(r, i, a, b, c, d) \
do { \
a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \
@ -305,17 +292,16 @@ static int blake2b_compress(hash_state *md, const unsigned char *buf)
int blake2b_process(hash_state *md, const unsigned char *in, unsigned long inlen)
{
if( inlen > 0 )
{
if (inlen > 0) {
unsigned long left = md->blake2b.curlen;
unsigned long fill = BLAKE2B_BLOCKBYTES - left;
if( inlen > fill )
{
if (inlen > fill) {
md->blake2b.curlen = 0;
XMEMCPY(md->blake2b.buf + left, in, fill); /* Fill buffer */
blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
blake2b_compress(md, md->blake2b.buf); /* Compress */
in += fill; inlen -= fill;
in += fill;
inlen -= fill;
while (inlen > BLAKE2B_BLOCKBYTES) {
blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
blake2b_compress(md, in);
@ -339,7 +325,6 @@ int blake2b_done( hash_state *md, unsigned char *out)
/* if(md->blakebs.outlen != outlen) return CRYPT_INVALID_ARG; */
if (blake2b_is_lastblock(md))
return CRYPT_ERROR;
@ -359,7 +344,6 @@ int blake2b_done( hash_state *md, unsigned char *out)
return CRYPT_OK;
}
/**
Self-test the hash
@return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled
@ -542,5 +526,4 @@ int blake2b_160_test(void)
#endif
}
#endif