From ecae8ea43cf5a9e222f6dd62e286f4683a00a8fd Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Tue, 14 Feb 2017 13:36:45 -0500 Subject: [PATCH] Get more tests working --- src/claims.rs | 4 ++-- src/crypt.rs | 6 +++--- src/lib.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/claims.rs b/src/claims.rs index f123ce5..40d559f 100644 --- a/src/claims.rs +++ b/src/claims.rs @@ -1,4 +1,4 @@ -use base64::{decode, encode_config, URL_SAFE}; +use base64::{decode_config, encode_config, URL_SAFE}; use Component; use error::Error; use serde::{Deserialize, Serialize}; @@ -33,7 +33,7 @@ impl Claims{ impl Component for Claims { fn from_base64(raw: &str) -> Result, Error> { - let data = try!(decode(raw)); + let data = try!(decode_config(raw, URL_SAFE)); let reg_claims: Registered = try!(serde_json::from_slice(&data)); let pri_claims: T = try!(serde_json::from_slice(&data)); diff --git a/src/crypt.rs b/src/crypt.rs index 6a117cf..570305b 100644 --- a/src/crypt.rs +++ b/src/crypt.rs @@ -1,4 +1,4 @@ -use base64::{decode, encode_config, URL_SAFE}; +use base64::{decode_config, encode_config, URL_SAFE}; use openssl::hash::MessageDigest; use openssl::memcmp; use openssl::pkey::PKey; @@ -26,7 +26,7 @@ pub fn sign_rsa(data: &str, key: &[u8], digest: MessageDigest) -> String { } pub fn verify(target: &str, data: &str, key: &[u8], digest: MessageDigest) -> bool { - let target_bytes: Vec = decode(target).unwrap(); + let target_bytes: Vec = decode_config(target, URL_SAFE).unwrap(); let secret_key = PKey::hmac(key).unwrap(); let mut signer = Signer::new(digest, &secret_key).unwrap(); @@ -38,7 +38,7 @@ pub fn verify(target: &str, data: &str, key: &[u8], digest: MessageDigest) -> bo } pub fn verify_rsa(signature: &str, data: &str, key: &[u8], digest: MessageDigest) -> bool { - let signature_bytes: Vec = decode(signature).unwrap(); + let signature_bytes: Vec = decode_config(signature, URL_SAFE).unwrap(); let public_key = Rsa::public_key_from_pem(key).unwrap(); let pkey = PKey::from_rsa(public_key).unwrap(); let mut verifier = Verifier::new(digest, &pkey).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 1fa0d15..d0e1a38 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ extern crate serde; extern crate serde_derive; extern crate serde_json; -use base64::{decode, encode_config, URL_SAFE}; +use base64::{decode_config, encode_config, URL_SAFE}; use openssl::hash::MessageDigest; use serde::{Serialize, Deserialize}; pub use error::Error; @@ -41,7 +41,7 @@ impl Component for T /// Parse from a string. fn from_base64(raw: &str) -> Result { - let data = try!(decode(raw)); + let data = try!(decode_config(raw, URL_SAFE)); let s = try!(String::from_utf8(data)); Ok(try!(serde_json::from_str(&*s))) }