| 1 |
// 20240805 djb: more cryptoint usage |
| 2 |
// 20240508 djb: switch to vec_mul_gf_using_64 |
| 3 |
// 20221230 djb: changed * to [...] for vec_GF_mul declaration |
| 4 |
|
| 5 |
#ifndef VEC_H |
| 6 |
#define VEC_H |
| 7 |
#define vec_GF_mul CRYPTO_NAMESPACE(vec_GF_mul) |
| 8 |
#define vec_mul_asm CRYPTO_SHARED_NAMESPACE(vec_mul_asm) |
| 9 |
#define vec_mul_sp_asm CRYPTO_SHARED_NAMESPACE(vec_mul_sp_asm) |
| 10 |
|
| 11 |
#include "params.h" |
| 12 |
#include "gf.h" |
| 13 |
|
| 14 |
#include <stdint.h> |
| 15 |
#include "crypto_int64.h" |
| 16 |
|
| 17 |
typedef uint64_t vec; |
| 18 |
|
| 19 |
extern void vec_mul_asm(vec *, const vec *, const vec *); |
| 20 |
|
| 21 |
static inline void vec_mul(vec *h, const vec *f, const vec *g) |
| 22 |
{ |
| 23 |
vec_mul_asm(h, f, g); |
| 24 |
} |
| 25 |
|
| 26 |
extern void vec_mul_sp_asm(vec *, const vec *, const vec *); |
| 27 |
|
| 28 |
static inline void vec_mul_sp(vec *h, const vec *f, const vec *g) |
| 29 |
{ |
| 30 |
vec_mul_sp_asm(h, f, g); |
| 31 |
} |
| 32 |
|
| 33 |
static inline void vec_add(vec *h, vec *f, vec *g) |
| 34 |
{ |
| 35 |
int b; |
| 36 |
|
| 37 |
for (b = 0; b < GFBITS; b++) |
| 38 |
h[b] = f[b] ^ g[b]; |
| 39 |
} |
| 40 |
|
| 41 |
static inline void vec_mul_gf_using_64(vec out[ GFBITS ], vec v[ GFBITS ], gf a) |
| 42 |
{ |
| 43 |
int i; |
| 44 |
|
| 45 |
vec bits[GFBITS]; |
| 46 |
|
| 47 |
for (i = 0; i < GFBITS; i++) |
| 48 |
bits[i] = crypto_int64_bitmod_mask(a, i); |
| 49 |
|
| 50 |
vec_mul_asm(out, v, bits); |
| 51 |
} |
| 52 |
|
| 53 |
void vec_GF_mul(vec [GFBITS], vec [GFBITS], gf [SYS_T]); |
| 54 |
|
| 55 |
#endif |
| 56 |
|