BigInteger getBigInteger ( int len , boolean makePositive ) throws IOException { if ( len > available ( ) ) throw new IOException ( "short read of integer" ) ; if ( len == 0 ) { throw new IOException ( "Invalid encoding: zero length Int value" ) ; } byte [ ] bytes = new byte [ len ] ; System . arraycopy ( buf , pos , bytes , 0 , len ) ; skip ( len ) ; // check to make sure no extra leading 0s for DER if ( len >= 2 && ( bytes [ 0 ] == 0 ) && ( bytes [ 1 ] >= 0 ) ) { throw new IOException ( "Invalid encoding: redundant leading 0s" ) ; } if ( makePositive ) { return new BigInteger ( 1 , bytes ) ; } else { return new BigInteger ( bytes ) ; } }
Returns the integer which takes up the specified number of bytes in this buffer as a BigInteger .