From 75ec270230cb361293d62f79710ccae4dd39bb01 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Fri, 16 Apr 2021 05:47:08 +0300 Subject: Almost passsing auth --- src/handlers.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs index 376d079..2401c0d 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -139,8 +139,9 @@ pub async fn authenticate_user( } }; - // TODO: request iv is coming with base64 encoding <16-04-21, yigit> // - let cipher = match Aes128Cbc::new_var(&temp_key, &request.iv.as_bytes()) { + let byte_iv = base64::decode(&request.iv).unwrap(); + + let cipher = match Aes128Cbc::new_var(&temp_key, &byte_iv) { Ok(c) => c, Err(err) => { debug!( @@ -175,17 +176,19 @@ pub async fn authenticate_user( } }; + println!(">>>{:?}<<<", auth_packet); + let auth_plaintext = match cipher.decrypt_vec(&auth_packet) { Ok(p) => p, Err(err) => { - debug!( + println!( "Base64 decoded auth request did not decrypt correctly {:?} {}", &auth_packet, err ); let res_json = warp::reply::json(&GradeCoinResponse { res: ResponseType::Error, - message: "The Bas64 decoded auth request did not decrypt correctly".to_owned(), + message: "The Base64 decoded auth request did not decrypt correctly".to_owned(), }); return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); @@ -608,7 +611,8 @@ pub async fn authorized_propose_transaction( // this transaction was already checked for correctness at custom_filters, we can panic here if // it has been changed since - let hashed_transaction = Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); + let hashed_transaction = + Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); if token_payload.claims.tha != format!("{:x}", hashed_transaction) { println!( "the hash of the request {:x} did not match the hash given in jwt {:?}", -- cgit v1.2.3-70-g09d2