Rsa: Fixed `num_e()` returning `n` (typo)

Fortune for cryptohelpers's current commit: Future blessing − 末吉
tokio-1.0
Avril 3 years ago
parent 95447dce6f
commit f3f6252933
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,6 +1,6 @@
[package] [package]
name = "cryptohelpers" name = "cryptohelpers"
version = "1.8.0" version = "1.8.1"
license= "MIT" license= "MIT"
description = "Collection of helpers and simplifying functions for cryptography things" description = "Collection of helpers and simplifying functions for cryptography things"
authors = ["Avril <flanchan@cumallover.me>"] authors = ["Avril <flanchan@cumallover.me>"]

@ -27,7 +27,7 @@ pub trait HasPublicComponents: HasComponents
/// This can panic if the internal state of the instance is incorrect /// This can panic if the internal state of the instance is incorrect
#[inline] fn num_e(&self) -> BigNum #[inline] fn num_e(&self) -> BigNum
{ {
BigNum::from_slice(self.n()).unwrap() BigNum::from_slice(self.e()).unwrap()
} }
} }

@ -107,7 +107,8 @@ where T: Read + ?Sized,
let mut done=0; let mut done=0;
while {read = data.read(&mut read_buffer[..])?; read!=0} { while {read = data.read(&mut read_buffer[..])?; read!=0} {
done+=read; 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])?; output.write_all(&crypt_buffer[..read])?;
} }
@ -125,7 +126,7 @@ where T: AsRef<[u8]>,
let mut crypt_buffer = vec![0u8; key_size]; 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])?; output.write_all(&crypt_buffer[..read])?;
Ok(read) Ok(read)

@ -1,5 +1,6 @@
//! RSA related thingies //! RSA related thingies
use super::*; use super::*;
pub use openssl;
use consts::RSA_PADDING as PADDING; use consts::RSA_PADDING as PADDING;

Loading…
Cancel
Save