// Path: src/impl/krypt/asn1/ParseException.java
// public class ParseException extends RuntimeException {
// 
//     public ParseException(Throwable cause) {
//         super(cause);
//     }
// 
//     public ParseException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ParseException(String message) {
//         super(message);
//     }
// 
//     public ParseException() {
//     }
// 
// }


import java.io.InputStream;
import impl.krypt.asn1.ParseException;
import java.io.FilterInputStream;
import java.io.IOException;
    @Override
    public int read() throws IOException {
        if (read == length)
            return -1;
        int b = super.read();
        read++;
        return b;
    }

    @Override
    public void close() throws IOException {
        //do nothing
    }
    
    

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        if (read == length)
            return -1;
        
        int toRead, actuallyRead;
        
        if (length - read < len)
            toRead = length - read;
        else
            toRead = len;
        
        actuallyRead = super.read(b, off, toRead);
        if (actuallyRead == -1)
// Path: src/impl/krypt/asn1/ParseException.java
// public class ParseException extends RuntimeException {
// 
//     public ParseException(Throwable cause) {
//         super(cause);
//     }
// 
//     public ParseException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ParseException(String message) {
//         super(message);
//     }
// 
//     public ParseException() {
//     }
// 
// }


// Path: src/impl/krypt/asn1/parser/DefiniteInputStream.java
import java.io.InputStream;
import impl.krypt.asn1.ParseException;
import java.io.FilterInputStream;
import java.io.IOException;

    @Override
    public int read() throws IOException {
        if (read == length)
            return -1;
        int b = super.read();
        read++;
        return b;
    }

    @Override
    public void close() throws IOException {
        //do nothing
    }
    
    

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        if (read == length)
            return -1;
        
        int toRead, actuallyRead;
        
        if (length - read < len)
            toRead = length - read;
        else
            toRead = len;
        
        actuallyRead = super.read(b, off, toRead);
        if (actuallyRead == -1)
            throw new ParseException("Premature end of value detected.");