aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2020-04-22 22:11:30 -0500
committerGanesh Viswanathan <dev@genotrance.com>2020-04-22 22:11:30 -0500
commitc1f46680f77d077bfc7abebea8b289e9b8bac043 (patch)
treefa01b07d028f058b18cbfe38bd68ff1e11f0222b /tests
parentf17b958f47686f41a20045ea089295841a6845d6 (diff)
downloadnimterop-c1f46680f77d077bfc7abebea8b289e9b8bac043.tar.gz
nimterop-c1f46680f77d077bfc7abebea8b289e9b8bac043.zip
Add cImport for multiple headers
Diffstat (limited to 'tests')
-rw-r--r--tests/rsa.nim42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/rsa.nim b/tests/rsa.nim
new file mode 100644
index 0000000..638c490
--- /dev/null
+++ b/tests/rsa.nim
@@ -0,0 +1,42 @@
+import os
+import strutils
+
+import nimterop/[build, cimport]
+
+setDefines(@["cryptoStd"])
+getHeader("openssl/crypto.h")
+
+const
+ basePath = cryptoPath.parentDir
+ FLAGS {.strdefine.} = ""
+
+cPlugin:
+ import strutils
+
+ proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
+ sym.name = sym.name.strip(chars = {'_'}).replace("__", "_")
+
+ if sym.name in [
+ "AES_ENCRYPT", "AES_DECRYPT",
+ "BIO_CTRL_PENDING", "BIO_CTRL_WPENDING",
+ "BN_F_BNRAND", "BN_F_BNRAND_RANGE",
+ "CRYPTO_THREADID",
+ "EVP_CIPHER",
+ "OPENSSL_VERSION",
+ "PKCS7_ENCRYPT", "PKCS7_STREAM",
+ "SSL_TXT_ADH", "SSL_TXT_AECDH", "SSL_TXT_kECDHE"
+ ]:
+ sym.name = "C_" & sym.name
+
+cOverride:
+ proc OPENSSL_die*(assertion: cstring; file: cstring; line: cint) {.importc.}
+
+cImport(@[
+ basePath / "rsa.h",
+ basePath / "err.h",
+], recurse = true, flags = "-f:ast2 -s " & FLAGS)
+
+{.passL: cryptoLPath.}
+
+OpensslInit()
+echo $OPENSSL_VERSION_TEXT \ No newline at end of file