Fix catch_unwind feature and drop feature gate
This commit is contained in:
parent
5cb04db787
commit
e86eb68624
|
|
@ -3,18 +3,15 @@ use std::fmt;
|
||||||
use error::ErrorStack;
|
use error::ErrorStack;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use libc::{c_uint, c_int};
|
use libc::{c_uint, c_int, c_char, c_void};
|
||||||
|
|
||||||
use bn::BigNum;
|
use bn::BigNum;
|
||||||
use bio::MemBio;
|
use bio::MemBio;
|
||||||
use crypto::hash;
|
use crypto::hash;
|
||||||
use crypto::HashTypeInternals;
|
use crypto::HashTypeInternals;
|
||||||
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
use libc::{c_char, c_void};
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
use crypto::util::{CallbackState, invoke_passwd_cb};
|
use crypto::util::{CallbackState, invoke_passwd_cb};
|
||||||
|
|
||||||
|
|
||||||
/// Builder for upfront DSA parameter generateration
|
/// Builder for upfront DSA parameter generateration
|
||||||
pub struct DSAParams(*mut ffi::DSA);
|
pub struct DSAParams(*mut ffi::DSA);
|
||||||
|
|
||||||
|
|
@ -94,15 +91,12 @@ impl DSA {
|
||||||
///
|
///
|
||||||
/// The callback will be passed the password buffer and should return the number of characters
|
/// The callback will be passed the password buffer and should return the number of characters
|
||||||
/// placed into the buffer.
|
/// placed into the buffer.
|
||||||
///
|
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> io::Result<DSA>
|
||||||
/// Requires the `catch_unwind` feature.
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> Result<DSA, ErrorStack>
|
|
||||||
where R: Read, F: FnOnce(&mut [c_char]) -> usize
|
where R: Read, F: FnOnce(&mut [c_char]) -> usize
|
||||||
{
|
{
|
||||||
let mut cb = CallbackState::new(pass_cb);
|
let mut cb = CallbackState::new(pass_cb);
|
||||||
let mut mem_bio = try!(MemBio::new());
|
let mut mem_bio = try!(MemBio::new());
|
||||||
try!(io::copy(reader, &mut mem_bio).map_err(StreamError));
|
try!(io::copy(reader, &mut mem_bio));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let cb_ptr = &mut cb as *mut _ as *mut c_void;
|
let cb_ptr = &mut cb as *mut _ as *mut c_void;
|
||||||
|
|
@ -331,7 +325,6 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
pub fn test_password() {
|
pub fn test_password() {
|
||||||
let mut password_queried = false;
|
let mut password_queried = false;
|
||||||
let mut buffer = File::open("test/dsa-encrypted.pem").unwrap();
|
let mut buffer = File::open("test/dsa-encrypted.pem").unwrap();
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ pub mod symm;
|
||||||
pub mod memcmp;
|
pub mod memcmp;
|
||||||
pub mod rsa;
|
pub mod rsa;
|
||||||
pub mod dsa;
|
pub mod dsa;
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
mod symm_internal;
|
mod symm_internal;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use libc::{c_int, c_uint, c_ulong};
|
use libc::{c_int, c_uint, c_ulong, c_void, c_char};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
|
|
@ -12,10 +12,6 @@ use crypto::hash::Type as HashType;
|
||||||
use ffi;
|
use ffi;
|
||||||
use crypto::rsa::RSA;
|
use crypto::rsa::RSA;
|
||||||
use error::ErrorStack;
|
use error::ErrorStack;
|
||||||
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
use libc::{c_void, c_char};
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
use crypto::util::{CallbackState, invoke_passwd_cb};
|
use crypto::util::{CallbackState, invoke_passwd_cb};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
|
@ -104,16 +100,13 @@ impl PKey {
|
||||||
///
|
///
|
||||||
/// The callback will be passed the password buffer and should return the number of characters
|
/// The callback will be passed the password buffer and should return the number of characters
|
||||||
/// placed into the buffer.
|
/// placed into the buffer.
|
||||||
///
|
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> io::Result<PKey>
|
||||||
/// Requires the `catch_unwind` feature.
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> Result<PKey, SslError>
|
|
||||||
where R: Read, F: FnOnce(&mut [c_char]) -> usize
|
where R: Read, F: FnOnce(&mut [c_char]) -> usize
|
||||||
{
|
{
|
||||||
let mut cb = CallbackState::new(pass_cb);
|
let mut cb = CallbackState::new(pass_cb);
|
||||||
|
|
||||||
let mut mem_bio = try!(MemBio::new());
|
let mut mem_bio = try!(MemBio::new());
|
||||||
try!(io::copy(reader, &mut mem_bio).map_err(StreamError));
|
try!(io::copy(reader, &mut mem_bio));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let evp = try_ssl_null!(ffi::PEM_read_bio_PrivateKey(mem_bio.get_handle(),
|
let evp = try_ssl_null!(ffi::PEM_read_bio_PrivateKey(mem_bio.get_handle(),
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,13 @@ use ffi;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use libc::c_int;
|
use libc::{c_int, c_void, c_char};
|
||||||
|
|
||||||
use bn::BigNum;
|
use bn::BigNum;
|
||||||
use bio::MemBio;
|
use bio::MemBio;
|
||||||
use error::ErrorStack;
|
use error::ErrorStack;
|
||||||
use crypto::HashTypeInternals;
|
use crypto::HashTypeInternals;
|
||||||
use crypto::hash;
|
use crypto::hash;
|
||||||
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
use libc::{c_void, c_char};
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
use crypto::util::{CallbackState, invoke_passwd_cb};
|
use crypto::util::{CallbackState, invoke_passwd_cb};
|
||||||
|
|
||||||
pub struct RSA(*mut ffi::RSA);
|
pub struct RSA(*mut ffi::RSA);
|
||||||
|
|
@ -82,16 +78,13 @@ impl RSA {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads an RSA private key from PEM formatted data and supplies a password callback.
|
/// Reads an RSA private key from PEM formatted data and supplies a password callback.
|
||||||
///
|
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> io::Result<RSA>
|
||||||
/// Requires the `catch_unwind` feature.
|
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> Result<RSA, ErrorStack>
|
|
||||||
where R: Read, F: FnOnce(&mut [c_char]) -> usize
|
where R: Read, F: FnOnce(&mut [c_char]) -> usize
|
||||||
{
|
{
|
||||||
let mut cb = CallbackState::new(pass_cb);
|
let mut cb = CallbackState::new(pass_cb);
|
||||||
|
|
||||||
let mut mem_bio = try!(MemBio::new());
|
let mut mem_bio = try!(MemBio::new());
|
||||||
try!(io::copy(reader, &mut mem_bio).map_err(StreamError));
|
try!(io::copy(reader, &mut mem_bio));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let cb_ptr = &mut cb as *mut _ as *mut c_void;
|
let cb_ptr = &mut cb as *mut _ as *mut c_void;
|
||||||
|
|
@ -303,7 +296,6 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "catch_unwind")]
|
|
||||||
pub fn test_password() {
|
pub fn test_password() {
|
||||||
let mut password_queried = false;
|
let mut password_queried = false;
|
||||||
let mut buffer = File::open("test/rsa-encrypted.pem").unwrap();
|
let mut buffer = File::open("test/rsa-encrypted.pem").unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue