@Test(expected = IllegalArgumentException.class) public void testSizeOfInvalidContentLength() { DerUtils.sizeOf(0, -1); }
public static int sizeOf(int tagNumber, int contentLength) { if (tagNumber < 0 || contentLength < 0) { throw new IllegalArgumentException("Invalid tagNumber/contentLength: " + tagNumber + ", " + contentLength); } int len = 0; if (tagNumber <= 30) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(tagNumber))) / 7.0d); } if (contentLength <= 0x7f) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(contentLength))) / 8.0d); } len += contentLength; return len; }
DerUtils { public static int sizeOf(int tagNumber, int contentLength) { if (tagNumber < 0 || contentLength < 0) { throw new IllegalArgumentException("Invalid tagNumber/contentLength: " + tagNumber + ", " + contentLength); } int len = 0; if (tagNumber <= 30) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(tagNumber))) / 7.0d); } if (contentLength <= 0x7f) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(contentLength))) / 8.0d); } len += contentLength; return len; } }
DerUtils { public static int sizeOf(int tagNumber, int contentLength) { if (tagNumber < 0 || contentLength < 0) { throw new IllegalArgumentException("Invalid tagNumber/contentLength: " + tagNumber + ", " + contentLength); } int len = 0; if (tagNumber <= 30) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(tagNumber))) / 7.0d); } if (contentLength <= 0x7f) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(contentLength))) / 8.0d); } len += contentLength; return len; } private  DerUtils(); }
DerUtils { public static int sizeOf(int tagNumber, int contentLength) { if (tagNumber < 0 || contentLength < 0) { throw new IllegalArgumentException("Invalid tagNumber/contentLength: " + tagNumber + ", " + contentLength); } int len = 0; if (tagNumber <= 30) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(tagNumber))) / 7.0d); } if (contentLength <= 0x7f) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(contentLength))) / 8.0d); } len += contentLength; 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 sizeOf(int tagNumber, int contentLength) { if (tagNumber < 0 || contentLength < 0) { throw new IllegalArgumentException("Invalid tagNumber/contentLength: " + tagNumber + ", " + contentLength); } int len = 0; if (tagNumber <= 30) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(tagNumber))) / 7.0d); } if (contentLength <= 0x7f) { len++; } else { len = len + 1 + (int) Math.ceil((1 + Integer.numberOfTrailingZeros(Integer.highestOneBit(contentLength))) / 8.0d); } len += contentLength; 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);  }