This commit is contained in:
Jay D Dee
2018-01-23 21:02:16 -05:00
parent a90d75b8f5
commit ad2275f74a
121 changed files with 4662 additions and 467 deletions

View File

@@ -1,6 +1,6 @@
#include "x13sm3-gate.h"
#if defined(__AVX2__) && defined(__AES__)
#if defined(X13SM3_4WAY)
#include <stdlib.h>
#include <stdint.h>
@@ -18,7 +18,7 @@
#include "algo/simd/sse2/nist.h"
#include "algo/echo/aes_ni/hash_api.h"
#include "algo/sm3/sm3-hash-4way.h"
#include "algo/hamsi/sph_hamsi.h"
#include "algo/hamsi/hamsi-hash-4way.h"
#include "algo/fugue/sph_fugue.h"
typedef struct {
@@ -34,7 +34,7 @@ typedef struct {
hashState_sd simd;
hashState_echo echo;
sm3_4way_ctx_t sm3;
sph_hamsi512_context hamsi;
hamsi512_4way_context hamsi;
sph_fugue512_context fugue;
} x13sm3_4way_ctx_holder;
@@ -55,7 +55,7 @@ void init_x13sm3_4way_ctx()
init_sd( &x13sm3_4way_ctx.simd, 512 );
init_echo( &x13sm3_4way_ctx.echo, 512 );
sm3_4way_init( &x13sm3_4way_ctx.sm3 );
sph_hamsi512_init( &x13sm3_4way_ctx.hamsi );
hamsi512_4way_init( &x13sm3_4way_ctx.hamsi );
sph_fugue512_init( &x13sm3_4way_ctx.fugue );
};
@@ -174,7 +174,9 @@ void x13sm3_4way_hash( void *state, const void *input )
update_final_echo( &ctx.echo, (BitSequence *)hash3,
(const BitSequence *) hash3, 512 );
// SM3
mm_interleave_4x32( vhash, hash0, hash1, hash2, hash3, 512 );
// SM3 parallel 32 bit
uint32_t sm3_vhash[32*4] __attribute__ ((aligned (64)));
memset( sm3_vhash, 0, sizeof sm3_vhash );
uint32_t sm3_hash0[32] __attribute__ ((aligned (32)));
@@ -186,26 +188,16 @@ void x13sm3_4way_hash( void *state, const void *input )
uint32_t sm3_hash3[32] __attribute__ ((aligned (32)));
memset( sm3_hash3, 0, sizeof sm3_hash3 );
mm_interleave_4x32( vhash, hash0, hash1, hash2, hash3, 512 );
sm3_4way( &ctx.sm3, vhash, 64 );
sm3_4way_close( &ctx.sm3, sm3_vhash );
mm_deinterleave_4x32( sm3_hash0, sm3_hash1, sm3_hash2, sm3_hash3,
sm3_vhash, 1024 );
// Hamsi
sph_hamsi512( &ctx.hamsi, sm3_hash0, 64 );
sph_hamsi512_close( &ctx.hamsi, hash0 );
memcpy( &ctx.hamsi, &x13sm3_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
sph_hamsi512( &ctx.hamsi, sm3_hash1, 64 );
sph_hamsi512_close( &ctx.hamsi, hash1 );
memcpy( &ctx.hamsi, &x13sm3_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
sph_hamsi512( &ctx.hamsi, sm3_hash2, 64 );
sph_hamsi512_close( &ctx.hamsi, hash2 );
memcpy( &ctx.hamsi, &x13sm3_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
sph_hamsi512( &ctx.hamsi, sm3_hash3, 64 );
sph_hamsi512_close( &ctx.hamsi, hash3 );
// Hamsi parallel 32 bit
hamsi512_4way( &ctx.hamsi, sm3_vhash, 64 );
hamsi512_4way_close( &ctx.hamsi, vhash );
// Fugue
mm_deinterleave_4x32( hash0, hash1, hash2, hash3, vhash, 512 );
// Fugue serial
sph_fugue512( &ctx.fugue, hash0, 64 );
sph_fugue512_close( &ctx.fugue, hash0 );
memcpy( &ctx.fugue, &x13sm3_4way_ctx.fugue, sizeof(sph_fugue512_context) );