Skip to content

Commit b8e6d33

Browse files
author
gefeili
committed
refactor for ElephantEngine.rol8 and rotl
1 parent 4361cd7 commit b8e6d33

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/main/java/org/bouncycastle/crypto/engines/ElephantEngine.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ private void KeccakP200Round(byte[] state, int indexRound)
258258
state[0] ^= KeccakRoundConstants[indexRound];//index(0,0)
259259
}
260260

261+
//TODO: search for " >>> (8 - " merge with with CamelliaLightEngine.lRot8,
262+
// code in OCBBlockCipher.init, DualECSP800DRBG.pad8,
261263
private byte ROL8(byte a, int offset)
262264
{
263-
return (byte)(((a & 0xff) << offset) | ((a & 0xff) >> (8 - offset)));
265+
return (byte)((a << offset) | ((a & 0xff) >>> (8 - offset)));
264266
}
265267

266268
private int index(int x, int y)
@@ -271,7 +273,7 @@ private int index(int x, int y)
271273

272274
private byte rotl(byte b)
273275
{
274-
return (byte)(((b & 0xFF) << 1) | ((b & 0xFF) >>> 7));
276+
return (byte)((b << 1) | ((b & 0xFF) >>> 7));
275277
}
276278

277279
// State should be BLOCK_SIZE bytes long

0 commit comments

Comments
 (0)