public BitArray getUnalignedBitString ( ) throws IOException { if ( buffer . read ( ) != DerValue . tag_BitString ) throw new IOException ( "DER input not a bit string" ) ; int length = getLength ( buffer ) - 1 ; /* * First byte = number of excess bits in the last octet of the * representation. */ int validBits = length * 8 - buffer . read ( ) ; byte [ ] repn = new byte [ length ] ; if ( ( length != 0 ) && ( buffer . read ( repn ) != length ) ) throw new IOException ( "short read of DER bit string" ) ; return new BitArray ( validBits , repn ) ; }
Get a bit string from the input stream . The bit string need not be byte - aligned .