aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/handlers.rs14
-rw-r--r--tests/route_tests.rs8
2 files changed, 12 insertions, 10 deletions
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(
139 } 139 }
140 }; 140 };
141 141
142 // TODO: request iv is coming with base64 encoding <16-04-21, yigit> // 142 let byte_iv = base64::decode(&request.iv).unwrap();
143 let cipher = match Aes128Cbc::new_var(&temp_key, &request.iv.as_bytes()) { 143
144 let cipher = match Aes128Cbc::new_var(&temp_key, &byte_iv) {
144 Ok(c) => c, 145 Ok(c) => c,
145 Err(err) => { 146 Err(err) => {
146 debug!( 147 debug!(
@@ -175,17 +176,19 @@ pub async fn authenticate_user(
175 } 176 }
176 }; 177 };
177 178
179 println!(">>>{:?}<<<", auth_packet);
180
178 let auth_plaintext = match cipher.decrypt_vec(&auth_packet) { 181 let auth_plaintext = match cipher.decrypt_vec(&auth_packet) {
179 Ok(p) => p, 182 Ok(p) => p,
180 Err(err) => { 183 Err(err) => {
181 debug!( 184 println!(
182 "Base64 decoded auth request did not decrypt correctly {:?} {}", 185 "Base64 decoded auth request did not decrypt correctly {:?} {}",
183 &auth_packet, err 186 &auth_packet, err
184 ); 187 );
185 188
186 let res_json = warp::reply::json(&GradeCoinResponse { 189 let res_json = warp::reply::json(&GradeCoinResponse {
187 res: ResponseType::Error, 190 res: ResponseType::Error,
188 message: "The Bas64 decoded auth request did not decrypt correctly".to_owned(), 191 message: "The Base64 decoded auth request did not decrypt correctly".to_owned(),
189 }); 192 });
190 193
191 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); 194 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST));
@@ -608,7 +611,8 @@ pub async fn authorized_propose_transaction(
608 // this transaction was already checked for correctness at custom_filters, we can panic here if 611 // this transaction was already checked for correctness at custom_filters, we can panic here if
609 // it has been changed since 612 // it has been changed since
610 613
611 let hashed_transaction = Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); 614 let hashed_transaction =
615 Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref());
612 if token_payload.claims.tha != format!("{:x}", hashed_transaction) { 616 if token_payload.claims.tha != format!("{:x}", hashed_transaction) {
613 println!( 617 println!(
614 "the hash of the request {:x} did not match the hash given in jwt {:?}", 618 "the hash of the request {:x} did not match the hash given in jwt {:?}",
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index 0b7628c..537b3d8 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -266,8 +266,6 @@ FQIDAQAB
266 let db = mocked_db(); 266 let db = mocked_db();
267 let filter = consensus_routes(db.clone()); 267 let filter = consensus_routes(db.clone());
268 268
269
270
271 let res = warp::test::request() 269 let res = warp::test::request()
272 .method("POST") 270 .method("POST")
273 .json(&Block { 271 .json(&Block {
@@ -447,9 +445,9 @@ FQIDAQAB
447 let res = warp::test::request() 445 let res = warp::test::request()
448 .method("POST") 446 .method("POST")
449 .json(&InitialAuthRequest { 447 .json(&InitialAuthRequest {
450 c: "llqkPAX8oGxBLFHGMNzwrCAP2WmsGZlOcm3mCp7+ZnX9p7BPffRvGcYHpif4htwU5RyR3fLo/VWERXqddVQkxhfuum0dFn1cpPfYTokc2BHpi61i4SXCaCHlJDxCtCKnujfEzMnS5hAKMQSyrwq/DPBwOSQ/XQeeMB0YF+l+ZfVJ8e6sQ5FfSK9rSInv+TokA7az6vR7Ky5fGjQ0GxKkO+SKLd5eHuGKgQ19JUQrj3k19GJn1h1cmWW1PYqVKFDp/RfWFL9weG8VynRND6xGK5fQarjdG0uMAk8Cy8ItOCAeMnBhUv/P2a721u3tA7L496r4E3ZwdgsiHe4iYzFiAdvWDWsLRlxXS+6Q2vUYSLgcFVsv2jyQ28c/ay3F1hYAHaqN4HiDhKz6bFCiyow1Doya2V24VQm5eUGxXErjEnLY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),
452 key: "baz".to_owned(), 450 key: "s4cn9BSmuForX6PxJAa55Es4t2puXuDtdII1lxEArqVlP+uYd5jDKofFtn9PCAoY7jyTgBIhQW7Ah5MGCcufWTaKHAjFVfSZ+qGwbGbBcklbNGH/F7cJ0Pe7kOCddUpIvLG6WH6+mnvyPs8PwDyagsx1Jc2PSSOYLAwkECvPbjiUjQiBixguTRNsU2eKaqzLimPE0w2ztvdA+IgCv94UPhjQfQrnMGK+Ppn3oK7IfKQJ7v2DLVNuz4d/BpwuqD+lYYAu4B4qn3daNR32a/mqAAlPg/RbPlH69N44Qh/NYux90FOY0XKxUskEwsAUw8dHFzzdKPcGx4C0s5e4KSLGkw==".to_owned(),
453 }) 451 })
454 .path("/register") 452 .path("/register")
455 .reply(&filter) 453 .reply(&filter)