8297972: Poly1305 Endianness on ByteBuffer not enforced
Reviewed-by: jnimeh
This commit is contained in:
parent
facd41511b
commit
9d44dd0cca
@ -127,6 +127,8 @@ public final class IntegerPolynomial1305 extends IntegerPolynomial {
|
||||
@Override
|
||||
protected void encode(ByteBuffer buf, int length, byte highByte,
|
||||
long[] result) {
|
||||
ByteOrder currOrder = buf.order();
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
if (length == 16) {
|
||||
long low = buf.getLong();
|
||||
long high = buf.getLong();
|
||||
@ -134,6 +136,7 @@ public final class IntegerPolynomial1305 extends IntegerPolynomial {
|
||||
} else {
|
||||
super.encode(buf, length, highByte, result);
|
||||
}
|
||||
buf.order(currOrder);
|
||||
}
|
||||
|
||||
protected void encode(long high, long low, byte highByte, long[] result) {
|
||||
|
@ -103,20 +103,17 @@ public class Poly1305IntrinsicFuzzTest {
|
||||
authenticator.engineUpdate(message, offset, len);
|
||||
break;
|
||||
case 1: // ByteArray with backing array
|
||||
buf = ByteBuffer.wrap(message, offset, len)
|
||||
.order(java.nio.ByteOrder.LITTLE_ENDIAN);
|
||||
buf = ByteBuffer.wrap(message, offset, len);
|
||||
authenticator.engineUpdate(buf);
|
||||
break;
|
||||
case 2: // ByteArray with backing array (non-zero position)
|
||||
buf = ByteBuffer.wrap(message, 0, len+offset)
|
||||
.order(java.nio.ByteOrder.LITTLE_ENDIAN)
|
||||
.position(offset);
|
||||
authenticator.engineUpdate(buf);
|
||||
break;
|
||||
case 3: // ByteArray without backing array (wont be sent to intrinsic)
|
||||
buf = ByteBuffer.wrap(message, offset, len)
|
||||
.asReadOnlyBuffer()
|
||||
.order(java.nio.ByteOrder.LITTLE_ENDIAN);
|
||||
.asReadOnlyBuffer();
|
||||
authenticator.engineUpdate(buf);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user