If the most significant bit of a BigInteger's magnitude is set, when encoded to a byte array, an extra leading byte will be added so that the resulting byte array can be passed back to the BigInteger constructor that takes only a byte array and no sign indicator.
This causes encoded parameters to sometimes be one byte longer than expected. All parameters (modulus, exponent, etc.) should be treated as unsigned numbers, and this leading byte can be discarded. In other words, since the sign of new BigInteger is fixed to be positive, we don't need to track the sign.
From erick...@bitflash.net on September 13, 2013 22:45:10
If the most significant bit of a BigInteger's magnitude is set, when encoded to a byte array, an extra leading byte will be added so that the resulting byte array can be passed back to the BigInteger constructor that takes only a byte array and no sign indicator.
This causes encoded parameters to sometimes be one byte longer than expected. All parameters (modulus, exponent, etc.) should be treated as unsigned numbers, and this leading byte can be discarded. In other words, since the sign of new BigInteger is fixed to be positive, we don't need to track the sign.
Original issue: http://code.google.com/p/jcardsim/issues/detail?id=15