protected byte[] engineDoFinal( byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException { int len = 0; byte[] tmp = new byte[engineGetOutputSize(inputLen)]; if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, tmp, 0); } try { len += cipher.doFinal(tmp, len); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } if (len == tmp.length) { return tmp; } byte[] out = new byte[len]; System.arraycopy(tmp, 0, out, 0, len); return out; }
if (cipher.wrapOnNoPadding()) cipher = new BufferedGenericBlockCipher(new BufferedBlockCipher(cipher.getUnderlyingCipher())); cipher = new BufferedGenericBlockCipher(new CTSBlockCipher(cipher.getUnderlyingCipher())); cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher()); cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ZeroBytePadding()); cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ISO10126d2Padding()); cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new X923Padding()); cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ISO7816d4Padding()); cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new TBCPadding());
protected byte[] engineUpdate( byte[] input, int inputOffset, int inputLen) { int length = cipher.getUpdateOutputSize(inputLen); if (length > 0) { byte[] out = new byte[length]; int len = cipher.processBytes(input, inputOffset, inputLen, out, 0); if (len == 0) { return null; } else if (len != out.length) { byte[] tmp = new byte[len]; System.arraycopy(out, 0, tmp, 0, len); return tmp; } return out; } cipher.processBytes(input, inputOffset, inputLen, null, 0); return null; }
param = PBE.Util.makePBEParameters(k.getEncoded(), PKCS12, digest, keySizeInBits, ivLength * 8, pbeSpec, cipher.getAlgorithmName()); param = PBE.Util.makePBEParameters(k.getEncoded(), PKCS12, digest, keySizeInBits, ivLength * 8, pbeSpec, cipher.getAlgorithmName()); param = PBE.Util.makePBEParameters(k.getEncoded(), PKCS5S1, digest, keySizeInBits, ivLength * 8, pbeSpec, cipher.getAlgorithmName()); if (param instanceof ParametersWithIV) param = PBE.Util.makePBEParameters(k, params, cipher.getUnderlyingCipher().getAlgorithmName()); param = PBE.Util.makePBEParameters(k.getEncoded(), scheme, digest, keySizeInBits, ivLength * 8, pbeSpec, cipher.getAlgorithmName()); if (param instanceof ParametersWithIV) ivParam = (ParametersWithIV)param; else if (cipher.getUnderlyingCipher().getAlgorithmName().indexOf("PGPCFB") < 0) cipher.init(true, param); break; case Cipher.DECRYPT_MODE: case Cipher.UNWRAP_MODE: cipher.init(false, param); break; default:
String name = cipher.getUnderlyingCipher().getAlgorithmName();
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws IllegalBlockSizeException, BadPaddingException, ShortBufferException { int len = 0; if (outputOffset + engineGetOutputSize(inputLen) > output.length) { throw new ShortBufferException("output buffer too short for input."); } try { if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } return (len + cipher.doFinal(output, outputOffset + len)); } catch (OutputLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } }
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { if (outputOffset + cipher.getUpdateOutputSize(inputLen) > output.length) { throw new ShortBufferException("output buffer too short for input."); } try { return cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } catch (DataLengthException e) { // should never occur throw new IllegalStateException(e.toString()); } }
protected void engineUpdateAAD(byte[] input, int offset, int length) { cipher.updateAAD(input, offset, length); }
protected int engineGetOutputSize( int inputLen) { return cipher.getOutputSize(inputLen); }