forked from I2P_Developers/i2p.i2p
Crypto: Micro-optimize AES encrypt loop
This commit is contained in:
@ -127,13 +127,12 @@ public final class CryptixAESEngine extends AESEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int numblock = length / 16;
|
|
||||||
|
|
||||||
DataHelper.xor(iv, ivOffset, payload, payloadIndex, out, outIndex, 16);
|
DataHelper.xor(iv, ivOffset, payload, payloadIndex, out, outIndex, 16);
|
||||||
encryptBlock(out, outIndex, sessionKey, out, outIndex);
|
encryptBlock(out, outIndex, sessionKey, out, outIndex);
|
||||||
for (int x = 1; x < numblock; x++) {
|
for (int x = 16; x < length; x += 16) {
|
||||||
DataHelper.xor(out, outIndex + (x-1) * 16, payload, payloadIndex + x * 16, out, outIndex + x * 16, 16);
|
int off = outIndex + x;
|
||||||
encryptBlock(out, outIndex + x * 16, sessionKey, out, outIndex + x * 16);
|
DataHelper.xor(out, off - 16, payload, payloadIndex + x, out, off, 16);
|
||||||
|
encryptBlock(out, off, sessionKey, out, off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user