@@ -22,12 +22,8 @@ using std::array;
22
22
namespace osuCrypto {
23
23
24
24
25
- // bool gUseBgicksPprf(true);
26
-
27
- // using namespace std;
28
-
29
- // Utility function to do modular exponentiation.
30
- // It returns (x^y) % p
25
+ // Utility function to do modular exponentiation.
26
+ // It returns (x^y) % p
31
27
u64 power (u64 x, u64 y, u64 p)
32
28
{
33
29
u64 res = 1 ; // Initialize result
@@ -105,14 +101,14 @@ namespace osuCrypto {
105
101
106
102
bool isPrime (u64 n)
107
103
{
108
- PRNG prng (ZeroBlock );
104
+ PRNG prng (oc::sysRandomSeed () );
109
105
return isPrime (n, prng);
110
106
}
111
107
112
108
113
109
u64 nextPrime (u64 n)
114
110
{
115
- PRNG prng (ZeroBlock );
111
+ PRNG prng (oc::sysRandomSeed () );
116
112
117
113
while (isPrime (n, prng) == false )
118
114
++n;
@@ -335,8 +331,8 @@ namespace osuCrypto {
335
331
outU16View[16 * x + 7 - j][y] = in[0 ].movemask_epi8 ();
336
332
outU16View[16 * x + 15 - j][y] = in[1 ].movemask_epi8 ();
337
333
338
- in[0 ] = ( in[0 ] << 1 );
339
- in[1 ] = ( in[1 ] << 1 );
334
+ in[0 ] = in[0 ]. slli_epi64 ( 1 );
335
+ in[1 ] = in[1 ]. slli_epi64 ( 1 );
340
336
}
341
337
}
342
338
@@ -494,14 +490,14 @@ namespace osuCrypto {
494
490
out7 -= out.stride ();
495
491
496
492
// shift the 128 values so that the top bit is now the next one.
497
- t.blks [0 ] = ( t.blks [0 ] << 1 );
498
- t.blks [1 ] = ( t.blks [1 ] << 1 );
499
- t.blks [2 ] = ( t.blks [2 ] << 1 );
500
- t.blks [3 ] = ( t.blks [3 ] << 1 );
501
- t.blks [4 ] = ( t.blks [4 ] << 1 );
502
- t.blks [5 ] = ( t.blks [5 ] << 1 );
503
- t.blks [6 ] = ( t.blks [6 ] << 1 );
504
- t.blks [7 ] = ( t.blks [7 ] << 1 );
493
+ t.blks [0 ] = t.blks [0 ]. slli_epi64 ( 1 );
494
+ t.blks [1 ] = t.blks [1 ]. slli_epi64 ( 1 );
495
+ t.blks [2 ] = t.blks [2 ]. slli_epi64 ( 1 );
496
+ t.blks [3 ] = t.blks [3 ]. slli_epi64 ( 1 );
497
+ t.blks [4 ] = t.blks [4 ]. slli_epi64 ( 1 );
498
+ t.blks [5 ] = t.blks [5 ]. slli_epi64 ( 1 );
499
+ t.blks [6 ] = t.blks [6 ]. slli_epi64 ( 1 );
500
+ t.blks [7 ] = t.blks [7 ]. slli_epi64 ( 1 );
505
501
}
506
502
}
507
503
}
@@ -550,15 +546,15 @@ namespace osuCrypto {
550
546
auto out0 = outStart + (chunkSize * subBlockHight + hh) * 8 * out.stride () + w * 2 ;
551
547
552
548
out0 -= out.stride () * skip;
553
- t.blks [0 ] = ( t.blks [0 ] << int (skip) );
549
+ t.blks [0 ] = t.blks [0 ]. slli_epi64 (skip);
554
550
555
551
for (int j = 0 ; j < rem; j++)
556
552
{
557
553
*(u16*)out0 = t.blks [0 ].movemask_epi8 ();
558
554
559
555
out0 -= out.stride ();
560
556
561
- t.blks [0 ] = ( t.blks [0 ] << 1 );
557
+ t.blks [0 ] = t.blks [0 ]. slli_epi64 ( 1 );
562
558
}
563
559
}
564
560
}
@@ -623,14 +619,14 @@ namespace osuCrypto {
623
619
out6 -= out.stride ();
624
620
out7 -= out.stride ();
625
621
626
- t.blks [0 ] = ( t.blks [0 ] << 1 );
627
- t.blks [1 ] = ( t.blks [1 ] << 1 );
628
- t.blks [2 ] = ( t.blks [2 ] << 1 );
629
- t.blks [3 ] = ( t.blks [3 ] << 1 );
630
- t.blks [4 ] = ( t.blks [4 ] << 1 );
631
- t.blks [5 ] = ( t.blks [5 ] << 1 );
632
- t.blks [6 ] = ( t.blks [6 ] << 1 );
633
- t.blks [7 ] = ( t.blks [7 ] << 1 );
622
+ t.blks [0 ] = t.blks [0 ]. slli_epi64 ( 1 );
623
+ t.blks [1 ] = t.blks [1 ]. slli_epi64 ( 1 );
624
+ t.blks [2 ] = t.blks [2 ]. slli_epi64 ( 1 );
625
+ t.blks [3 ] = t.blks [3 ]. slli_epi64 ( 1 );
626
+ t.blks [4 ] = t.blks [4 ]. slli_epi64 ( 1 );
627
+ t.blks [5 ] = t.blks [5 ]. slli_epi64 ( 1 );
628
+ t.blks [6 ] = t.blks [6 ]. slli_epi64 ( 1 );
629
+ t.blks [7 ] = t.blks [7 ]. slli_epi64 ( 1 );
634
630
}
635
631
}
636
632
else
@@ -655,14 +651,14 @@ namespace osuCrypto {
655
651
out6 -= out.stride ();
656
652
out7 -= out.stride ();
657
653
658
- t.blks [0 ] = ( t.blks [0 ] << 1 );
659
- t.blks [1 ] = ( t.blks [1 ] << 1 );
660
- t.blks [2 ] = ( t.blks [2 ] << 1 );
661
- t.blks [3 ] = ( t.blks [3 ] << 1 );
662
- t.blks [4 ] = ( t.blks [4 ] << 1 );
663
- t.blks [5 ] = ( t.blks [5 ] << 1 );
664
- t.blks [6 ] = ( t.blks [6 ] << 1 );
665
- t.blks [7 ] = ( t.blks [7 ] << 1 );
654
+ t.blks [0 ] = t.blks [0 ]. slli_epi64 ( 1 );
655
+ t.blks [1 ] = t.blks [1 ]. slli_epi64 ( 1 );
656
+ t.blks [2 ] = t.blks [2 ]. slli_epi64 ( 1 );
657
+ t.blks [3 ] = t.blks [3 ]. slli_epi64 ( 1 );
658
+ t.blks [4 ] = t.blks [4 ]. slli_epi64 ( 1 );
659
+ t.blks [5 ] = t.blks [5 ]. slli_epi64 ( 1 );
660
+ t.blks [6 ] = t.blks [6 ]. slli_epi64 ( 1 );
661
+ t.blks [7 ] = t.blks [7 ]. slli_epi64 ( 1 );
666
662
}
667
663
}
668
664
}
@@ -936,14 +932,14 @@ namespace osuCrypto {
936
932
auto x16_7 = x * 16 + 7 ;
937
933
auto x16_15 = x * 16 + 15 ;
938
934
939
- block b0 = ( in[0 ] << 0 );
940
- block b1 = ( in[0 ] << 1 );
941
- block b2 = ( in[0 ] << 2 );
942
- block b3 = ( in[0 ] << 3 );
943
- block b4 = ( in[0 ] << 4 );
944
- block b5 = ( in[0 ] << 5 );
945
- block b6 = ( in[0 ] << 6 );
946
- block b7 = ( in[0 ] << 7 );
935
+ block b0 = in[0 ]. slli_epi64 ( 0 );
936
+ block b1 = in[0 ]. slli_epi64 ( 1 );
937
+ block b2 = in[0 ]. slli_epi64 ( 2 );
938
+ block b3 = in[0 ]. slli_epi64 ( 3 );
939
+ block b4 = in[0 ]. slli_epi64 ( 4 );
940
+ block b5 = in[0 ]. slli_epi64 ( 5 );
941
+ block b6 = in[0 ]. slli_epi64 ( 6 );
942
+ block b7 = in[0 ]. slli_epi64 ( 7 );
947
943
948
944
outU16View[x16_7 - 0 ][i8y] = b0.movemask_epi8 ();
949
945
outU16View[x16_7 - 1 ][i8y] = b1.movemask_epi8 ();
@@ -954,14 +950,14 @@ namespace osuCrypto {
954
950
outU16View[x16_7 - 6 ][i8y] = b6.movemask_epi8 ();
955
951
outU16View[x16_7 - 7 ][i8y] = b7.movemask_epi8 ();
956
952
957
- b0 = ( in[1 ] << 0 );
958
- b1 = ( in[1 ] << 1 );
959
- b2 = ( in[1 ] << 2 );
960
- b3 = ( in[1 ] << 3 );
961
- b4 = ( in[1 ] << 4 );
962
- b5 = ( in[1 ] << 5 );
963
- b6 = ( in[1 ] << 6 );
964
- b7 = ( in[1 ] << 7 );
953
+ b0 = in[1 ]. slli_epi64 ( 0 );
954
+ b1 = in[1 ]. slli_epi64 ( 1 );
955
+ b2 = in[1 ]. slli_epi64 ( 2 );
956
+ b3 = in[1 ]. slli_epi64 ( 3 );
957
+ b4 = in[1 ]. slli_epi64 ( 4 );
958
+ b5 = in[1 ]. slli_epi64 ( 5 );
959
+ b6 = in[1 ]. slli_epi64 ( 6 );
960
+ b7 = in[1 ]. slli_epi64 ( 7 );
965
961
966
962
outU16View[x16_15 - 0 ][i8y] = b0.movemask_epi8 ();
967
963
outU16View[x16_15 - 1 ][i8y] = b1.movemask_epi8 ();
0 commit comments