Fix the issue on encode_der function (part of processAADBytes), but the unit test cann't reach the branch
@@ -387,7 +387,8 @@ public void processAADBytes(byte[] input, int inOff, int len)
}
else
{
- aderlen = Integer.numberOfLeadingZeros(len);
+ // aderlen is the highest bit position divided by 8
+ aderlen = (32 - Integer.numberOfLeadingZeros(len)) >>> 3;
ader = new byte[aderlen + 1 + len];
ader[0] = (byte)reverseByte(0x80 | aderlen);
int tmp = aderlen;
@@ -466,7 +467,8 @@ public int getUpdateOutputSize(int len)
@Override
public int getOutputSize(int len)
{
- return 0;
+ //the last 8 bits are from AD
+ return len + 8;
}
private int reverseByte(int x)
