Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more OpenSSL methods. #13131

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/wrappers/openssl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ type
PASN1_UTCTIME* = SslPtr
PASN1_cInt* = SslPtr
PPasswdCb* = SslPtr
EVP_MD* = SslPtr
EVP_MD_CTX* = SslPtr
EVP_PKEY_CTX* = SslPtr
ENGINE* = SslPtr
PFunction* = proc () {.cdecl.}
DES_cblock* = array[0..7, int8]
PDES_cblock* = ptr DES_cblock
Expand Down Expand Up @@ -535,6 +539,45 @@ proc PEM_read_bio_RSA_PUBKEY*(bp: BIO, x: ptr PRSA, pw: pem_password_cb, u: poin
proc RSA_verify*(kind: cint, origMsg: pointer, origMsgLen: cuint, signature: pointer,
signatureLen: cuint, rsa: PRSA): cint {.cdecl, dynlib: DLLSSLName, importc.}

# sha types
proc EVP_md_null*(): EVP_MD {.cdecl, importc.}
proc EVP_md2*(): EVP_MD {.cdecl, importc.}
proc EVP_md4*(): EVP_MD {.cdecl, importc.}
proc EVP_md5*(): EVP_MD {.cdecl, importc.}
proc EVP_sha*(): EVP_MD {.cdecl, importc.}
proc EVP_sha1*(): EVP_MD {.cdecl, importc.}
proc EVP_dss*(): EVP_MD {.cdecl, importc.}
proc EVP_dss1*(): EVP_MD {.cdecl, importc.}
proc EVP_ecdsa*(): EVP_MD {.cdecl, importc.}
proc EVP_sha224*(): EVP_MD {.cdecl, importc.}
proc EVP_sha256*(): EVP_MD {.cdecl, importc.}
proc EVP_sha384*(): EVP_MD {.cdecl, importc.}
proc EVP_sha512*(): EVP_MD {.cdecl, importc.}
proc EVP_mdc2*(): EVP_MD {.cdecl, importc.}
proc EVP_ripemd160*(): EVP_MD {.cdecl, importc.}
proc EVP_whirlpool*(): EVP_MD {.cdecl, importc.}

# hmac functions
proc HMAC*(evp_md: EVP_MD; key: pointer; key_len: cint; d: cstring; n: csize_t; md: cstring; md_len: ptr cuint): cstring {.cdecl, importc.}

# RSA key functions
proc PEM_read_bio_PrivateKey*(bp: BIO, x: ptr EVP_PKEY, cb: pointer, u: pointer): EVP_PKEY {.cdecl, importc.}
proc EVP_PKEY_free*(p: EVP_PKEY) {.cdecl, importc.}
proc EVP_DigestSignInit*(ctx: EVP_MD_CTX, pctx: ptr EVP_PKEY_CTX, typ: EVP_MD, e: ENGINE, pkey: EVP_PKEY): cint {.cdecl, importc.}
proc EVP_DigestUpdate*(ctx: EVP_MD_CTX, data: pointer, len: cuint): cint {.cdecl, importc.}
proc EVP_DigestSignFinal*(ctx: EVP_MD_CTX, data: pointer, len: ptr csize_t): cint {.cdecl, importc.}
proc EVP_PKEY_CTX_new*(pkey: EVP_PKEY, e: ENGINE): EVP_PKEY_CTX {.cdecl, importc.}
proc EVP_PKEY_CTX_free*(pkeyCtx: EVP_PKEY_CTX) {.cdecl, importc.}
proc EVP_PKEY_sign_init*(c: EVP_PKEY_CTX): cint {.cdecl, importc.}

when defined(macosx) or defined(windows):
proc EVP_MD_CTX_create*(): EVP_MD_CTX {.cdecl, importc.}
proc EVP_MD_CTX_destroy*(ctx: EVP_MD_CTX) {.cdecl, importc.}
else:
# some times you will need this instead:
proc EVP_MD_CTX_create*(): EVP_MD_CTX {.cdecl, importc: "EVP_MD_CTX_new".}
proc EVP_MD_CTX_destroy*(ctx: EVP_MD_CTX) {.cdecl, importc: "EVP_MD_CTX_free".}

# <openssl/md5.h>
type
MD5_LONG* = cuint
Expand Down