@Test(expected = IllegalArgumentException.class) public void testLengthNull() { DerUtils.decodeLength(null); }
public static int decodeLength(ByteBuffer buf) { if (buf == null || buf.remaining() == 0) { throw new IllegalArgumentException("Null or empty buffer"); } int len = 0; byte first = buf.get(); if (first >> 7 == 0) { len = first & 0x7f; } else { int numOctets = first & 0x7f; if (buf.remaining() < numOctets) { throw new IllegalArgumentException("Insufficient data to decode long-form DER length"); } for (int i = 0; i < numOctets; i++) { len = (len << 8) + (0xff & buf.get()); } } return len; }
DerUtils { public static int decodeLength(ByteBuffer buf) { if (buf == null || buf.remaining() == 0) { throw new IllegalArgumentException("Null or empty buffer"); } int len = 0; byte first = buf.get(); if (first >> 7 == 0) { len = first & 0x7f; } else { int numOctets = first & 0x7f; if (buf.remaining() < numOctets) { throw new IllegalArgumentException("Insufficient data to decode long-form DER length"); } for (int i = 0; i < numOctets; i++) { len = (len << 8) + (0xff & buf.get()); } } return len; } }
DerUtils { public static int decodeLength(ByteBuffer buf) { if (buf == null || buf.remaining() == 0) { throw new IllegalArgumentException("Null or empty buffer"); } int len = 0; byte first = buf.get(); if (first >> 7 == 0) { len = first & 0x7f; } else { int numOctets = first & 0x7f; if (buf.remaining() < numOctets) { throw new IllegalArgumentException("Insufficient data to decode long-form DER length"); } for (int i = 0; i < numOctets; i++) { len = (len << 8) + (0xff & buf.get()); } } return len; } private  DerUtils(); }
DerUtils { public static int decodeLength(ByteBuffer buf) { if (buf == null || buf.remaining() == 0) { throw new IllegalArgumentException("Null or empty buffer"); } int len = 0; byte first = buf.get(); if (first >> 7 == 0) { len = first & 0x7f; } else { int numOctets = first & 0x7f; if (buf.remaining() < numOctets) { throw new IllegalArgumentException("Insufficient data to decode long-form DER length"); } for (int i = 0; i < numOctets; i++) { len = (len << 8) + (0xff & buf.get()); } } return len; } private  DerUtils(); static int decodeLength(ByteBuffer buf); static DerId decodeIdAndLength(ByteBuffer buf); static int encodeIdAndLength(DerId.TagClass tagClass, DerId.EncodingType encodingType, int tagNumber,
            int contentLength, ByteBuffer buf); static int sizeOf(int tagNumber, int contentLength); }
DerUtils { public static int decodeLength(ByteBuffer buf) { if (buf == null || buf.remaining() == 0) { throw new IllegalArgumentException("Null or empty buffer"); } int len = 0; byte first = buf.get(); if (first >> 7 == 0) { len = first & 0x7f; } else { int numOctets = first & 0x7f; if (buf.remaining() < numOctets) { throw new IllegalArgumentException("Insufficient data to decode long-form DER length"); } for (int i = 0; i < numOctets; i++) { len = (len << 8) + (0xff & buf.get()); } } return len; } private  DerUtils(); static int decodeLength(ByteBuffer buf); static DerId decodeIdAndLength(ByteBuffer buf); static int encodeIdAndLength(DerId.TagClass tagClass, DerId.EncodingType encodingType, int tagNumber,
            int contentLength, ByteBuffer buf); static int sizeOf(int tagNumber, int contentLength);  }