Changeset 74e8cf7 for router


Ignore:
Timestamp:
Mar 11, 2016 1:53:21 AM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
0904500
Parents:
b7498b5
Message:

Peer selection: Don't truncate data used for random slice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    rb7498b5 r74e8cf7  
    13901390     */
    13911391    private int getSubTier(Hash peer, Hash randomKey) {
    1392         // input is first 36 bytes; output is last 32 bytes
    1393         byte[] data = new byte[Hash.HASH_LENGTH + 4 + Hash.HASH_LENGTH];
    1394         System.arraycopy(peer.getData(), 0, data, 0, Hash.HASH_LENGTH);
    1395         System.arraycopy(randomKey.getData(), 0, data, Hash.HASH_LENGTH, 4);
    1396         _context.sha().calculateHash(data, 0, Hash.HASH_LENGTH + 4, data, Hash.HASH_LENGTH + 4);
    1397         return data[Hash.HASH_LENGTH + 4] & 0x03;
     1392        // input is first 64 bytes; output is last 32 bytes
     1393        byte[] data = new byte[96];
     1394        System.arraycopy(peer.getData(), 0, data, 0, 32);
     1395        System.arraycopy(randomKey.getData(), 0, data, 32, 32);
     1396        _context.sha().calculateHash(data, 0, 64, data, 64);
     1397        return data[64] & 0x03;
    13981398    }
    13991399
Note: See TracChangeset for help on using the changeset viewer.