Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Nov 30, 2023
1 parent 403a60e commit 2016d44
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/algorithms/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl AsRef<Rsa<Private>> for RSAKeyPair {
impl RSAKeyPair {
pub fn from_der(der: &[u8]) -> Result<Self, Error> {
let rsa_sk = Rsa::<Private>::private_key_from_der(der)?;
if rsa_sk.check_key()? == false {
if !(rsa_sk.check_key()?) {
bail!(JWTError::InvalidKeyPair);
}
Ok(RSAKeyPair {
Expand All @@ -97,7 +97,7 @@ impl RSAKeyPair {
pub fn from_pem(pem: &str) -> Result<Self, Error> {
let pem = pem.trim();
let rsa_sk = Rsa::<Private>::private_key_from_pem(pem.as_bytes())?;
if rsa_sk.check_key()? == false {
if !(rsa_sk.check_key()?) {
bail!(JWTError::InvalidKeyPair);
}
Ok(RSAKeyPair {
Expand Down Expand Up @@ -192,10 +192,9 @@ pub trait RSAPublicKeyLike {
let pkey = PKey::from_rsa(self.public_key().as_ref().clone())?;
let mut verifier = Verifier::new(digest, &pkey)?;
verifier.update(authenticated.as_bytes())?;
if verifier
.verify(&signature)
.map_err(|_| JWTError::InvalidSignature)?
== false
if !(verifier
.verify(signature)
.map_err(|_| JWTError::InvalidSignature)?)
{
bail!(JWTError::InvalidSignature);
}
Expand Down

0 comments on commit 2016d44

Please sign in to comment.