Unverified Commit 3d2ac916 authored by Jonas Platte's avatar Jonas Platte
Browse files

Use crate in imports in the openssl crate

This was mostly automated using `cargo fix --edition`, except imports of
openssl_sys (renamed to ffi) were converted to crate::ffi, which was
reverted.

The same thing is not done for the openssl-sys crate because this breaks
ctest (used in systest to verify the -sys crate), see
https://github.com/gnzlbg/ctest/issues/70
parent d68077d2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ use ffi;
use libc::{c_int, c_uint};
use std::{mem, ptr};

use symm::Mode;
use crate::symm::Mode;

/// Provides Error handling for parsing keys.
#[derive(Debug)]
@@ -240,7 +240,7 @@ mod test {
    use hex::FromHex;

    use super::*;
    use symm::Mode;
    use crate::symm::Mode;

    // From https://www.mgp25.com/AESIGE/
    #[test]
+11 −11
Original line number Diff line number Diff line
@@ -35,12 +35,12 @@ use std::ptr;
use std::slice;
use std::str;

use bio::MemBio;
use bn::{BigNum, BigNumRef};
use error::ErrorStack;
use nid::Nid;
use string::OpensslString;
use {cvt, cvt_p};
use crate::bio::MemBio;
use crate::bn::{BigNum, BigNumRef};
use crate::error::ErrorStack;
use crate::nid::Nid;
use crate::string::OpensslString;
use crate::{cvt, cvt_p};

foreign_type_and_impl_send_sync! {
    type CType = ffi::ASN1_GENERALIZEDTIME;
@@ -526,7 +526,7 @@ impl Asn1IntegerRef {
    #[allow(missing_docs)]
    #[deprecated(since = "0.10.6", note = "use to_bn instead")]
    pub fn get(&self) -> i64 {
        unsafe { ::ffi::ASN1_INTEGER_get(self.as_ptr()) as i64 }
        unsafe { ffi::ASN1_INTEGER_get(self.as_ptr()) as i64 }
    }

    /// Converts the integer to a `BigNum`.
@@ -536,7 +536,7 @@ impl Asn1IntegerRef {
    /// [`ASN1_INTEGER_to_BN`]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_INTEGER_get.html
    pub fn to_bn(&self) -> Result<BigNum, ErrorStack> {
        unsafe {
            cvt_p(::ffi::ASN1_INTEGER_to_BN(self.as_ptr(), ptr::null_mut()))
            cvt_p(ffi::ASN1_INTEGER_to_BN(self.as_ptr(), ptr::null_mut()))
                .map(|p| BigNum::from_ptr(p))
        }
    }
@@ -549,7 +549,7 @@ impl Asn1IntegerRef {
    /// [`bn`]: ../bn/struct.BigNumRef.html#method.to_asn1_integer
    /// [`ASN1_INTEGER_set`]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_INTEGER_set.html
    pub fn set(&mut self, value: i32) -> Result<(), ErrorStack> {
        unsafe { cvt(::ffi::ASN1_INTEGER_set(self.as_ptr(), value as c_long)).map(|_| ()) }
        unsafe { cvt(ffi::ASN1_INTEGER_set(self.as_ptr(), value as c_long)).map(|_| ()) }
    }
}

@@ -674,8 +674,8 @@ cfg_if! {
mod tests {
    use super::*;

    use bn::BigNum;
    use nid::Nid;
    use crate::bn::BigNum;
    use crate::nid::Nid;

    /// Tests conversion between BigNum and Asn1Integer.
    #[test]
+2 −2
Original line number Diff line number Diff line
//! Base64 encoding support.
use cvt_n;
use error::ErrorStack;
use crate::cvt_n;
use crate::error::ErrorStack;
use ffi;
use libc::c_int;

+2 −2
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@ use std::marker::PhantomData;
use std::ptr;
use std::slice;

use cvt_p;
use error::ErrorStack;
use crate::cvt_p;
use crate::error::ErrorStack;

pub struct MemBioSlice<'a>(*mut ffi::BIO, PhantomData<&'a [u8]>);

+5 −5
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@ use std::ffi::CString;
use std::ops::{Add, Deref, Div, Mul, Neg, Rem, Shl, Shr, Sub};
use std::{fmt, ptr};

use asn1::Asn1Integer;
use error::ErrorStack;
use string::OpensslString;
use {cvt, cvt_n, cvt_p};
use crate::asn1::Asn1Integer;
use crate::error::ErrorStack;
use crate::string::OpensslString;
use crate::{cvt, cvt_n, cvt_p};

cfg_if! {
    if #[cfg(ossl110)] {
@@ -1376,7 +1376,7 @@ impl Neg for BigNum {

#[cfg(test)]
mod tests {
    use bn::{BigNum, BigNumContext};
    use crate::bn::{BigNum, BigNumContext};

    #[test]
    fn test_to_from_slice() {
Loading