Example #1
0
void init_zr5_ctx()
{
  #ifndef NO_AES_NI
     init_groestl( &zr5_ctx.groestl );
  #endif
     sph_keccak512_init(&zr5_ctx.keccak);
}  
Example #2
0
void jha_hash(void *output, const void *input)
{
	uint8_t _ALIGN(128) hash[64];

#ifdef NO_AES_NI
	sph_groestl512_context ctx_groestl;
#else
        hashState_groestl      ctx_groestl;
#endif
        sph_blake512_context ctx_blake;
	sph_jh512_context ctx_jh;
	sph_keccak512_context ctx_keccak;
	sph_skein512_context ctx_skein;

        memcpy( &ctx_keccak, &jha_kec_mid, sizeof jha_kec_mid );
        sph_keccak512(&ctx_keccak, input+64, 16 );
	sph_keccak512_close(&ctx_keccak, hash );

	// Heavy & Light Pair Loop
	for (int round = 0; round < 3; round++)
	{
	   if (hash[0] & 0x01)
           {
#ifdef NO_AES_NI
		sph_groestl512_init(&ctx_groestl);
		sph_groestl512(&ctx_groestl, hash, 64 );
		sph_groestl512_close(&ctx_groestl, hash );
#else
                init_groestl( &ctx_groestl, 64 );
                update_and_final_groestl( &ctx_groestl, (char*)hash,
                                          (char*)hash, 512 );
#endif
	    }
            else
            {
		sph_skein512_init(&ctx_skein);
		sph_skein512(&ctx_skein, hash, 64);
		sph_skein512_close(&ctx_skein, hash );
	    }

	    if (hash[0] & 0x01)
            {
		sph_blake512_init(&ctx_blake);
		sph_blake512(&ctx_blake, hash, 64);
		sph_blake512_close(&ctx_blake, hash );
	    }
            else
            {
		sph_jh512_init(&ctx_jh);
		sph_jh512(&ctx_jh, hash, 64 );
		sph_jh512_close(&ctx_jh, hash );
	    }
	}

	memcpy(output, hash, 32);
}
Example #3
0
void init_x12_4way_ctx()
{
     blake512_4way_init( &x12_4way_ctx.blake );
     bmw512_4way_init( &x12_4way_ctx.bmw );
     init_groestl( &x12_4way_ctx.groestl, 64 );
     skein512_4way_init( &x12_4way_ctx.skein );
     jh512_4way_init( &x12_4way_ctx.jh );
     keccak512_4way_init( &x12_4way_ctx.keccak );
     luffa_2way_init( &x12_4way_ctx.luffa, 512 );
     cubehashInit( &x12_4way_ctx.cube, 512, 16, 32 );
     sph_shavite512_init( &x12_4way_ctx.shavite );
     simd_2way_init( &x12_4way_ctx.simd, 512 );
     init_echo( &x12_4way_ctx.echo, 512 );
     hamsi512_4way_init( &x12_4way_ctx.hamsi );
//     sph_fugue512_init( &x12_4way_ctx.fugue );
};
Example #4
0
void init_x14_ctx()
{
#ifdef NO_AES_NI
        sph_groestl512_init(&x14_ctx.groestl);
        sph_echo512_init(&x14_ctx.echo);
#else
        init_echo(&x14_ctx.echo, 512);
        init_groestl(&x14_ctx.groestl);
#endif
        init_luffa(&x14_ctx.luffa,512);
        cubehashInit(&x14_ctx.cubehash,512,16,32);
        sph_shavite512_init(&x14_ctx.shavite);
        init_sd(&x14_ctx.simd,512);
        sph_hamsi512_init(&x14_ctx.hamsi);
        sph_fugue512_init(&x14_ctx.fugue);
        sph_shabal512_init(&x14_ctx.shabal);
};
Example #5
0
/* hash bit sequence */
HashReturn_gr hash_groestl(int hashbitlen,
		const BitSequence_gr* data, 
		DataLength_gr databitlen,
		BitSequence_gr* hashval) {
  HashReturn_gr ret;
  hashState_groestl context;

  /* initialise */
  if ((ret = init_groestl( &context, hashbitlen/8 )) != SUCCESS_GR)
    return ret;

  /* process message */
  if ((ret = update_groestl(&context, data, databitlen)) != SUCCESS_GR)
    return ret;

  /* finalise */
  ret = final_groestl(&context, hashval);

  return ret;
}
inline void Xhash(void *state, const void *input)
{
	Xhash_context_holder ctx;

//	uint32_t hashA[16], hashB[16];


	memcpy(&ctx, &base_contexts, sizeof(base_contexts));
	#ifdef AES_NI_GR
	init_groestl(&ctx.groestl);
	#endif

	DATA_ALIGNXY(unsigned char hashbuf[128],16);
	size_t hashptr;
	DATA_ALIGNXY(sph_u64 hashctA,8);
	DATA_ALIGNXY(sph_u64 hashctB,8);

	#ifndef AES_NI_GR
	grsoState sts_grs;
	#endif


	DATA_ALIGNXY(unsigned char hash[128],16);
	/* proably not needed */
	memset(hash, 0, 128);
	//blake1-bmw2-grs3-skein4-jh5-keccak6-luffa7-cubehash8-shavite9-simd10-echo11
	//---blake1---
/*	  //blake init
	blake512_init(&base_contexts.blake1, 512);
	blake512_update(&ctx.blake1, input, 512);
	blake512_final(&ctx.blake1, hash);
*/
	DECL_BLK;
	BLK_I;
	BLK_W;
	BLK_C;

	//---bmw2---
	DECL_BMW;
	BMW_I;
	BMW_U;
	#define M(x)    sph_dec64le_aligned(data + 8 * (x))
	#define H(x)    (h[x])
	#define dH(x)   (dh[x])
        BMW_C;
	#undef M
	#undef H
	#undef dH
	//---grs3----

	#ifdef AES_NI_GR
	update_groestl(&ctx.groestl, (char*)hash,512);
	final_groestl(&ctx.groestl, (char*)hash);
	#else
	GRS_I;
	GRS_U;
	GRS_C;
	#endif
	//---skein4---
	DECL_SKN;
	SKN_I;
	SKN_U;
	SKN_C;
	//---jh5------
	DECL_JH;
	JH_H;
	//---keccak6---
	DECL_KEC;
	KEC_I;
	KEC_U;
	KEC_C;

//	asm volatile ("emms");
	//--- luffa7
	update_luffa(&ctx.luffa,(const BitSequence*)hash,512);
	final_luffa(&ctx.luffa,(BitSequence*)hash+64);
	//---cubehash---
	cubehashUpdate(&ctx.cubehash,(const byte*) hash+64,64);
	cubehashDigest(&ctx.cubehash,(byte*)hash);
	//---shavite---
	sph_shavite512 (&ctx.shavite1, hash, 64);
	sph_shavite512_close(&ctx.shavite1, hash+64);
	//sph_simd512 (&ctx.simd1, hashA, 64);
	// sph_simd512_close(&ctx.simd1, hashB);
	//-------simd512 vect128 --------------
	update_sd(&ctx.ctx_simd1,(const BitSequence *)hash+64,512);
	final_sd(&ctx.ctx_simd1,(BitSequence *)hash);
	//---echo---
	#ifdef AES_NI
	update_echo (&ctx.echo1,(const BitSequence *) hash, 512);
	final_echo(&ctx.echo1, (BitSequence *) hash+64);
	#else
	sph_echo512 (&ctx.echo1, hash, 64);
	sph_echo512_close(&ctx.echo1, hash+64);
	#endif

	memcpy(state, hash+64, 32);
}