Skip to content

Commit 93701ee

Browse files
authored
Expand openssl sign verify parsing (#238)
1 parent 3c5acb4 commit 93701ee

File tree

5 files changed

+102
-19
lines changed

5 files changed

+102
-19
lines changed

.pipelines/azure-pipelines-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resources:
1616
options: --entrypoint=""
1717

1818
variables:
19-
VcVersion : 1.13.11
19+
VcVersion : 1.13.12
2020
ROOT: $(Build.SourcesDirectory)
2121
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2222
ENABLE_PRS_DELAYSIGN: 1

.pipelines/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pool:
1818
vmImage: windows-latest
1919

2020
variables:
21-
VcVersion : 1.13.11
21+
VcVersion : 1.13.12
2222
ROOT: $(Build.SourcesDirectory)
2323
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2424
ENABLE_PRS_DELAYSIGN: 1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Forked child 0
2+
Forked child 1
3+
Forked child 2
4+
Forked child 3
5+
Forked child 4
6+
Forked child 5
7+
Forked child 6
8+
Forked child 7
9+
Forked child 8
10+
Forked child 9
11+
Forked child 10
12+
Forked child 11
13+
Forked child 12
14+
Forked child 13
15+
Forked child 14
16+
Forked child 15
17+
Got: +F6:0:253:Ed25519:16489.200000:5105.600000 from 0
18+
Got: +F6:0:253:Ed25519:16327.400000:4928.400000 from 1
19+
Got: +F6:0:253:Ed25519:16509.400000:4777.200000 from 2
20+
Got: +F6:0:253:Ed25519:16471.257485:4928.600000 from 3
21+
Got: +F6:0:253:Ed25519:16538.600000:4936.600000 from 4
22+
Got: +F6:0:253:Ed25519:16152.800000:4873.000000 from 5
23+
Got: +F6:0:253:Ed25519:16498.400000:4752.400000 from 6
24+
Got: +F6:0:253:Ed25519:15695.800000:4706.000000 from 7
25+
Got: +F6:0:253:Ed25519:16496.000000:4926.746507 from 8
26+
Got: +F6:0:253:Ed25519:15967.600000:4884.231537 from 9
27+
Got: +F6:0:253:Ed25519:16496.200000:4911.800000 from 10
28+
Got: +F6:0:253:Ed25519:16526.400000:4882.600000 from 11
29+
Got: +F6:0:253:Ed25519:16437.325349:4779.800000 from 12
30+
Got: +F6:0:253:Ed25519:16442.600000:4889.800000 from 13
31+
Got: +F6:0:253:Ed25519:16186.600000:4914.600000 from 14
32+
Got: +F6:0:253:Ed25519:15880.600000:4805.800000 from 15
33+
version: 3.0.0-beta3-dev
34+
built on: built on: Thu Aug 5 18:45:56 2021 UTC
35+
options:bn(64,64)
36+
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
37+
CPUINFO: OPENSSL_ia32cap=0xfffa32235f8bffff:0x415f46f1bf2fbb
38+
sign verify sign/s verify/s
39+
253 bits EdDSA (Ed25519) 0.0000s 0.0000s 261116.2 78003.2

src/VirtualClient/VirtualClient.Actions.UnitTests/OpenSSL/OpenSslMetricsParserTests.cs

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ sha256 98952.23k 300483.21k 717624.35k 1098886.72k 1296898.18k
5050
IEnumerable<Metric> metrics = parser.Parse();
5151

5252
Assert.IsNotNull(metrics);
53-
Assert.IsTrue(metrics.Count() == 6);
53+
Assert.AreEqual(6, metrics.Count());
5454
Assert.IsTrue(metrics.All(m => m.Unit == MetricUnit.KilobytesPerSecond));
5555

56-
OpenSslMetricsParserTests.AssertMetricsMatch("aes-256-cbc", metrics, new Dictionary<string, double>
56+
OpenSslMetricsParserTests.AssertMetricsMatch("AES-256-CBC", metrics, new Dictionary<string, double>
5757
{
58-
{ "aes-256-cbc 16-byte", 1109022.36 },
59-
{ "aes-256-cbc 64-byte", 1209391.13 },
60-
{ "aes-256-cbc 256-byte", 1232451.87 },
61-
{ "aes-256-cbc 1024-byte", 1237247.28 },
62-
{ "aes-256-cbc 8192-byte", 1239375.05 },
63-
{ "aes-256-cbc 16384-byte", 1239090.79 },
58+
{ "AES-256-CBC 16-byte", 1109022.36 },
59+
{ "AES-256-CBC 64-byte", 1209391.13 },
60+
{ "AES-256-CBC 256-byte", 1232451.87 },
61+
{ "AES-256-CBC 1024-byte", 1237247.28 },
62+
{ "AES-256-CBC 8192-byte", 1239375.05 },
63+
{ "AES-256-CBC 16384-byte", 1239090.79 },
6464
});
6565
}
6666

@@ -194,6 +194,34 @@ rsa 2048 bits 0.000820s 0.000024s 1219.7 41003.9
194194
});
195195
}
196196

