JCE: fix Cipher update with offset
parent
2a38c5684b
commit
69b42b64fb
|
@ -457,8 +457,7 @@ public class WolfCryptCipher extends CipherSpi {
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
byte tmpIn[] = Arrays.copyOfRange(input, inputOffset,
|
byte tmpIn[] = null;
|
||||||
inputOffset + len);
|
|
||||||
byte tmpOut[] = null;
|
byte tmpOut[] = null;
|
||||||
|
|
||||||
/* return null if input data is too short to result in a new
|
/* return null if input data is too short to result in a new
|
||||||
|
@ -466,18 +465,25 @@ public class WolfCryptCipher extends CipherSpi {
|
||||||
if (input == null || isValidBlockLength(len) == 0)
|
if (input == null || isValidBlockLength(len) == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
tmpIn = Arrays.copyOfRange(input, inputOffset,
|
||||||
|
inputOffset + len);
|
||||||
|
|
||||||
switch (this.cipherType) {
|
switch (this.cipherType) {
|
||||||
|
|
||||||
case WC_AES:
|
case WC_AES:
|
||||||
tmpOut = this.aes.update(input, inputOffset, len);
|
tmpOut = this.aes.update(input, inputOffset, len);
|
||||||
tmpOut = Arrays.copyOfRange(tmpOut, inputOffset,
|
|
||||||
inputOffset + len);
|
/* truncate */
|
||||||
|
tmpOut = Arrays.copyOfRange(tmpOut, 0, len);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WC_DES3:
|
case WC_DES3:
|
||||||
tmpOut = this.des3.update(input, inputOffset, len);
|
tmpOut = this.des3.update(input, inputOffset, len);
|
||||||
tmpOut = Arrays.copyOfRange(tmpOut, inputOffset,
|
|
||||||
inputOffset + len);
|
/* truncate */
|
||||||
|
tmpOut = Arrays.copyOfRange(tmpOut, 0, len);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WC_RSA:
|
case WC_RSA:
|
||||||
|
|
Loading…
Reference in New Issue