h48108 s 00006/00076/00304 d D 1.4 97/12/09 15:24:42 luehe 5 4 c rm ,* e s 00000/00019/00380 d D 1.3 97/10/22 15:25:05 luehe 4 3 c removed examples e s 00020/00021/00379 d D 1.2 97/10/18 13:59:53 luehe 3 1 c removed examples e s 00000/00000/00000 d R 1.2 97/10/09 09:58:13 Codemgr 2 1 c SunPro Code Manager data about conflicts, renames, etc... c Name history : 1 0 security/JCE1.2/earlyaccess/javax.crypto.CipherInputStream.html e s 00400/00000/00000 d D 1.1 97/10/09 09:58:12 luehe 1 0 c date and time created 97/10/09 09:58:12 by luehe e u U f e 0 t T I 1
D 3 E 3 I 3 D 5 E 5 I 5 E 5 E 3D 3 All Packages Class Hierarchy This Package Previous Next IndexE 3 I 3 All Packages Class Hierarchy This Package Previous Next Index E 3
java.lang.Object
|
+----java.io.InputStream
|
+----java.io.FilterInputStream
|
+----javax.crypto.CipherInputStream
For example, if the Cipher is initialized for decryption, the D 3 SecureInputStream will attempt to read in data and decrypt them, E 3 I 3 CipherInputStream will attempt to read in data and decrypt them, E 3 before returning the decrypted data.
This class adheres strictly to the semantics, especially the
D 3
failure semantics, given for its ancestor classes
E 3
I 3
failure semantics, of its ancestor classes
E 3
java.io.FilterInputStream and java.io.InputStream. This class has
exactly those methods specified in its ancestor classes, and
D 3
override them all. Moreover, this class catches all exceptions
E 3
I 3
overrides them all. Moreover, this class catches all exceptions
E 3
that are not thrown by its ancestor classes. In particular, the
D 3
skip(long) method skips only data that have been
E 3
I 3
skip(long) method skips only data that have been
E 3
processed by the Cipher.
D 3
It is crucial for a programmer using this class to not to use E 3 I 3
It is crucial for a programmer using this class not to use E 3 methods that are not defined or overriden in this class (such as a new method or constructor that is later added to one of the super classes), because the design and implementation of those methods are unlikely to have considered security impact with regard to CipherInputStream. D 3
As an example of its usage, suppose cipher1 and cipher2 have been initialized for encryption and decryption (with corresponding crypto keys) respectively, the code below demonstrates how to easily connect several instances of SecureInputStream and InputStream. E 3 I 3 D 4
As an example of its usage, suppose cipher1 and
cipher2 have been initialized for encryption and decryption
(with corresponding keys), respectively. The code below demonstrates how to
easily connect several instances of CipherInputStream and InputStream:
E 3
D 3
The above program copies the content from file /tmp/a.txt to
/tmp/b.txt, except that in the process the content has been first
encrypted and then decrypted back.
E 3
I 3
The above program copies the content from file /tmp/a.txt to /tmp/b.txt,
except that the content is first encrypted and then decrypted
back when it is read from /tmp/a.txt.
E 4
E 3
FileInputStream fis = new FileInputStream("/tmp/a.txt");
D 3
SecureInputStream sis1 = new SecureInputStream(fis, cipher1);
SecureInputStream sis2 = new SecureInputStream(sis1, cipher2);
E 3
I 3
CipherInputStream cis1 = new CipherInputStream(fis, cipher1);
CipherInputStream cis2 = new CipherInputStream(cis1, cipher2);
E 3
FileOutputStream fos = new FileOutputStream("/tmp/b.txt");
byte[] b = new byte[8];
D 3
int i = sis2.read(b);
E 3
I 3
int i = cis2.read(b);
E 3
while (i != -1) {
fos.write(b, 0, i);
D 3
i = sis2.read(b);
E 3
I 3
i = cis2.read(b);
E 3
}
mark
D 5
and reset methods.
E 5
I 5
and reset methods, which it does not.
E 5
b.length bytes of data from this input
stream into an array of bytes.
len bytes of data from this input stream
into an array of bytes.
mark method was last called on this input stream.
n bytes of data from this
input stream.
public CipherInputStream(InputStream is,
Cipher c)
protected CipherInputStream(InputStream is)
public int read() throws IOException
int in the range
0 to 255. If no byte is available
because the end of the stream has been reached, the value
-1 is returned. This method blocks until input data
is available, the end of the stream is detected, or an exception
is thrown.
-1 if the end of the
stream is reached.
public int read(byte b[]) throws IOException
b.length bytes of data from this input
stream into an array of bytes.
The read method of InputStream calls
the read method of three arguments with the arguments
b, 0, and b.length.
-1 is there is no more data because the end of
the stream has been reached.
public int read(byte b[],
int off,
int len) throws IOException
len bytes of data from this input stream
into an array of bytes. This method blocks until some input is
available. If the first argument is null, up to
len bytes are read and discarded.
-1 if there is no more data because the end of
the stream has been reached.
public long skip(long n) throws IOException
n bytes of data from this
input stream. The skip method may, for a variety of
reasons, end up skipping over some smaller number of bytes,
possibly 0. The actual number of bytes skipped is
returned.
public int available() throws IOException
InputStream returns 0. This method
should be overridden by subclasses.
public void close() throws IOException
The close method of CipherInputStream
calls the close method of its underlying input
stream.
public synchronized void mark(int readlimit)
reset method repositions this stream at
the last marked position so that subsequent reads re-read the same
bytes.
The readlimit arguments tells this input stream to
allow that many bytes to be read before the mark position gets
invalidated.
The mark method of FilterInputStream
calls the mark method of its underlying input stream
with the readlimit argument.
public synchronized void reset() throws IOException
mark method was last called on this input stream.
The reset method of FilterInputStream
calls the reset method of its underlying input stream.
Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parser, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails, which, if it happens within readlimit bytes, allows the outer code to reset the stream and try another parser.
public boolean markSupported()
mark
D 5
and reset methods. The markSupported
method of CipherInputStream calls the
markSupported method of its underlying input stream
and returns whatever value that method returns.
E 5
I 5
and reset methods, which it does not.
E 5
true if this true type supports the mark and reset
method; false otherwise.
E 5
I 5
false, since this class does not support the
mark and reset methods.
E 5
D 3 All Packages Class Hierarchy This Package Previous Next IndexE 3 I 3 All Packages Class Hierarchy This Package Previous Next Index E 3 E 1