| 1 |
#include "crypto_core.h" |
| 2 |
|
| 3 |
#define p 953 |
| 4 |
#define q 6343 |
| 5 |
|
| 6 |
#include "crypto_decode_953xint16.h" |
| 7 |
#define crypto_decode_pxint16 crypto_decode_953xint16 |
| 8 |
#include "crypto_encode_953xint16.h" |
| 9 |
#define crypto_encode_pxint16 crypto_encode_953xint16 |
| 10 |
|
| 11 |
#include "crypto_int16.h" |
| 12 |
typedef crypto_int16 Fq; |
| 13 |
|
| 14 |
/* out = 3*in in Rq */ |
| 15 |
void crypto_core(unsigned char *outbytes,const unsigned char *inbytes,const unsigned char *kbytes,const unsigned char *cbytes) |
| 16 |
{ |
| 17 |
Fq f[p]; |
| 18 |
int i; |
| 19 |
|
| 20 |
crypto_decode_pxint16(f,inbytes); |
| 21 |
for (i = 0;i < p;++i) { |
| 22 |
Fq x = f[i]; |
| 23 |
x *= 3; /* (-3q+3)/2 ... (3q-3)/2 */ |
| 24 |
x -= (q+1)/2; /* -2q+1 ... q-2 */ |
| 25 |
x += q&crypto_int16_negative_mask(x); /* -q+1 ... q-1 */ |
| 26 |
x += q&crypto_int16_negative_mask(x); /* 0 ... q-1 */ |
| 27 |
x -= (q-1)/2; /* -(q-1)/2 ... (q-1)/2 */ |
| 28 |
f[i] = x; |
| 29 |
} |
| 30 |
crypto_encode_pxint16(outbytes,f); |
| 31 |
} |