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

Implement type conversions on BigNum #1214

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
default: false
image:
type: string
default: 1.33.0
default: 1.34.0
minimal_build:
type: boolean
default: false
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
default: false
image:
type: string
default: 1.33.0
default: 1.34.0
macos:
xcode: "9.0"
environment:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update 1.31.0 && rustup default 1.31.0
run: rustup update 1.34.0 && rustup default 1.34.0
- name: Get rust version
id: rust-version
run: echo "::set-output name=version::$(rustc --version)"
Expand Down
6 changes: 6 additions & 0 deletions openssl-sys/src/bn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ extern "C" {
pub fn BN_clear_free(bn: *mut BIGNUM);
pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM;
pub fn BN_bn2bin(a: *const BIGNUM, to: *mut u8) -> c_int;
#[cfg(ossl110)]
pub fn BN_lebin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM;
#[cfg(ossl110)]
pub fn BN_bn2binpad(a: *const BIGNUM, to: *mut u8, tolen: c_int) -> c_int;
#[cfg(ossl110)]
pub fn BN_bn2lebinpad(a: *const BIGNUM, to: *mut u8, tolen: c_int) -> c_int;
pub fn BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
pub fn BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
Expand Down
6 changes: 3 additions & 3 deletions openssl/src/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
//!
use ffi;
use libc::{c_int, c_uint};
use std::{mem, ptr};
use std::ptr;

use symm::Mode;

Expand All @@ -79,7 +79,7 @@ impl AesKey {
unsafe {
assert!(key.len() <= c_int::max_value() as usize / 8);

let mut aes_key = mem::uninitialized();
let mut aes_key = super::uninitialized();
let r = ffi::AES_set_encrypt_key(
key.as_ptr() as *const _,
key.len() as c_int * 8,
Expand All @@ -103,7 +103,7 @@ impl AesKey {
unsafe {
assert!(key.len() <= c_int::max_value() as usize / 8);

let mut aes_key = mem::uninitialized();
let mut aes_key = super::uninitialized();
let r = ffi::AES_set_decrypt_key(
key.as_ptr() as *const _,
key.len() as c_int * 8,
Expand Down
6 changes: 4 additions & 2 deletions openssl/src/asn1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,12 @@ mod tests {
assert_eq!(large.to_bn().unwrap(), bn);
}

use std::convert::TryFrom;

roundtrip(BigNum::from_dec_str("1000000000000000000000000000000000").unwrap());
roundtrip(-BigNum::from_dec_str("1000000000000000000000000000000000").unwrap());
roundtrip(BigNum::from_u32(1234).unwrap());
roundtrip(-BigNum::from_u32(1234).unwrap());
roundtrip(BigNum::try_from(1234).unwrap());
roundtrip(-BigNum::try_from(1234).unwrap());
}

#[test]
Expand Down
Loading