X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_grasshopper_math.h;h=87d1265267b7e150e7bb266a84e6339cfafe05a4;hb=4976e022f58f132fb1157fc452499afdbb64a234;hp=176d16aeca19ce3cea7a0b8fe45c24d7afbcb571;hpb=83a3a1682977d0775a085aea7257f949f23c859a;p=openssl-gost%2Fengine.git diff --git a/gost_grasshopper_math.h b/gost_grasshopper_math.h index 176d16a..87d1265 100644 --- a/gost_grasshopper_math.h +++ b/gost_grasshopper_math.h @@ -77,9 +77,15 @@ static GRASSHOPPER_INLINE void grasshopper_copy128(grasshopper_w128_t* to, const static GRASSHOPPER_INLINE void grasshopper_append128(grasshopper_w128_t* x, const grasshopper_w128_t* y) { int i; +#ifdef STRICT_ALIGNMENT + for (i = 0; i < 16; i++) { + GRASSHOPPER_ACCESS_128_VALUE_8(*x, i) ^= GRASSHOPPER_ACCESS_128_VALUE_8(*y, i); + } +#else for (i = 0; i < GRASSHOPPER_BIT_PARTS; i++) { GRASSHOPPER_ACCESS_128_VALUE(*x, i) ^= GRASSHOPPER_ACCESS_128_VALUE(*y, i); } +#endif } static GRASSHOPPER_INLINE void grasshopper_plus128(grasshopper_w128_t* result, const grasshopper_w128_t* x, @@ -119,7 +125,7 @@ extern uint8_t grasshopper_galois_alpha_to[256]; extern uint8_t grasshopper_galois_index_of[256]; static GRASSHOPPER_INLINE uint8_t grasshopper_galois_mul(uint8_t x, uint8_t y) { - if (__builtin_expect(x != 0 && y != 0, 1)) { + if (likely(x != 0 && y != 0)) { return grasshopper_galois_alpha_to[(grasshopper_galois_index_of[x] + grasshopper_galois_index_of[y]) % GRASSHOPPER_GALOIS_FIELD_SIZE]; } else {