diff options
| author | Steven Fackler <[email protected]> | 2014-10-07 12:14:44 -0400 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2014-10-07 12:14:44 -0400 |
| commit | e4b8b5e697620a543f1f7fe0183193ea7a45dc93 (patch) | |
| tree | 61a63011ead6a70ab17e3a9b5705534593a4361f | |
| parent | Merge pull request #60 from vhbit/cert-gen-cleanup (diff) | |
| parent | Potential fix for #68 (diff) | |
| download | rust-openssl-e4b8b5e697620a543f1f7fe0183193ea7a45dc93.tar.xz rust-openssl-e4b8b5e697620a543f1f7fe0183193ea7a45dc93.zip | |
Merge pull request #69 from vhbit/bn-zero-fix
Fixes #68: error on linking `bn_is_zero`
| -rw-r--r-- | Makefile | 11 | ||||
| -rw-r--r-- | src/ffi.rs | 9 | ||||
| -rw-r--r-- | src/ssl/tests.rs | 13 |
3 files changed, 27 insertions, 6 deletions
@@ -1,4 +1,9 @@ +ifneq ($(findstring i686,$(TARGET)),) + CFLAGS += -m32 +else + CFLAGS += -m64 +endif + default: - rm -f $(OUT_DIR)/bin_is_zero.o - $(CC) -O -shared native/bn_is_zero.c -o bn_is_zero.o - mv bn_is_zero.o $(OUT_DIR) + $(CC) $(CFLAGS) -c native/bn_is_zero.c -o $(OUT_DIR)/bn_is_zero.o + $(AR) crus $(OUT_DIR)/libwrapped.a $(OUT_DIR)/bn_is_zero.o @@ -189,6 +189,12 @@ extern { } /* Since the openssl BN_is_zero is sometimes a macro, this wrapper is necessary. */ pub unsafe fn BN_is_zero(a: *mut BIGNUM) -> c_int { bn_is_zero(a) } +/* Special import from native/bn_is_zero.c */ +#[link(name="wrapped")] +extern "C" { + pub fn bn_is_zero(a: *mut BIGNUM) -> c_int; +} + extern "C" { pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int; pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING; @@ -241,9 +247,6 @@ extern "C" { pub fn BN_cmp(a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; pub fn BN_ucmp(a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; - /* Special import from native/bn_is_zero.c */ - pub fn bn_is_zero(a: *mut BIGNUM) -> c_int; - /* Prime handling */ pub fn BN_generate_prime_ex(r: *mut BIGNUM, bits: c_int, safe: c_int, add: *mut BIGNUM, rem: *mut BIGNUM, cb: *const c_void) -> c_int; pub fn BN_is_prime_ex(p: *mut BIGNUM, checks: c_int, ctx: *mut BN_CTX, cb: *const c_void) -> c_int; diff --git a/src/ssl/tests.rs b/src/ssl/tests.rs index 0e6edbf7..50c24b94 100644 --- a/src/ssl/tests.rs +++ b/src/ssl/tests.rs @@ -221,3 +221,16 @@ fn test_cert_gen() { // FIXME: check data in result to be correct, needs implementation // of X509 getters } + +#[test] +fn test_bn_is_zero() { + use ffi; + use std::ptr; + + unsafe { + let bn = ffi::BN_new(); + assert!(bn != ptr::null_mut()); + // Just make sure it is linked and resolved correctly + ffi::BN_is_zero(bn); + } +} |