Merge
Crypto WASM TESTS
This commit is contained in:
parent
2a00bb35e7
commit
687e6f9642
49 changed files with 6272 additions and 366 deletions
|
|
@ -176,8 +176,9 @@ impl MTPHost {
|
|||
_ => vec![],
|
||||
};
|
||||
|
||||
let (assigned_id, client_bundle) =
|
||||
if msg.get_type() == mtp_codec::CommunicationType::Identification.to_id(&tm) {
|
||||
let (assigned_id, client_bundle, response_type) = if msg.get_type()
|
||||
== mtp_codec::CommunicationType::Identification.to_id(&tm)
|
||||
{
|
||||
// LOGIN
|
||||
let cid = match msg.get_data(DataType::Id.to_id(&tm)) {
|
||||
DataValue::UnsignedNumber(n) => *n as u64,
|
||||
|
|
@ -238,7 +239,11 @@ impl MTPHost {
|
|||
}
|
||||
/* ===== End Signature ===== */
|
||||
|
||||
(cid, bundle)
|
||||
(
|
||||
cid,
|
||||
bundle,
|
||||
mtp_codec::CommunicationType::IdentificationResponse,
|
||||
)
|
||||
} else if msg.get_type() == mtp_codec::CommunicationType::Register.to_id(&tm) {
|
||||
// REGISTER
|
||||
let bundle = match msg.get_data(DataType::PublicKeys.to_id(&tm)) {
|
||||
|
|
@ -285,7 +290,11 @@ impl MTPHost {
|
|||
/* ===== End Signature ===== */
|
||||
|
||||
let new_id = (self.config.complete_register)(bundle.clone());
|
||||
(new_id, bundle)
|
||||
(
|
||||
new_id,
|
||||
bundle,
|
||||
mtp_codec::CommunicationType::RegisterResponse,
|
||||
)
|
||||
} else {
|
||||
sender.close();
|
||||
return None;
|
||||
|
|
@ -305,16 +314,15 @@ impl MTPHost {
|
|||
/* ===== Signature ===== */
|
||||
let host_sig = host_signer.sign(&host_sig_payload).ok()?;
|
||||
|
||||
let mut response =
|
||||
CommunicationValue::new(mtp_codec::CommunicationType::IdentificationResponse)
|
||||
.add_typed_default(DataType::Connected, DataValue::BoolTrue)
|
||||
.add_typed_default(
|
||||
DataType::ClientNonce,
|
||||
DataValue::UnsignedNumber(client_nonce),
|
||||
)
|
||||
.add_typed_default(DataType::Timestamp, DataValue::UnsignedNumber(new_nonce))
|
||||
.add_typed_default(DataType::Signature, DataValue::Bytes(host_sig))
|
||||
.add_typed_default(DataType::Id, DataValue::UnsignedNumber(assigned_id as u128));
|
||||
let mut response = CommunicationValue::new(response_type)
|
||||
.add_typed_default(DataType::Connected, DataValue::BoolTrue)
|
||||
.add_typed_default(
|
||||
DataType::ClientNonce,
|
||||
DataValue::UnsignedNumber(client_nonce),
|
||||
)
|
||||
.add_typed_default(DataType::Timestamp, DataValue::UnsignedNumber(new_nonce))
|
||||
.add_typed_default(DataType::Signature, DataValue::Bytes(host_sig))
|
||||
.add_typed_default(DataType::Id, DataValue::UnsignedNumber(assigned_id as u128));
|
||||
|
||||
if !self
|
||||
.config
|
||||
|
|
@ -336,6 +344,7 @@ impl MTPHost {
|
|||
/* ===== End Signature ===== */
|
||||
|
||||
sender.send(&response).await.ok()?;
|
||||
sender.finish_stream().await.ok()?;
|
||||
|
||||
// 3. Version negotiation
|
||||
let negotiated = self.registry.negotiate(&[client_version])?;
|
||||
|
|
@ -380,7 +389,10 @@ mod tests {
|
|||
mtp_codec::CommunicationType::Identification,
|
||||
&tm,
|
||||
)
|
||||
.add_data(DataType::Version.to_id(&tm), DataValue::Str("2.0".to_string()));
|
||||
.add_data(
|
||||
DataType::Version.to_id(&tm),
|
||||
DataValue::Str("2.0".to_string()),
|
||||
);
|
||||
let version = extract_version(&msg);
|
||||
assert_eq!(version, Some(Version(2, 0)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue