Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorDavid Hook <dgh@cryptoworkshop.com>2014-05-24 09:22:11 +0400
committerDavid Hook <dgh@cryptoworkshop.com>2014-05-24 09:22:11 +0400
commitab7e3efe4f01579aeee2e1eed7ddff80a28502a2 (patch)
tree6ab95d1e78cb4337f83398890242bb57b64f2a87 /core/src
parentd5fad8634149cfc46a5fdb13eacf176047f6e478 (diff)
JavaDoc, cleared out buffered data.
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java33
-rw-r--r--core/src/test/java/org/bouncycastle/crypto/test/CipherStreamTest.java2
2 files changed, 35 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java b/core/src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java
index f58e033c..1589b149 100644
--- a/core/src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java
+++ b/core/src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java
@@ -9,6 +9,7 @@ import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.crypto.SkippingCipher;
import org.bouncycastle.crypto.StreamCipher;
import org.bouncycastle.crypto.modes.AEADBlockCipher;
+import org.bouncycastle.util.Arrays;
/**
* A CipherInputStream is composed of an InputStream and a cipher so that read() methods return data
@@ -344,8 +345,29 @@ public class CipherInputStream
}
}
maxBuf = bufOff = 0;
+ markBufOff = 0;
+ markPosition = 0;
+ if (markBuf != null)
+ {
+ Arrays.fill(markBuf, (byte)0);
+ markBuf = null;
+ }
+ if (buf != null)
+ {
+ Arrays.fill(buf, (byte)0);
+ buf = null;
+ }
+ Arrays.fill(inBuf, (byte)0);
}
+ /**
+ * Mark the current position.
+ * <p>
+ * This method only works if markSupported() returns true - which means the underlying stream supports marking, and the cipher passed
+ * in to this stream's constructor is a SkippingCipher (so capable of being reset to an arbitrary point easily).
+ * </p>
+ * @param readlimit the maximum read ahead required before a reset() may be called.
+ */
public void mark(int readlimit)
{
in.mark(readlimit);
@@ -365,6 +387,11 @@ public class CipherInputStream
markBufOff = bufOff;
}
+ /**
+ * Reset to the last marked position, if supported.
+ *
+ * @throws IOException if marking not supported by the cipher used, or the underlying stream.
+ */
public void reset()
throws IOException
{
@@ -385,6 +412,12 @@ public class CipherInputStream
bufOff = markBufOff;
}
+ /**
+ * Return true if mark(readlimit) is supported. This will be true if the underlying stream supports marking and the
+ * cipher used is a SkippingCipher,
+ *
+ * @return true if mark(readlimit) supported, false otherwise.
+ */
public boolean markSupported()
{
if (streamCipher instanceof SkippingCipher)
diff --git a/core/src/test/java/org/bouncycastle/crypto/test/CipherStreamTest.java b/core/src/test/java/org/bouncycastle/crypto/test/CipherStreamTest.java
index 46b70858..aaf20310 100644
--- a/core/src/test/java/org/bouncycastle/crypto/test/CipherStreamTest.java
+++ b/core/src/test/java/org/bouncycastle/crypto/test/CipherStreamTest.java
@@ -674,6 +674,8 @@ public class CipherStreamTest
{
fail(cipher.getAlgorithmName() + " fourth reset read failed");
}
+
+ cIn.close();
}
private boolean areEqual(byte[] a, int aOff, byte[] b, int bOff)