From a988eb42a271e372450479539ba4c058ebedc91c Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 12 Jun 2021 13:32:38 +0200 Subject: [PATCH] Properly use the odoh-rs API --- src/libdoh/src/lib.rs | 2 -- src/libdoh/src/odoh.rs | 10 ++-------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/libdoh/src/lib.rs b/src/libdoh/src/lib.rs index 9aff743..4bed29d 100644 --- a/src/libdoh/src/lib.rs +++ b/src/libdoh/src/lib.rs @@ -192,12 +192,10 @@ impl DoH { Ok((q, context)) => (q.to_vec(), context), Err(e) => return http_error(StatusCode::from(e)), }; - let resp = match self.proxy(query).await { Ok(resp) => resp, Err(e) => return http_error(StatusCode::from(e)), }; - let encrypted_resp = match context.encrypt_response(resp.packet) { Ok(resp) => self.build_response(resp, 0u32, DoHType::Oblivious.as_str()), Err(e) => return http_error(StatusCode::from(e)), diff --git a/src/libdoh/src/odoh.rs b/src/libdoh/src/odoh.rs index 04907b2..29c16cd 100644 --- a/src/libdoh/src/odoh.rs +++ b/src/libdoh/src/odoh.rs @@ -70,20 +70,14 @@ impl ODoHPublicKey { query: query.clone(), server_secret, }; - let mut query_bytes = Vec::new(); - query - .serialize(&mut query_bytes) - .map_err(|_| DoHError::InvalidData)?; - Ok((query_bytes, context)) + Ok((query.into_msg().to_vec(), context)) } } impl ODoHQueryContext { pub fn encrypt_response(self, response_body: Vec) -> Result, DoHError> { let response_nonce = rand::thread_rng().gen::(); - let response_body_ = - ObliviousDoHMessagePlaintext::deserialize(&mut bytes::Bytes::from(response_body)) - .map_err(|_| DoHError::InvalidData)?; + let response_body_ = ObliviousDoHMessagePlaintext::new(response_body, 0); let encrypted_response = odoh_rs::encrypt_response( &self.query, &response_body_,