diff options
| author | Bradley Beddoes <[email protected]> | 2017-08-09 13:21:57 +1000 |
|---|---|---|
| committer | Bradley Beddoes <[email protected]> | 2017-08-09 13:34:08 +1000 |
| commit | 16e8fbc31ee2f144b43a0a8353d6f85514081bf3 (patch) | |
| tree | fa92ca800bfac4008e7ba31b518f33a666cf23b6 | |
| parent | Set the private key within EcKeyBuilder (diff) | |
| download | rust-openssl-16e8fbc31ee2f144b43a0a8353d6f85514081bf3.tar.xz rust-openssl-16e8fbc31ee2f144b43a0a8353d6f85514081bf3.zip | |
Fix EC_KEY_set_public_key_affine_coordinates
Previous definition incorrectly used `const` pointers but the
underpinning library definition (unfortunately) does not.
| -rw-r--r-- | openssl-sys/src/lib.rs | 2 | ||||
| -rw-r--r-- | openssl/src/ec.rs | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 69c95395..f0e3e18a 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -1674,7 +1674,7 @@ extern "C" { pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int; pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int; pub fn EC_KEY_free(key: *mut EC_KEY); - pub fn EC_KEY_set_public_key_affine_coordinates(key: *mut EC_KEY, x: *const BIGNUM, y: *const BIGNUM) -> c_int; + pub fn EC_KEY_set_public_key_affine_coordinates(key: *mut EC_KEY, x: *mut BIGNUM, y: *mut BIGNUM) -> c_int; #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] pub fn EC_GF2m_simple_method() -> *const EC_METHOD; diff --git a/openssl/src/ec.rs b/openssl/src/ec.rs index e221b411..0a3cfcb6 100644 --- a/openssl/src/ec.rs +++ b/openssl/src/ec.rs @@ -462,8 +462,8 @@ impl EcKeyBuilderRef { /// Sets the public key based on affine coordinates. pub fn set_public_key_affine_coordinates(&mut self, - x: &BigNumRef, - y: &BigNumRef) + x: &mut BigNumRef, + y: &mut BigNumRef) -> Result<&mut EcKeyBuilderRef, ErrorStack> { unsafe { cvt(ffi::EC_KEY_set_public_key_affine_coordinates(self.as_ptr(), @@ -571,12 +571,12 @@ mod test { let y = data_encoding::base64url::decode_nopad("4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM".as_bytes()) .unwrap(); - let xbn = BigNum::from_slice(&x).unwrap(); - let ybn = BigNum::from_slice(&y).unwrap(); + let mut xbn = BigNum::from_slice(&x).unwrap(); + let mut ybn = BigNum::from_slice(&y).unwrap(); let mut builder = EcKeyBuilder::new().unwrap(); builder.set_group(&group).unwrap(); - builder.set_public_key_affine_coordinates(&xbn, &ybn).unwrap(); + builder.set_public_key_affine_coordinates(&mut xbn, &mut ybn).unwrap(); let ec_key = builder.build(); assert!(ec_key.check_key().is_ok()); |