mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge #20405: p2p: avoid calculating onion address checksum when version is not 3
d355a302d9Break circuit earlier (lontivero) Pull request description: Currently when parsing an onion v3 address the pubic key checksum is calculated in order to compare it with the received address checksum. However this step is not necessary if the address version byte is not 3, in which case the method can return with false immediately. ACKs for top commit: jonatack: ACKd355a302d9practicalswift: ACKd355a302d9-- patch looks correct hebasto: ACKd355a302d9, I have reviewed the code and it looks OK, I agree it can be merged. sipa: utACKd355a302d9Tree-SHA512: 9e4506793b7f4a62ce8edc41a260a8c125ae81ed2f90cd850eb2a9214d323c446edc7586c7b0590dcbf3aed5be534718b77bb19c45b48f8f52553d32a3663a65
This commit is contained in:
commit
7c0d412a74
1 changed files with 5 additions and 1 deletions
|
|
@ -255,10 +255,14 @@ bool CNetAddr::SetSpecial(const std::string& str)
|
|||
Span<const uint8_t> input_checksum{input.data() + ADDR_TORV3_SIZE, torv3::CHECKSUM_LEN};
|
||||
Span<const uint8_t> input_version{input.data() + ADDR_TORV3_SIZE + torv3::CHECKSUM_LEN, sizeof(torv3::VERSION)};
|
||||
|
||||
if (input_version != torv3::VERSION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t calculated_checksum[torv3::CHECKSUM_LEN];
|
||||
torv3::Checksum(input_pubkey, calculated_checksum);
|
||||
|
||||
if (input_checksum != calculated_checksum || input_version != torv3::VERSION) {
|
||||
if (input_checksum != calculated_checksum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue