This commit is contained in:
Steven Fackler 2016-11-05 10:54:17 -07:00
parent 71a114707f
commit f15c817c2d
5 changed files with 15 additions and 34 deletions

View File

@ -59,9 +59,7 @@ impl Asn1StringRef {
}
pub fn len(&self) -> usize {
unsafe {
ffi::ASN1_STRING_length(self.as_ptr()) as usize
}
unsafe { ffi::ASN1_STRING_length(self.as_ptr()) as usize }
}
}

View File

@ -365,22 +365,12 @@ impl BigNumRef {
/// * `bits`: Length of the number in bits.
/// * `msb`: The desired properties of the number.
/// * `odd`: If `true`, the generated number will be odd.
pub fn rand(&mut self,
bits: i32,
msb: MsbOption,
odd: bool)
-> Result<(), ErrorStack> {
unsafe {
cvt(ffi::BN_rand(self.as_ptr(), bits.into(), msb.0, odd as c_int)).map(|_| ())
}
pub fn rand(&mut self, bits: i32, msb: MsbOption, odd: bool) -> Result<(), ErrorStack> {
unsafe { cvt(ffi::BN_rand(self.as_ptr(), bits.into(), msb.0, odd as c_int)).map(|_| ()) }
}
/// The cryptographically weak counterpart to `rand`.
pub fn pseudo_rand(&mut self,
bits: i32,
msb: MsbOption,
odd: bool)
-> Result<(), ErrorStack> {
pub fn pseudo_rand(&mut self, bits: i32, msb: MsbOption, odd: bool) -> Result<(), ErrorStack> {
unsafe {
cvt(ffi::BN_pseudo_rand(self.as_ptr(), bits.into(), msb.0, odd as c_int)).map(|_| ())
}

View File

@ -215,9 +215,7 @@ fn get_dh() -> Result<Dh, ErrorStack> {
use types::OpenSslType;
// manually call into ffi to avoid forcing the features
unsafe {
cvt_p(ffi::DH_get_2048_256()).map(|p| Dh::from_ptr(p))
}
unsafe { cvt_p(ffi::DH_get_2048_256()).map(|p| Dh::from_ptr(p)) }
}
#[cfg(ossl101)]
@ -302,8 +300,7 @@ mod verify {
}
}
fn verify_subject_alt_names(domain: &str,
names: Stack<GeneralName>) -> bool {
fn verify_subject_alt_names(domain: &str, names: Stack<GeneralName>) -> bool {
let ip = domain.parse();
for name in &names {

View File

@ -10,8 +10,8 @@ use types::{OpenSslType, OpenSslTypeRef};
use util::Opaque;
#[cfg(ossl10x)]
use ffi::{sk_pop as OPENSSL_sk_pop,sk_free as OPENSSL_sk_free, sk_num as OPENSSL_sk_num,
sk_value as OPENSSL_sk_value};
use ffi::{sk_pop as OPENSSL_sk_pop, sk_free as OPENSSL_sk_free, sk_num as OPENSSL_sk_num,
sk_value as OPENSSL_sk_value};
#[cfg(ossl110)]
use ffi::{OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value};
@ -226,7 +226,8 @@ impl<'a, T: Stackable> iter::IntoIterator for &'a mut Stack<T> {
/// An iterator over the stack's contents.
pub struct Iter<'a, T: Stackable>
where T: 'a {
where T: 'a
{
stack: &'a StackRef<T>,
pos: usize,
}
@ -251,8 +252,7 @@ impl<'a, T: Stackable> iter::Iterator for Iter<'a, T> {
}
}
impl<'a, T: Stackable> iter::ExactSizeIterator for Iter<'a, T> {
}
impl<'a, T: Stackable> iter::ExactSizeIterator for Iter<'a, T> {}
/// A mutable iterator over the stack's contents.
pub struct IterMut<'a, T: Stackable + 'a> {
@ -272,9 +272,7 @@ impl<'a, T: Stackable> iter::Iterator for IterMut<'a, T> {
// guarantee that we won't return several references to
// the same object, so we have to use unsafe code for
// mutable iterators.
let n = unsafe {
Some(T::Ref::from_ptr_mut(self.stack._get(self.pos)))
};
let n = unsafe { Some(T::Ref::from_ptr_mut(self.stack._get(self.pos))) };
self.pos += 1;
@ -289,5 +287,4 @@ impl<'a, T: Stackable> iter::Iterator for IterMut<'a, T> {
}
}
impl<'a, T: Stackable> iter::ExactSizeIterator for IterMut<'a, T> {
}
impl<'a, T: Stackable> iter::ExactSizeIterator for IterMut<'a, T> {}

View File

@ -513,9 +513,8 @@ impl<'a> Iterator for X509NameEntries<'a> {
fn next(&mut self) -> Option<&'a X509NameEntryRef> {
unsafe {
self.loc = ffi::X509_NAME_get_index_by_NID(self.name.as_ptr(),
self.nid.as_raw(),
self.loc);
self.loc =
ffi::X509_NAME_get_index_by_NID(self.name.as_ptr(), self.nid.as_raw(), self.loc);
if self.loc == -1 {
return None;