Skip to content

Commit 2048648

Browse files
committed
correct supported protocols
clients can receive this message (and then it will have a payload). servers can also receive this message, but then the body should be empty
1 parent ab73c04 commit 2048648

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

ntp-proto/src/nts_record.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ struct KeyExchangeResultDecoder {
759759

760760
#[cfg(feature = "nts-pool")]
761761
keep_alive: bool,
762+
763+
#[cfg(feature = "nts-pool")]
764+
supported_protocols: Vec<(AeadAlgorithm, u16)>,
762765
}
763766

764767
impl KeyExchangeResultDecoder {
@@ -861,9 +864,21 @@ impl KeyExchangeResultDecoder {
861864
Continue(state)
862865
}
863866
#[cfg(feature = "nts-pool")]
864-
SupportedProtocolList { .. } => {
865-
// a client should never receive a SupportedProtocolList
866-
tracing::warn!("Unexpected supported protocol list");
867+
SupportedProtocolList {
868+
supported_protocols,
869+
} => {
870+
use self::AeadAlgorithm;
871+
872+
let supported_protocols = supported_protocols
873+
.into_iter()
874+
.filter_map(|(aead_protocol_id, key_length)| {
875+
let aead_algorithm = AeadAlgorithm::try_deserialize(aead_protocol_id)?;
876+
Some((aead_algorithm, key_length))
877+
})
878+
.collect();
879+
880+
state.supported_protocols = supported_protocols;
881+
867882
Continue(state)
868883
}
869884
#[cfg(feature = "nts-pool")]
@@ -1044,7 +1059,7 @@ struct KeyExchangeServerDecoder {
10441059
#[cfg(feature = "nts-pool")]
10451060
keep_alive: Option<bool>,
10461061
#[cfg(feature = "nts-pool")]
1047-
supported_protocols: Option<Vec<(AeadAlgorithm, u16)>>,
1062+
send_supported_protocols: bool,
10481063
#[cfg(feature = "nts-pool")]
10491064
fixed_key_request: Option<(Vec<u8>, Vec<u8>)>,
10501065
#[cfg(feature = "nts-pool")]
@@ -1186,17 +1201,9 @@ impl KeyExchangeServerDecoder {
11861201
SupportedProtocolList {
11871202
supported_protocols,
11881203
} => {
1189-
use self::AeadAlgorithm;
1190-
1191-
let supported_protocols = supported_protocols
1192-
.into_iter()
1193-
.filter_map(|(aead_protocol_id, key_length)| {
1194-
let aead_algorithm = AeadAlgorithm::try_deserialize(aead_protocol_id)?;
1195-
Some((aead_algorithm, key_length))
1196-
})
1197-
.collect();
1204+
debug_assert_eq!(supported_protocols, &[]);
11981205

1199-
state.supported_protocols = Some(supported_protocols);
1206+
state.send_supported_protocols = true;
12001207

12011208
Continue(state)
12021209
}

0 commit comments

Comments
 (0)