1
1
mirror of https://github.com/BLAKE2/BLAKE2 synced 2024-11-26 04:26:12 +01:00

replace some c99isms

This commit is contained in:
Samuel Neves 2016-10-11 22:12:43 +01:00
parent cb19577245
commit de31f550f3
6 changed files with 36 additions and 33 deletions

@ -51,8 +51,8 @@ static int blake2sp_init_root( blake2s_state *S, size_t outlen, size_t keylen )
P->fanout = PARALLELISM_DEGREE;
P->depth = 2;
store32( &P->leaf_length, 0 );
store32( &P->node_offset, 0ULL );
store16( &P->xof_length, 0ULL );
store32( &P->node_offset, 0 );
store16( &P->xof_length, 0 );
P->node_depth = 1;
P->inner_length = BLAKE2S_OUTBYTES;
memset( P->salt, 0, sizeof( P->salt ) );

@ -164,11 +164,11 @@ int blake2xb(void *out, size_t outlen, const void *in, size_t inlen, const void
#if defined(BLAKE2XB_SELFTEST)
#include <string.h>
#include "blake2-kat.h"
int main( int argc, char **argv )
int main( void )
{
uint8_t key[BLAKE2B_KEYBYTES];
uint8_t buf[BLAKE2_KAT_LENGTH];
size_t i, step;
size_t i, step, outlen;
for( i = 0; i < BLAKE2B_KEYBYTES; ++i ) {
key[i] = ( uint8_t )i;
@ -182,11 +182,12 @@ int main( int argc, char **argv )
/* (Test of input lengths mostly covered by blake2s tests) */
/* Test simple API */
for( size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
for( outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
{
uint8_t hash[BLAKE2_KAT_LENGTH] = {0};
blake2xb( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2B_KEYBYTES );
if( blake2xb( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2B_KEYBYTES ) < 0 ) {
goto fail;
}
if( 0 != memcmp( hash, blake2xb_keyed_kat[outlen-1], outlen ) )
{
@ -196,7 +197,7 @@ int main( int argc, char **argv )
/* Test streaming API */
for(step = 1; step < BLAKE2B_BLOCKBYTES; ++step) {
for (size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
for (outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
uint8_t hash[BLAKE2_KAT_LENGTH];
blake2xb_state S;
uint8_t * p = buf;

@ -166,7 +166,7 @@ int main( void )
{
uint8_t key[BLAKE2S_KEYBYTES];
uint8_t buf[BLAKE2_KAT_LENGTH];
size_t i, step;
size_t i, step, outlen;
for( i = 0; i < BLAKE2S_KEYBYTES; ++i ) {
key[i] = ( uint8_t )i;
@ -180,10 +180,12 @@ int main( void )
/* (Test of input lengths mostly covered by blake2s tests) */
/* Test simple API */
for( size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
for( outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
{
uint8_t hash[BLAKE2_KAT_LENGTH] = {0};
blake2xs( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2S_KEYBYTES );
if( blake2xs( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2S_KEYBYTES ) < 0 ) {
goto fail;
}
if( 0 != memcmp( hash, blake2xs_keyed_kat[outlen-1], outlen ) )
{
@ -193,7 +195,7 @@ int main( void )
/* Test streaming API */
for(step = 1; step < BLAKE2S_BLOCKBYTES; ++step) {
for (size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
for (outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
uint8_t hash[BLAKE2_KAT_LENGTH];
blake2xs_state S;
uint8_t * p = buf;

@ -164,11 +164,11 @@ int blake2xb(void *out, size_t outlen, const void *in, size_t inlen, const void
#if defined(BLAKE2XB_SELFTEST)
#include <string.h>
#include "blake2-kat.h"
int main( int argc, char **argv )
int main( void )
{
uint8_t key[BLAKE2B_KEYBYTES];
uint8_t buf[BLAKE2_KAT_LENGTH];
size_t i, step;
size_t i, step, outlen;
for( i = 0; i < BLAKE2B_KEYBYTES; ++i ) {
key[i] = ( uint8_t )i;
@ -182,7 +182,7 @@ int main( int argc, char **argv )
/* (Test of input lengths mostly covered by blake2s tests) */
/* Test simple API */
for( size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
for( outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
{
uint8_t hash[BLAKE2_KAT_LENGTH] = {0};
blake2xb( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2B_KEYBYTES );
@ -196,7 +196,7 @@ int main( int argc, char **argv )
/* Test streaming API */
for(step = 1; step < BLAKE2B_BLOCKBYTES; ++step) {
for (size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
for (outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
uint8_t hash[BLAKE2_KAT_LENGTH];
blake2xb_state S;
uint8_t * p = buf;

@ -166,7 +166,7 @@ int main( void )
{
uint8_t key[BLAKE2S_KEYBYTES];
uint8_t buf[BLAKE2_KAT_LENGTH];
size_t i, step;
size_t i, step, outlen;
for( i = 0; i < BLAKE2S_KEYBYTES; ++i ) {
key[i] = ( uint8_t )i;
@ -180,7 +180,7 @@ int main( void )
/* (Test of input lengths mostly covered by blake2s tests) */
/* Test simple API */
for( size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
for( outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen )
{
uint8_t hash[BLAKE2_KAT_LENGTH] = {0};
blake2xs( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2S_KEYBYTES );
@ -193,7 +193,7 @@ int main( void )
/* Test streaming API */
for(step = 1; step < BLAKE2S_BLOCKBYTES; ++step) {
for (size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
for (outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
uint8_t hash[BLAKE2_KAT_LENGTH];
blake2xs_state S;
uint8_t * p = buf;