Fix add of req id
This commit is contained in:
@@ -20,6 +20,7 @@ pub struct AuthenticatorRequest {
|
||||
pub version: u8,
|
||||
pub data: AuthenticatorRequestData,
|
||||
pub reply_to: Recipient,
|
||||
pub request_id: u64,
|
||||
}
|
||||
|
||||
impl AuthenticatorRequest {
|
||||
@@ -37,6 +38,7 @@ impl AuthenticatorRequest {
|
||||
version: VERSION,
|
||||
data: AuthenticatorRequestData::Initial(init_message),
|
||||
reply_to,
|
||||
request_id,
|
||||
},
|
||||
request_id,
|
||||
)
|
||||
@@ -49,6 +51,7 @@ impl AuthenticatorRequest {
|
||||
version: VERSION,
|
||||
data: AuthenticatorRequestData::Final(gateway_client),
|
||||
reply_to,
|
||||
request_id,
|
||||
},
|
||||
request_id,
|
||||
)
|
||||
|
||||
@@ -19,19 +19,27 @@ pub struct AuthenticatorResponse {
|
||||
impl AuthenticatorResponse {
|
||||
pub fn new_pending_registration_success(
|
||||
registration_data: RegistrationData,
|
||||
request_id: u64,
|
||||
reply_to: Recipient,
|
||||
) -> Self {
|
||||
Self {
|
||||
version: VERSION,
|
||||
data: AuthenticatorResponseData::PendingRegistration(registration_data),
|
||||
data: AuthenticatorResponseData::PendingRegistration(PendingRegistrationResponse {
|
||||
reply: registration_data,
|
||||
reply_to,
|
||||
request_id,
|
||||
}),
|
||||
reply_to,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_registered(reply_to: Recipient) -> Self {
|
||||
pub fn new_registered(reply_to: Recipient, request_id: u64) -> Self {
|
||||
Self {
|
||||
version: VERSION,
|
||||
data: AuthenticatorResponseData::Registered,
|
||||
data: AuthenticatorResponseData::Registered(RegisteredResponse {
|
||||
reply_to,
|
||||
request_id,
|
||||
}),
|
||||
reply_to,
|
||||
}
|
||||
}
|
||||
@@ -54,8 +62,8 @@ impl AuthenticatorResponse {
|
||||
|
||||
pub fn id(&self) -> Option<u64> {
|
||||
match &self.data {
|
||||
AuthenticatorResponseData::PendingRegistration(registration_data) => {}
|
||||
AuthenticatorResponseData::Registered => None,
|
||||
AuthenticatorResponseData::PendingRegistration(response) => Some(response.request_id),
|
||||
AuthenticatorResponseData::Registered(response) => Some(response.request_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ impl MixnetListener {
|
||||
fn on_initial_request(
|
||||
&mut self,
|
||||
init_message: InitMessage,
|
||||
request_id: u64,
|
||||
reply_to: Recipient,
|
||||
) -> AuthenticatorHandleResult {
|
||||
let remote_public = init_message.pub_key();
|
||||
@@ -131,6 +132,7 @@ impl MixnetListener {
|
||||
if let Some(registration_data) = self.registration_in_progres.get(&remote_public) {
|
||||
return Ok(AuthenticatorResponse::new_pending_registration_success(
|
||||
registration_data.value().clone(),
|
||||
request_id,
|
||||
reply_to,
|
||||
));
|
||||
}
|
||||
@@ -177,6 +179,7 @@ impl MixnetListener {
|
||||
|
||||
Ok(AuthenticatorResponse::new_pending_registration_success(
|
||||
registration_data,
|
||||
request_id,
|
||||
reply_to,
|
||||
))
|
||||
}
|
||||
@@ -184,6 +187,7 @@ impl MixnetListener {
|
||||
fn on_final_request(
|
||||
&mut self,
|
||||
gateway_client: GatewayClient,
|
||||
request_id: u64,
|
||||
reply_to: Recipient,
|
||||
) -> AuthenticatorHandleResult {
|
||||
let registration_data = self
|
||||
@@ -211,7 +215,7 @@ impl MixnetListener {
|
||||
.client_registry()
|
||||
.insert(gateway_client.pub_key(), gateway_client);
|
||||
|
||||
Ok(AuthenticatorResponse::new_registered(reply_to))
|
||||
Ok(AuthenticatorResponse::new_registered(reply_to, request_id))
|
||||
} else {
|
||||
Err(AuthenticatorError::MacVerificationFailure)
|
||||
}
|
||||
@@ -235,10 +239,10 @@ impl MixnetListener {
|
||||
|
||||
match request.data {
|
||||
AuthenticatorRequestData::Initial(init_msg) => {
|
||||
self.on_initial_request(init_msg, request.reply_to)
|
||||
self.on_initial_request(init_msg, request.request_id, request.reply_to)
|
||||
}
|
||||
AuthenticatorRequestData::Final(client) => {
|
||||
self.on_final_request(client, request.reply_to)
|
||||
self.on_final_request(client, request.request_id, request.reply_to)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user