no need to send the encrypted block twice

This commit is contained in:
Sebastian Hugentobler 2022-03-22 21:23:49 +01:00
parent 22fcf324e4
commit f78d2e8124
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
2 changed files with 4 additions and 5 deletions

View file

@ -40,13 +40,12 @@ public class CTR {
*
* @param block Encrypted block (only lower 16 bits get looked at).
* @param idx Block index.
* @param y Y at index idx.
* @return Decrypted block (in the lower 16 bits of the int).
*/
public int decrypt(int block, int idx, int y) {
public int decrypt(int block, int idx) {
int e = (iv + idx) % (1 << BLOCK_LENGTH); // iv + i mod 2^16
e = spn.encryptBlock(key, e); // yes, we need the encryption function, as this is CTR
return y ^ e;
return block ^ e;
}
}