tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

fe_cmov.c (1283B)


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