mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
Break circuit earlier
There is no need to calculate the full checksum for an Tor v3 onion address if the version byte is not the expected one.
This commit is contained in:
parent
c48e788246
commit
d355a302d9
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
Reference in a new issue