|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectde.cscc.crypto.util.BigIntegerUtil
BigIntegerUtil Class.
This is a wrapper class for frequentliy used methods that are missed in the BigInteger class. Because BigInteger is immutable we are not able to extend this class.
| Method Summary | |
static byte[] |
toUnsignedByteArray(BigInteger signature)
Cuts a leading 0x00 byte that indicates that this number is non negative. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static byte[] toUnsignedByteArray(BigInteger signature)
BigInterger#toByteArray returns a two's-complement representation of the BigInteger. This does not matter because we hav a non negative number (number >= 0). Two's Complement uses the leftmost bit (most significant bit) for the sign bit. Because BigInteger represents infinite numbers, there is no concrete sign bit. This isn't realy a problem for us, because positive numbers has no sign bit. But what, if a positive number where the leftmost bit in its leftmost byte is set? Is it a negative or a positive number? For these cases BigInteger#toByteArray adds a whole 0x00 byte add the left side to indicate this number is positive. This byte is bad for us, so we want to filter it out in this method.
signature - the signature that will be converted to an unsigned byte[].
NullPointerException - if signature is null.
IllegalArgumentException - if signature is a negative number.BigInteger.toByteArray()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||