@@ -1060,11 +1060,23 @@ private final simulated function int TestMath()
1060
1060
local int Remainder;
1061
1061
local int HardCodedMontyFail;
1062
1062
local int MontyDecodeResult;
1063
+ local int BenchmarkRound;
1063
1064
local string BigIntString;
1064
1065
1065
1066
local int Dummy;
1066
1067
local FCQWORD QW;
1068
+ local FCQWORD QW1;
1069
+ local FCQWORD QW2;
1070
+ local FCQWORD QW3;
1071
+ local FCQWORD QW4;
1072
+ local FCQWORD QW5;
1073
+ local FCQWORD QW6;
1074
+ local FCQWORD QW7;
1075
+ local FCQWORD QW8;
1076
+ local FCQWORD QW9;
1067
1077
local bool bQWCarry;
1078
+ local float QWClock;
1079
+ local int QWIdx;
1068
1080
1069
1081
// TODO: Design for FCQWORD arithmetic.
1070
1082
Dummy = 0xFFFFFFFF;
@@ -1109,6 +1121,70 @@ private final simulated function int TestMath()
1109
1121
`fclog(" 0x7FFFFFFF > 0xFFFFFFFF :" @ IsGt(0x7FFFFFFF, 0xFFFFFFFF));
1110
1122
`fclog(" 0xFFFFFFFF > 0x7FFFFFFF :" @ IsGt(0xFFFFFFFF, 0x7FFFFFFF));
1111
1123
1124
+ QW1.A = 0x00000000;
1125
+ QW1.B = 0xFFFFFFFF;
1126
+ QW2.A = 0xFFFFFFFF;
1127
+ QW2.B = 0xFFFFFFFF;
1128
+ QW3.A = 0x00000000;
1129
+ QW3.B = 0x00000000;
1130
+ QW4.A = 0x00000000;
1131
+ QW4.B = 0xFFFFFFFF;
1132
+ QW5.A = 0x00000002;
1133
+ QW5.B = 0xFFFFFFFF;
1134
+ QW6.A = 0x00000000;
1135
+ QW6.B = 0x7FFAFFFF;
1136
+ QW7.A = 0x00000000;
1137
+ QW7.B = 0x00000002;
1138
+ QW8.A = 0x00000000;
1139
+ QW8.B = 0x00000001;
1140
+ QW9.A = 0x7FFFFFFF;
1141
+ QW9.B = 0x7FFFFFFF;
1142
+
1143
+ Clock(QWClock);
1144
+ for (QWIdx = 0; QWIdx < 1024; ++QWIdx)
1145
+ {
1146
+ class'FCryptoQWORD'.static.IsGt(QW1, QW1);
1147
+ class'FCryptoQWORD'.static.IsGt(QW1, QW2);
1148
+ class'FCryptoQWORD'.static.IsGt(QW2, QW3);
1149
+ class'FCryptoQWORD'.static.IsGt(QW3, QW4);
1150
+ class'FCryptoQWORD'.static.IsGt(QW4, QW5);
1151
+ class'FCryptoQWORD'.static.IsGt(QW5, QW6);
1152
+ class'FCryptoQWORD'.static.IsGt(QW7, QW8);
1153
+ class'FCryptoQWORD'.static.IsGt(QW8, QW9);
1154
+ class'FCryptoQWORD'.static.IsGt(QW9, QW1);
1155
+ class'FCryptoQWORD'.static.IsGt(QW2, QW5);
1156
+ class'FCryptoQWORD'.static.IsGt(QW7, QW9);
1157
+ class'FCryptoQWORD'.static.IsGt(QW1, QW5);
1158
+ class'FCryptoQWORD'.static.IsGt(QW1, QW4);
1159
+ class'FCryptoQWORD'.static.IsGt(QW4, QW9);
1160
+ class'FCryptoQWORD'.static.IsGt(QW4, QW8);
1161
+ }
1162
+ UnClock(QWClock);
1163
+ `fclog(" QWClock (reference )=" $ QWClock);
1164
+
1165
+ QWClock = 0;
1166
+ Clock(QWClock);
1167
+ for (QWIdx = 0; QWIdx < 1024; ++QWIdx)
1168
+ {
1169
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW1, QW1);
1170
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW1, QW2);
1171
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW2, QW3);
1172
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW3, QW4);
1173
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW4, QW5);
1174
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW5, QW6);
1175
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW7, QW8);
1176
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW8, QW9);
1177
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW9, QW1);
1178
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW2, QW5);
1179
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW7, QW9);
1180
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW1, QW5);
1181
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW1, QW4);
1182
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW4, QW9);
1183
+ class'FCryptoQWORD'.static.IsGt_NonConst(QW4, QW8);
1184
+ }
1185
+ UnClock(QWClock);
1186
+ `fclog(" QWClock (copy )=" $ QWClock);
1187
+
1112
1188
// BearSSL assumes all operands caller-allocated.
1113
1189
// We'll do some bare minimum allocations here to avoid issues.
1114
1190
// TODO: does UScript dynamic array allocation break CT guarantees?
@@ -1153,6 +1229,38 @@ private final simulated function int TestMath()
1153
1229
);
1154
1230
X.Length = 0;
1155
1231
1232
+ // -----------------------------------------------------------------------
1233
+ // -----------------------------------------------------------------------
1234
+ // TODO: dedicated benchmarking test suite.
1235
+ QWClock = 0;
1236
+ Clock(QWClock);
1237
+ for (BenchmarkRound = 0; BenchmarkRound < 10000; ++BenchmarkRound)
1238
+ {
1239
+ class'FCryptoBigInt'.static.Decode(
1240
+ X,
1241
+ Bytes_683384335291162482276352519,
1242
+ Bytes_683384335291162482276352519.Length
1243
+ );
1244
+ }
1245
+ UnClock(QWClock);
1246
+ `fclog(" QWClock (decode1 )=" $ QWClock);
1247
+
1248
+ QWClock = 0;
1249
+ Clock(QWClock);
1250
+ for (BenchmarkRound = 0; BenchmarkRound < 10000; ++BenchmarkRound)
1251
+ {
1252
+ class'FCryptoBigInt'.static.Decode_NonConst(
1253
+ X,
1254
+ Bytes_683384335291162482276352519,
1255
+ Bytes_683384335291162482276352519.Length
1256
+ );
1257
+ }
1258
+ UnClock(QWClock);
1259
+ `fclog(" QWClock (decode2 )=" $ QWClock);
1260
+
1261
+ // -----------------------------------------------------------------------
1262
+ // -----------------------------------------------------------------------
1263
+
1156
1264
`fcdebug(" check decode Bytes_683384335291162482276352519 ");
1157
1265
class'FCryptoBigInt'.static.Decode(
1158
1266
X,
0 commit comments