--- a/jdk/src/share/classes/com/sun/crypto/provider/FeedbackCipher.java Tue Oct 08 11:07:31 2013 -0700
+++ b/jdk/src/share/classes/com/sun/crypto/provider/FeedbackCipher.java Tue Oct 08 11:17:53 2013 -0700
@@ -133,9 +133,10 @@
* @param plainLen the length of the input data
* @param cipher the buffer for the encryption result
* @param cipherOffset the offset in <code>cipher</code>
+ * @return the number of bytes placed into <code>cipher</code>
*/
- abstract void encrypt(byte[] plain, int plainOffset, int plainLen,
- byte[] cipher, int cipherOffset);
+ abstract int encrypt(byte[] plain, int plainOffset, int plainLen,
+ byte[] cipher, int cipherOffset);
/**
* Performs encryption operation for the last time.
*
@@ -154,10 +155,9 @@
*/
int encryptFinal(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset)
- throws IllegalBlockSizeException {
- encrypt(plain, plainOffset, plainLen, cipher, cipherOffset);
- return plainLen;
- }
+ throws IllegalBlockSizeException, ShortBufferException {
+ return encrypt(plain, plainOffset, plainLen, cipher, cipherOffset);
+ }
/**
* Performs decryption operation.
*
@@ -174,9 +174,10 @@
* @param cipherLen the length of the input data
* @param plain the buffer for the decryption result
* @param plainOffset the offset in <code>plain</code>
+ * @return the number of bytes placed into <code>plain</code>
*/
- abstract void decrypt(byte[] cipher, int cipherOffset, int cipherLen,
- byte[] plain, int plainOffset);
+ abstract int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
+ byte[] plain, int plainOffset);
/**
* Performs decryption operation for the last time.
@@ -196,9 +197,9 @@
*/
int decryptFinal(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset)
- throws IllegalBlockSizeException, AEADBadTagException {
- decrypt(cipher, cipherOffset, cipherLen, plain, plainOffset);
- return cipherLen;
+ throws IllegalBlockSizeException, AEADBadTagException,
+ ShortBufferException {
+ return decrypt(cipher, cipherOffset, cipherLen, plain, plainOffset);
}
/**
@@ -228,4 +229,15 @@
void updateAAD(byte[] src, int offset, int len) {
throw new IllegalStateException("No AAD accepted");
}
+
+ /**
+ * @return the number of bytes that are buffered internally inside
+ * this FeedbackCipher instance.
+ * @since 1.8
+ */
+ int getBufferedLength() {
+ // Currently only AEAD cipher impl, e.g. GCM, buffers data
+ // internally during decryption mode
+ return 0;
+ }
}