forked from I2P_Developers/i2p.i2p
* Tunnel encryption: More efficient XOR
This commit is contained in:
@@ -100,7 +100,10 @@ class HopProcessor {
|
|||||||
|
|
||||||
private final void encrypt(byte data[], int offset, int length) {
|
private final void encrypt(byte data[], int offset, int length) {
|
||||||
for (int off = offset + IV_LENGTH; off < length; off += IV_LENGTH) {
|
for (int off = offset + IV_LENGTH; off < length; off += IV_LENGTH) {
|
||||||
DataHelper.xor(data, off - IV_LENGTH, data, off, data, off, IV_LENGTH);
|
//DataHelper.xor(data, off - IV_LENGTH, data, off, data, off, IV_LENGTH);
|
||||||
|
for (int j = 0; j < IV_LENGTH; j++) {
|
||||||
|
data[off + j] ^= data[(off - IV_LENGTH) + j];
|
||||||
|
}
|
||||||
_context.aes().encryptBlock(data, off, _config.getLayerKey(), data, off);
|
_context.aes().encryptBlock(data, off, _config.getLayerKey(), data, off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,7 +93,10 @@ class OutboundGatewayProcessor {
|
|||||||
|
|
||||||
System.arraycopy(orig, off, cur, 0, HopProcessor.IV_LENGTH);
|
System.arraycopy(orig, off, cur, 0, HopProcessor.IV_LENGTH);
|
||||||
ctx.aes().decryptBlock(orig, off, config.getLayerKey(), orig, off);
|
ctx.aes().decryptBlock(orig, off, config.getLayerKey(), orig, off);
|
||||||
DataHelper.xor(prev, 0, orig, off, orig, off, HopProcessor.IV_LENGTH);
|
//DataHelper.xor(prev, 0, orig, off, orig, off, HopProcessor.IV_LENGTH);
|
||||||
|
for (int j = 0; j < HopProcessor.IV_LENGTH; j++) {
|
||||||
|
orig[off + j] ^= prev[j];
|
||||||
|
}
|
||||||
byte xf[] = prev;
|
byte xf[] = prev;
|
||||||
prev = cur;
|
prev = cur;
|
||||||
cur = xf;
|
cur = xf;
|
||||||
|
Reference in New Issue
Block a user