| 1 |
#include <string.h> |
| 2 |
#include "ge.h" |
| 3 |
#include "sc.h" |
| 4 |
#include "crypto_verify_32.h" |
| 5 |
#include "crypto_mGnP.h" |
| 6 |
|
| 7 |
void crypto_mGnP( |
| 8 |
unsigned char *Q, |
| 9 |
const unsigned char *m, |
| 10 |
const unsigned char *n, |
| 11 |
const unsigned char *P |
| 12 |
) |
| 13 |
{ |
| 14 |
unsigned char mcopy[64]; |
| 15 |
unsigned char ncopy[64]; |
| 16 |
ge_p3 P_internal; |
| 17 |
ge_p2 R; |
| 18 |
int ok; |
| 19 |
|
| 20 |
ok = ge_frombytes_negate_vartime(&P_internal,P); |
| 21 |
|
| 22 |
memcpy(mcopy,m,32); |
| 23 |
memset(mcopy+32,0,32); |
| 24 |
sc_reduce(mcopy); |
| 25 |
if (crypto_verify_32(mcopy,m)) ok = 0; |
| 26 |
|
| 27 |
memcpy(ncopy,n,64); |
| 28 |
sc_reduce(ncopy); |
| 29 |
|
| 30 |
ge_double_scalarmult_vartime(&R,ncopy,&P_internal,mcopy); |
| 31 |
ge_tobytes(Q,&R); |
| 32 |
Q[32] = ok; |
| 33 |
} |