197+
[Test]
198+
public void OpenSslParserParsesResultsCorrectly_ed25519_Scenario()
199+
{
200+
/* In this scenario, we are evaluating a single cipher as well as all byte buffer sizes.
201+
202+
Example:
203+
sign verify sign/s verify/s
204+
253 bits EdDSA (Ed25519) 0.0000s 0.0000s 261116.2 78003.2
205+
*/
206+
207+
OpenSslMetricsParser parser = new OpenSslMetricsParser(
208+
File.ReadAllText(Path.Combine(OpenSslMetricsParserTests.examplesDir, "OpenSSL-speed-multi-ed25519.txt")),
209+
"speed -multi 16 -seconds 5 ed25519");
210+
211+
IEnumerable<Metric> metrics = parser.Parse();
212+
213+
Assert.IsNotNull(metrics);
214+
Assert.AreEqual(4, metrics.Count());
215+
216+
OpenSslMetricsParserTests.AssertMetricsMatch("253 bits EdDSA (Ed25519)", metrics, new Dictionary<string, double>
217+
{
218+
{ "253 bits EdDSA (Ed25519) sign", 0 },
219+
{ "253 bits EdDSA (Ed25519) verify", 0 },
220+
{ "253 bits EdDSA (Ed25519) sign/s", 261116.2 },
221+
{ "253 bits EdDSA (Ed25519) verify/s", 78003.2 }
222+
});
223+
}
224+
197225
[Test]
198226
public void OpenSslParserParsesResultsCorrectly_AllCiphers_Scenario()
199227
{
@@ -213,7 +241,7 @@ sha256 98952.23k 300483.21k 717624.35k 1098886.72k 1296898.18k
213241
IEnumerable<Metric> metrics = parser.Parse();
214242

215243
Assert.IsNotNull(metrics);
216-
Assert.IsTrue(metrics.Count() == 112);
244+
Assert.AreEqual(224, metrics.Count());
217245
// Assert.IsTrue(metrics.All(m => m.Unit == MetricUnit.KilobytesPerSecond)); --> changed with inclusion of RSA coverage
218246

219247
OpenSslMetricsParserTests.AssertMetricsMatch("md5", metrics, new Dictionary<string, double>
@@ -432,7 +460,7 @@ sha256 1316783.17k
432460
IEnumerable<Metric> metrics = parser.Parse();
433461

434462
Assert.IsNotNull(metrics);
435-
Assert.IsTrue(metrics.Count() == 42);
463+
Assert.AreEqual(154, metrics.Count());
436464
// Assert.IsTrue(metrics.All(m => m.Unit == MetricUnit.KilobytesPerSecond)); --> changed with inclusion of RSA coverage
437465

438466
OpenSslMetricsParserTests.AssertMetricsMatch("md5", metrics, new Dictionary<string, double>
@@ -526,7 +554,7 @@ type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 1
526554
IEnumerable<Metric> metrics = parser.Parse();
527555

528556
Assert.IsNotNull(metrics);
529-
Assert.IsTrue(metrics.Count() == 94);
557+
Assert.AreEqual(206, metrics.Count());
530558
// Assert.IsTrue(metrics.All(m => m.Unit == MetricUnit.KilobytesPerSecond)); --> changed with inclusion of RSA coverage
531559

532560
OpenSslMetricsParserTests.AssertMetricsMatch("md5", metrics, new Dictionary<string, double>
@@ -650,6 +678,22 @@ type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 1
650678
{ "rand 1024-byte", 1062619.07 },
651679
{ "rand 8192-byte", 4221050.33 }
652680
});
681+
682+
OpenSslMetricsParserTests.AssertMetricsMatch("rsa 512", metrics, new Dictionary<string, double>
683+
{
684+
{ "rsa 512 bits sign", 0.000038 },
685+
{ "rsa 512 bits verify", 0.000002 },
686+
{ "rsa 512 bits sign/s", 26538.8 },
687+
{ "rsa 512 bits verify/s", 432400.4 }
688+
});
689+
690+
OpenSslMetricsParserTests.AssertMetricsMatch("256 bits SM2 (CurveSM2)", metrics, new Dictionary<string, double>
691+
{
692+
{ "256 bits SM2 (CurveSM2) sign", 0.0003 },
693+
{ "256 bits SM2 (CurveSM2) verify", 0.0003 },
694+
{ "256 bits SM2 (CurveSM2) sign/s", 2862.3 },
695+
{ "256 bits SM2 (CurveSM2) verify/s", 3079.5 }
696+
});
653697
}
654698

655699
[Test]

src/VirtualClient/VirtualClient.Actions/OpenSSL/OpenSslMetricsParser.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public override IList<Metric> Parse()
116116
this.CipherResults = cipherResults;
117117
}
118118

