diff --git a/Cargo.toml b/Cargo.toml index ecba3bf..794c8de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptohelpers" -version = "1.8.0" +version = "1.8.1" license= "MIT" description = "Collection of helpers and simplifying functions for cryptography things" authors = ["Avril "] diff --git a/src/rsa/components.rs b/src/rsa/components.rs index d578b15..b2c00a9 100644 --- a/src/rsa/components.rs +++ b/src/rsa/components.rs @@ -27,7 +27,7 @@ pub trait HasPublicComponents: HasComponents /// This can panic if the internal state of the instance is incorrect #[inline] fn num_e(&self) -> BigNum { - BigNum::from_slice(self.n()).unwrap() + BigNum::from_slice(self.e()).unwrap() } } diff --git a/src/rsa/crypt.rs b/src/rsa/crypt.rs index 87cb1d0..8e0c517 100644 --- a/src/rsa/crypt.rs +++ b/src/rsa/crypt.rs @@ -107,7 +107,8 @@ where T: Read + ?Sized, let mut done=0; while {read = data.read(&mut read_buffer[..])?; read!=0} { done+=read; - read = key.public_encrypt(&read_buffer[..read], &mut crypt_buffer[..], PADDING).map_err(|_| Error::Encrypt)?; + read = key.public_encrypt(&read_buffer[..read], &mut crypt_buffer[..], PADDING).map_err(|ssl| {eprintln!("SSL err: {}", ssl); Error::Encrypt})?; + output.write_all(&crypt_buffer[..read])?; } @@ -125,7 +126,7 @@ where T: AsRef<[u8]>, let mut crypt_buffer = vec![0u8; key_size]; - let read = key.public_encrypt(data.as_ref(), &mut crypt_buffer[..], PADDING).map_err(|_| Error::Encrypt)?; + let read = key.public_encrypt(data.as_ref(), &mut crypt_buffer[..], PADDING).map_err(|ssl| {eprintln!("SSL err: {}", ssl); Error::Encrypt})?; output.write_all(&crypt_buffer[..read])?; Ok(read) diff --git a/src/rsa/mod.rs b/src/rsa/mod.rs index 6061d8b..e0e7d92 100644 --- a/src/rsa/mod.rs +++ b/src/rsa/mod.rs @@ -1,5 +1,6 @@ //! RSA related thingies use super::*; +pub use openssl; use consts::RSA_PADDING as PADDING;