@@ -309,7 +309,7 @@ static byte[] shiftLeft(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder
309309 byte src = byteArray [sourceIndex ];
310310 byte dst = (byte ) (src << shiftMod );
311311 if (sourceIndex + 1 < byteArray .length ) {
312- dst |= byteArray [sourceIndex + 1 ] >>> (8 - shiftMod ) & carryMask ;
312+ dst |= byteArray [sourceIndex + 1 ] >>> (8 - shiftMod ) & carryMask & 0xff ;
313313 }
314314 byteArray [i ] = dst ;
315315 }
@@ -323,7 +323,7 @@ static byte[] shiftLeft(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder
323323 byte src = byteArray [sourceIndex ];
324324 byte dst = (byte ) (src << shiftMod );
325325 if (sourceIndex - 1 >= 0 ) {
326- dst |= byteArray [sourceIndex - 1 ] >>> (8 - shiftMod ) & carryMask ;
326+ dst |= byteArray [sourceIndex - 1 ] >>> (8 - shiftMod ) & carryMask & 0xff ;
327327 }
328328 byteArray [i ] = dst ;
329329 }
@@ -365,7 +365,7 @@ static byte[] shiftRight(byte[] byteArray, int shiftBitCount, ByteOrder byteOrde
365365 byte src = byteArray [sourceIndex ];
366366 byte dst = (byte ) ((0xff & src ) >>> shiftMod );
367367 if (sourceIndex - 1 >= 0 ) {
368- dst |= byteArray [sourceIndex - 1 ] << (8 - shiftMod ) & carryMask ;
368+ dst |= byteArray [sourceIndex - 1 ] << (8 - shiftMod ) & carryMask & 0xff ;
369369 }
370370 byteArray [i ] = dst ;
371371 }
@@ -379,7 +379,7 @@ static byte[] shiftRight(byte[] byteArray, int shiftBitCount, ByteOrder byteOrde
379379 byte src = byteArray [sourceIndex ];
380380 byte dst = (byte ) ((0xff & src ) >>> shiftMod );
381381 if (sourceIndex + 1 < byteArray .length ) {
382- dst |= byteArray [sourceIndex + 1 ] << (8 - shiftMod ) & carryMask ;
382+ dst |= byteArray [sourceIndex + 1 ] << (8 - shiftMod ) & carryMask & 0xff ;
383383 }
384384 byteArray [i ] = dst ;
385385 }
0 commit comments