Debian Codegraph @

crypto_nG/merged25519/ref10/fe_cmov.c

raw
1 // linker define fe_cmov
2
3 #include "fe.h"
4
5 /*
6 Replace (f,g) with (g,g) if b == 1;
7 replace (f,g) with (f,g) if b == 0.
8
9 Preconditions: b in {0,1}.
10 */
11
12 void fe_cmov(fe f,const fe g,unsigned int b)
13 {
14 crypto_int32 f0 = f[0];
15 crypto_int32 f1 = f[1];
16 crypto_int32 f2 = f[2];
17 crypto_int32 f3 = f[3];
18 crypto_int32 f4 = f[4];
19 crypto_int32 f5 = f[5];
20 crypto_int32 f6 = f[6];
21 crypto_int32 f7 = f[7];
22 crypto_int32 f8 = f[8];
23 crypto_int32 f9 = f[9];
24 crypto_int32 g0 = g[0];
25 crypto_int32 g1 = g[1];
26 crypto_int32 g2 = g[2];
27 crypto_int32 g3 = g[3];
28 crypto_int32 g4 = g[4];
29 crypto_int32 g5 = g[5];
30 crypto_int32 g6 = g[6];
31 crypto_int32 g7 = g[7];
32 crypto_int32 g8 = g[8];
33 crypto_int32 g9 = g[9];
34 crypto_int32 x0 = f0 ^ g0;
35 crypto_int32 x1 = f1 ^ g1;
36 crypto_int32 x2 = f2 ^ g2;
37 crypto_int32 x3 = f3 ^ g3;
38 crypto_int32 x4 = f4 ^ g4;
39 crypto_int32 x5 = f5 ^ g5;
40 crypto_int32 x6 = f6 ^ g6;
41 crypto_int32 x7 = f7 ^ g7;
42 crypto_int32 x8 = f8 ^ g8;
43 crypto_int32 x9 = f9 ^ g9;
44 b = -b;
45 x0 &= b;
46 x1 &= b;
47 x2 &= b;
48 x3 &= b;
49 x4 &= b;
50 x5 &= b;
51 x6 &= b;
52 x7 &= b;
53 x8 &= b;
54 x9 &= b;
55 f[0] = f0 ^ x0;
56 f[1] = f1 ^ x1;
57 f[2] = f2 ^ x2;
58 f[3] = f3 ^ x3;
59 f[4] = f4 ^ x4;
60 f[5] = f5 ^ x5;
61 f[6] = f6 ^ x6;
62 f[7] = f7 ^ x7;
63 f[8] = f8 ^ x8;
64 f[9] = f9 ^ x9;
65 }