@@ -91,12 +91,12 @@ public void init(boolean forEncryption, CipherParameters params)
9191 if (keyBytes .length != 16 )
9292 {
9393 throw new IllegalArgumentException (
94- "Grain-128AEAD key must be 128 bits long" );
94+ "Grain-128AEAD key must be 128 bits long" );
9595 }
9696
9797 CryptoServicesRegistrar .checkConstraints (new DefaultServiceProperties (
98- this .getAlgorithmName (), 128 , params , Utils .getPurpose (forEncryption )));
99-
98+ this .getAlgorithmName (), 128 , params , Utils .getPurpose (forEncryption )));
99+
100100 /**
101101 * Initialize variables.
102102 */
@@ -418,6 +418,7 @@ private void doProcessAADBytes(byte[] input, int inOff, int len)
418418 {
419419 ader [1 + aderlen + i ] = (byte )reverseByte (input [inOff + i ]);
420420 }
421+
421422 byte adval ;
422423 int adCnt = 0 ;
423424 for (int i = 0 ; i < ader .length ; ++i )
@@ -467,14 +468,14 @@ public int doFinal(byte[] out, int outOff)
467468 doProcessAADBytes (aadData .getBuf (), 0 , aadData .size ());
468469 aadFinished = true ;
469470 }
470-
471+
471472 this .mac = new byte [8 ];
472473
473474 output = getOutput ();
474475 nfsr = shift (nfsr , (getOutputNFSR () ^ lfsr [0 ]) & 1 );
475476 lfsr = shift (lfsr , (getOutputLFSR ()) & 1 );
476477 accumulate ();
477-
478+
478479 int cCnt = 0 ;
479480 for (int i = 0 ; i < 2 ; ++i )
480481 {
@@ -483,7 +484,7 @@ public int doFinal(byte[] out, int outOff)
483484 mac [cCnt ++] = (byte )((authAcc [i ] >>> (j << 3 )) & 0xff );
484485 }
485486 }
486-
487+
487488 System .arraycopy (mac , 0 , out , outOff , mac .length );
488489
489490 try
@@ -514,9 +515,9 @@ public int getOutputSize(int len)
514515
515516 private int reverseByte (int x )
516517 {
517- x = (((x & 0x55 ) << 1 ) | ((x & (~ 0x55 )) >>> 1 )) & 0xFF ;
518- x = (((x & 0x33 ) << 2 ) | ((x & (~ 0x33 )) >>> 2 )) & 0xFF ;
519- x = (((x & 0x0f ) << 4 ) | ((x & (~ 0x0f )) >>> 4 )) & 0xFF ;
518+ x = (((x & 0x55 ) << 1 ) | ((x & (0xAA )) >>> 1 )) & 0xFF ;
519+ x = (((x & 0x33 ) << 2 ) | ((x & (0xCC )) >>> 2 )) & 0xFF ;
520+ x = (((x & 0x0f ) << 4 ) | ((x & (0xf0 )) >>> 4 )) & 0xFF ;
520521 return x ;
521522 }
522523
0 commit comments