deal with DLL mess for OpenSSL test
This commit is contained in:
parent
e89429e822
commit
a5c1d077fb
|
@ -6,16 +6,42 @@ import
|
|||
# Third-party
|
||||
stew/byteutils
|
||||
|
||||
# Deal with platform mess
|
||||
# --------------------------------------------------------------------
|
||||
when defined(windows):
|
||||
when sizeof(int) == 8:
|
||||
const DLLSSLName* = "(libssl-1_1-x64|ssleay64|libssl64).dll"
|
||||
else:
|
||||
const DLLSSLName* = "(libssl-1_1|ssleay32|libssl32).dll"
|
||||
else:
|
||||
when defined(macosx):
|
||||
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|)"
|
||||
else:
|
||||
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|)"
|
||||
|
||||
when defined(macosx):
|
||||
const DLLSSLName* = "libssl" & versions & ".dylib"
|
||||
elif defined(genode):
|
||||
const DLLSSLName* = "libssl.lib.so"
|
||||
else:
|
||||
const DLLSSLName* = "libssl.so" & versions
|
||||
|
||||
# OpenSSL wrapper
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
proc SHA256[T: byte|char](
|
||||
msg: openarray[T],
|
||||
digest: ptr array[32, byte] = nil
|
||||
): ptr array[32, byte] {.cdecl, dynlib: "libssl.so", importc.}
|
||||
): ptr array[32, byte] {.cdecl, dynlib: DLLSSLName, importc.}
|
||||
|
||||
proc SHA256_OpenSSL[T: byte|char](
|
||||
digest: var array[32, byte],
|
||||
s: openarray[T]) =
|
||||
discard SHA256(s, digest.addr)
|
||||
|
||||
# Test
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
echo "\n------------------------------------------------------\n"
|
||||
const SmallSizeIters = 128
|
||||
const LargeSizeIters = 10
|
||||
|
|
Loading…
Reference in New Issue