forked from I2P_Developers/i2p.i2p
Peer selection: Don't truncate data used for random slice
This commit is contained in:
@@ -1389,12 +1389,12 @@ public class ProfileOrganizer {
|
||||
* @return 0-3
|
||||
*/
|
||||
private int getSubTier(Hash peer, Hash randomKey) {
|
||||
// input is first 36 bytes; output is last 32 bytes
|
||||
byte[] data = new byte[Hash.HASH_LENGTH + 4 + Hash.HASH_LENGTH];
|
||||
System.arraycopy(peer.getData(), 0, data, 0, Hash.HASH_LENGTH);
|
||||
System.arraycopy(randomKey.getData(), 0, data, Hash.HASH_LENGTH, 4);
|
||||
_context.sha().calculateHash(data, 0, Hash.HASH_LENGTH + 4, data, Hash.HASH_LENGTH + 4);
|
||||
return data[Hash.HASH_LENGTH + 4] & 0x03;
|
||||
// input is first 64 bytes; output is last 32 bytes
|
||||
byte[] data = new byte[96];
|
||||
System.arraycopy(peer.getData(), 0, data, 0, 32);
|
||||
System.arraycopy(randomKey.getData(), 0, data, 32, 32);
|
||||
_context.sha().calculateHash(data, 0, 64, data, 64);
|
||||
return data[64] & 0x03;
|
||||
}
|
||||
|
||||
public boolean isSelectable(Hash peer) {
|
||||
|
||||
Reference in New Issue
Block a user