< prev index next >
src/java.base/share/classes/com/sun/crypto/provider/ElectronicCodeBook.java
Print this page
rev 17032 : ECB fix part 1
@@ -110,18 +110,11 @@
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the length of the encrypted data
*/
int encrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
- if ((len % blockSize) != 0) {
- throw new ProviderException("Internal error in input buffering");
- }
- for (int i = len; i >= blockSize; i -= blockSize) {
- embeddedCipher.encryptBlock(in, inOff, out, outOff);
- inOff += blockSize;
- outOff += blockSize;
- }
+ embeddedCipher.encryptBlocks(in, inOff, out, outOff, len);
return len;
}
/**
* Performs decryption operation.
@@ -139,16 +132,9 @@
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the length of the decrypted data
*/
int decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
- if ((len % blockSize) != 0) {
- throw new ProviderException("Internal error in input buffering");
- }
- for (int i = len; i >= blockSize; i -= blockSize) {
- embeddedCipher.decryptBlock(in, inOff, out, outOff);
- inOff += blockSize;
- outOff += blockSize;
- }
+ embeddedCipher.decryptBlocks(in, inOff, out, outOff, len);
return len;
}
}
< prev index next >