jervi
-
2009-08-05
- priority: 5 --> 7
When encoding BitString using PER/U-encoding, the last byte is encoded wrong if trailBitsCnt != 0. Instead of encoding the bits that should be included, only the trailBits are encoded.
It can be fixed by fixing the for loop in org.bn.coders.per.PerAlignedEncoder encodeBitString(...). Add "8-" before "str.getTrailBitsCnt()". The fixed for-loop should read:
for (int i = 0; i < 8-str.getTrailBitsCnt(); i++) {
int bitValue = (buffer[buffer.length - 1] >> (7 - i)) & 0x1;
bitStream.writeBit(bitValue);
}