119-
if (this.TryParseRSAPerformanceResults(out DataTable rsaResults))
119+
if (this.TryParseSignVerifyPerformanceResults(out DataTable rsaResults))
120120
{
121121
rsaResultsValid = true;
122122
this.RSAResults = rsaResults;
@@ -135,7 +135,7 @@ public override IList<Metric> Parse()
135135
foreach (DataRow row in this.CipherResults.Rows)
136136
{
137137
// Ex: aes-256-cbc (8192 bytes)
138-
string metricName = $"{row[OpenSslMetricsParser.ColumnCipher]} {row[OpenSslMetricsParser.ColumnBytes]}-byte".ToLowerInvariant();
138+
string metricName = $"{row[OpenSslMetricsParser.ColumnCipher]} {row[OpenSslMetricsParser.ColumnBytes]}-byte";
139139
double metricValue = (double)row[OpenSslMetricsParser.ColumnKilobytesPerSec];
140140

141141
// There is an anomaly that sometimes happens where the result is a negative number. It indicates
@@ -156,14 +156,14 @@ public override IList<Metric> Parse()
156156
{
157157
foreach (DataRow row in this.RSAResults.Rows)
158158
{
159-
string metricName = $"{row[OpenSslMetricsParser.ColumnCipher]} {row[OpenSslMetricsParser.ColumnUnit]}".ToLowerInvariant();
159+
string metricName = $"{row[OpenSslMetricsParser.ColumnCipher]} {row[OpenSslMetricsParser.ColumnUnit]}";
160160
double metricValue = (double)row[OpenSslMetricsParser.ColumnValue];
161161

162162
if (metricValue >= 0)
163163
{
164164
if (metricName.Contains("/"))
165165
{
166-
metrics.Add(new Metric(metricName, metricValue, $"row[OpenSslMetricsParser.ColumnUnit]", MetricRelativity.HigherIsBetter));
166+
metrics.Add(new Metric(metricName, metricValue, $"{row[OpenSslMetricsParser.ColumnUnit]}", MetricRelativity.HigherIsBetter));
167167
}
168168
else
169169
{
@@ -274,7 +274,7 @@ private bool TryParseCipherPerformanceResults(IEnumerable<int> cipherBytes, out
274274
return parsedSuccessfully;
275275
}
276276

277-
private bool TryParseRSAPerformanceResults(out DataTable results)
277+
private bool TryParseSignVerifyPerformanceResults(out DataTable results)
278278
{
279279
results = null;
280280
bool parsedSuccessfully = false;
@@ -290,7 +290,7 @@ private bool TryParseRSAPerformanceResults(out DataTable results)
290290
// Example:
291291
// sign verify sign/s verify/s
292292
// rsa 2048 bits 0.000820s 0.000024s 1219.7 41003.9
293-
MatchCollection rsaPerformanceResults = Regex.Matches(this.RawText, $@"(rsa\s*[0-9\.]+\s*bits)(\s*[0-9\.]+s)(\s*[0-9\.]+s)(\s*[0-9\.]+)(\s*[0-9\.]+)", RegexOptions.IgnoreCase);
293+
MatchCollection rsaPerformanceResults = Regex.Matches(this.RawText, $@"((?:\w *\(*)+(?:bits|\)))(\s*[0-9\.]+s)(\s*[0-9\.]+s)(\s*[0-9\.]+)(\s*[0-9\.]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
294294
if (rsaPerformanceResults?.Any() == true)
295295
{
296296
// return datatable with rsa name, column, value per row

0 commit comments

Comments
 (0)