Add LoginStart_Sig, EncryptionResponse_Sig
This commit is contained in:
parent
e5547945b1
commit
7531ea7b31
|
@ -2359,15 +2359,34 @@ state_packets!(
|
||||||
}
|
}
|
||||||
login Login {
|
login Login {
|
||||||
serverbound Serverbound {
|
serverbound Serverbound {
|
||||||
/// LoginStart is sent immeditately after switching into the login
|
/// LoginStart is sent immediately after switching into the login
|
||||||
/// state. The passed username is used by the server to authenticate
|
/// state. The passed username is used by the server to authenticate
|
||||||
/// the player in online mode.
|
/// the player in online mode.
|
||||||
|
packet LoginStart_Sig {
|
||||||
|
field username: String =,
|
||||||
|
field has_sign_data: bool =,
|
||||||
|
field timestamp: Option<u64> = when(|p: &LoginStart_Sig| p.has_sign_data),
|
||||||
|
field public_key: Option<LenPrefixedBytes<VarInt>> = when(|p: &LoginStart_Sig| p.has_sign_data),
|
||||||
|
field signature: Option<LenPrefixedBytes<VarInt>> = when(|p: &LoginStart_Sig| p.has_sign_data),
|
||||||
|
}
|
||||||
packet LoginStart {
|
packet LoginStart {
|
||||||
field username: String =,
|
field username: String =,
|
||||||
}
|
}
|
||||||
/// EncryptionResponse is sent as a reply to EncryptionRequest. All
|
/// EncryptionResponse is sent as a reply to EncryptionRequest. All
|
||||||
/// packets following this one must be encrypted with AES/CFB8
|
/// packets following this one must be encrypted with AES/CFB8
|
||||||
/// encryption.
|
/// encryption.
|
||||||
|
packet EncryptionResponse_Sig {
|
||||||
|
/// The key for the AES/CFB8 cipher encrypted with the
|
||||||
|
/// public key
|
||||||
|
field shared_secret: LenPrefixedBytes<VarInt> =,
|
||||||
|
/// Whether or not the Verify Token should be sent. If not, then the salt and signature will be sent.
|
||||||
|
field has_verify_token: bool =,
|
||||||
|
/// The verify token from the request encrypted with the
|
||||||
|
/// public key
|
||||||
|
field verify_token: Option<LenPrefixedBytes<VarInt>> = when(|p: &EncryptionResponse_Sig| p.has_verify_token),
|
||||||
|
field salt: Option<u64> = when(|p: &EncryptionResponse_Sig| !p.has_verify_token),
|
||||||
|
field signature: Option<LenPrefixedBytes<VarInt>> = when(|p: &EncryptionResponse_Sig| !p.has_verify_token),
|
||||||
|
}
|
||||||
packet EncryptionResponse {
|
packet EncryptionResponse {
|
||||||
/// The key for the AES/CFB8 cipher encrypted with the
|
/// The key for the AES/CFB8 cipher encrypted with the
|
||||||
/// public key
|
/// public key
|
||||||
|
|
|
@ -166,8 +166,8 @@ protocol_packet_ids!(
|
||||||
}
|
}
|
||||||
login Login {
|
login Login {
|
||||||
serverbound Serverbound {
|
serverbound Serverbound {
|
||||||
0x00 => LoginStart
|
0x00 => LoginStart_Sig
|
||||||
0x01 => EncryptionResponse
|
0x01 => EncryptionResponse_Sig
|
||||||
0x02 => LoginPluginResponse
|
0x02 => LoginPluginResponse
|
||||||
}
|
}
|
||||||
clientbound Clientbound {
|
clientbound Clientbound {
|
||||||
|
|
|
@ -132,9 +132,19 @@ impl Server {
|
||||||
next: protocol::VarInt(2),
|
next: protocol::VarInt(2),
|
||||||
})?;
|
})?;
|
||||||
conn.state = protocol::State::Login;
|
conn.state = protocol::State::Login;
|
||||||
conn.write_packet(protocol::packet::login::serverbound::LoginStart {
|
if protocol_version >= 759 {
|
||||||
username: profile.username.clone(),
|
conn.write_packet(protocol::packet::login::serverbound::LoginStart_Sig {
|
||||||
})?;
|
username: profile.username.clone(),
|
||||||
|
has_sign_data: false,
|
||||||
|
public_key: None,
|
||||||
|
signature: None,
|
||||||
|
timestamp: None,
|
||||||
|
})?;
|
||||||
|
} else {
|
||||||
|
conn.write_packet(protocol::packet::login::serverbound::LoginStart {
|
||||||
|
username: profile.username.clone(),
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
let (server_id, public_key, verify_token);
|
let (server_id, public_key, verify_token);
|
||||||
|
@ -207,7 +217,17 @@ impl Server {
|
||||||
profile.join_server(&server_id, &shared, &public_key)?;
|
profile.join_server(&server_id, &shared, &public_key)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if protocol_version >= 47 {
|
if protocol_version >= 759 {
|
||||||
|
conn.write_packet(
|
||||||
|
protocol::packet::login::serverbound::EncryptionResponse_Sig {
|
||||||
|
shared_secret: protocol::LenPrefixedBytes::new(shared_e),
|
||||||
|
verify_token: Some(protocol::LenPrefixedBytes::new(token_e)),
|
||||||
|
has_verify_token: true,
|
||||||
|
salt: None,
|
||||||
|
signature: None,
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
} else if protocol_version >= 47 {
|
||||||
conn.write_packet(protocol::packet::login::serverbound::EncryptionResponse {
|
conn.write_packet(protocol::packet::login::serverbound::EncryptionResponse {
|
||||||
shared_secret: protocol::LenPrefixedBytes::new(shared_e),
|
shared_secret: protocol::LenPrefixedBytes::new(shared_e),
|
||||||
verify_token: protocol::LenPrefixedBytes::new(token_e),
|
verify_token: protocol::LenPrefixedBytes::new(token_e),
|
||||||
|
|
Loading…
Reference in New Issue