Skip to content

Commit 429eb4c

Browse files
committed
bench: Comment out OpenSSL Keccak bench due to OpenSSL/LibreSSL versioning issues
1 parent 3e8cfa7 commit 429eb4c

File tree

1 file changed

+23
-33
lines changed

1 file changed

+23
-33
lines changed

benchmarks/bench_h_keccak.nim

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,27 @@ proc separator*() = separator(69)
99

1010
# Deal with platform mess
1111
# --------------------------------------------------------------------
12-
when defined(windows):
13-
when sizeof(int) == 8:
14-
const DLLSSLName* = "(libssl-1_1-x64|ssleay64|libssl64).dll"
15-
else:
16-
const DLLSSLName* = "(libssl-1_1|ssleay32|libssl32).dll"
17-
else:
18-
when defined(macosx) or defined(macos) or defined(ios):
19-
const versions = "(.1.1|.38|.39|.41|.43|.44|.45|.46|.47|.48|.10|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|)"
20-
else:
21-
const versions = "(.1.1|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|.48|.47|.46|.45|.44|.43|.41|.39|.38|.10|)"
22-
23-
when defined(macosx) or defined(macos) or defined(ios):
24-
const DLLSSLName* = "libssl" & versions & ".dylib"
25-
elif defined(genode):
26-
const DLLSSLName* = "libssl.lib.so"
27-
else:
28-
const DLLSSLName* = "libssl.so" & versions
12+
when false:
13+
include ./openssl_wrapper
2914

3015
# OpenSSL wrapper
3116
# --------------------------------------------------------------------
17+
# Only supported on OpenSSL 3.3, and even then it might have been removed in OpenSSL 3.4
18+
# On MacOS the default libssl is actually LibreSSL which doesn't provide the new mandatory (for Keccak) EVP API
3219

33-
proc EVP_Q_digest[T: byte|char](
34-
ossl_libctx: pointer,
35-
algoName: cstring,
36-
propq: cstring,
37-
data: openArray[T],
38-
digest: var array[32, byte],
39-
size: ptr uint): int32 {.noconv, dynlib: DLLSSLName, importc.}
20+
when false:
21+
proc EVP_Q_digest[T: byte|char](
22+
ossl_libctx: pointer,
23+
algoName: cstring,
24+
propq: cstring,
25+
data: openArray[T],
26+
digest: var array[32, byte],
27+
size: ptr uint): int32 {.noconv, dynlib: DLLSSLName, importc.}
4028

41-
proc SHA3_256_OpenSSL[T: byte|char](
42-
digest: var array[32, byte],
43-
s: openArray[T]) =
44-
discard EVP_Q_digest(nil, "SHA3-256", nil, s, digest, nil)
29+
proc SHA3_256_OpenSSL[T: byte|char](
30+
digest: var array[32, byte],
31+
s: openArray[T]) =
32+
discard EVP_Q_digest(nil, "SHA3-256", nil, s, digest, nil)
4533

4634
# --------------------------------------------------------------------
4735

@@ -64,10 +52,11 @@ proc benchKeccak256_constantine[T](msg: openarray[T], msgComment: string, iters:
6452
bench("Keccak256 - Constantine - " & msgComment, msg.len, iters):
6553
keccak256.hash(digest, msg)
6654

67-
proc benchSHA3_256_openssl[T](msg: openarray[T], msgComment: string, iters: int) =
68-
var digest: array[32, byte]
69-
bench("SHA3-256 - OpenSSL - " & msgComment, msg.len, iters):
70-
SHA3_256_OpenSSL(digest, msg)
55+
when false:
56+
proc benchSHA3_256_openssl[T](msg: openarray[T], msgComment: string, iters: int) =
57+
var digest: array[32, byte]
58+
bench("SHA3-256 - OpenSSL - " & msgComment, msg.len, iters):
59+
SHA3_256_OpenSSL(digest, msg)
7160

7261
when isMainModule:
7362
proc main() =
@@ -83,7 +72,8 @@ when isMainModule:
8372
let msg = rng.random_byte_seq(s)
8473
let iters = int(target_cycles div (s.int64 * worst_cycles_per_bytes))
8574
benchKeccak256_constantine(msg, $s & "B", iters)
86-
benchSHA3_256_openssl(msg, $s & "B", iters)
75+
when false:
76+
benchSHA3_256_openssl(msg, $s & "B", iters)
8777
echo "----"
8878

8979
main()

0 commit comments

Comments
 (0)