Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion bindings/ffi_bindings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ module Bindings (F : Cstubs.FOREIGN) = struct
let new_ = foreign "BN_new" Ctypes.(void @-> returning t_opt)
let free = foreign "BN_free" Ctypes.(t @-> returning void)
let bin2bn = foreign "BN_bin2bn" Ctypes.(ptr char @-> int @-> t @-> returning t)
let hex2bn = foreign "BN_hex2bn" Ctypes.(ptr t_opt @-> string @-> returning int)
let hex2bn = foreign "ocaml_BN_hex2bn" Ctypes.(string @-> returning t_opt)
end

module Progress_callback = Progress_callback
Expand Down
8 changes: 8 additions & 0 deletions bindings/openssl_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,11 @@ void async_ssl__free_pem_peer_certificate_chain(char *certs) {
free(certs);
return;
}

BIGNUM *ocaml_BN_hex2bn(const char *str) {
BIGNUM *bn = NULL;
if (BN_hex2bn(&bn, str) == 0) {
return NULL;
}
return bn;
}
1 change: 1 addition & 0 deletions bindings/openssl_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ char **async_ssl__subject_alt_names(const X509 *cert);
void async_ssl__free_subject_alt_names(char **results);
char *async_ssl__pem_peer_certificate_chain(const SSL *con);
void async_ssl__free_pem_peer_certificate_chain(char *certs);
BIGNUM *ocaml_BN_hex2bn(const char *str);
6 changes: 2 additions & 4 deletions src/ffi__library_must_be_initialized.ml
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@ end
module Bignum = struct
type t = Bindings.Bignum.t

let create_no_gc (`hex hex) =
let p_ref = Ctypes.(allocate Bindings.Bignum.t_opt None) in
let _len = Bindings.Bignum.hex2bn p_ref hex in
match Ctypes.( !@ ) p_ref with
let create_no_gc (`hex hex) : t =
match Bindings.Bignum.hex2bn hex with
| Some p -> p
| None -> failwith "Unable to allocate/init Bignum."
;;
Expand Down