securityHandler.decryptStream(stream, objKey.getNumber(), objKey.getGeneration()); securityHandler.decrypt(pb, objKey.getNumber(), objKey.getGeneration());
encryptDataAES256(data, output, decrypt); byte[] finalKey = calcFinalKey(objectNumber, genNumber); encryptDataAESother(finalKey, data, output, decrypt); encryptDataRC4(finalKey, data, output);
decryptString((COSString) obj, objNum, genNum); decryptStream((COSStream) obj, objNum, genNum); decryptDictionary((COSDictionary) obj, objNum, genNum); decryptArray((COSArray) obj, objNum, genNum);
decryptDictionary(stream, objNum, genNum); byte[] encrypted = IOUtils.toByteArray(stream.createRawInputStream()); ByteArrayInputStream encryptedStream = new ByteArrayInputStream(encrypted); try (OutputStream output = stream.createRawOutputStream()) encryptData(objNum, genNum, encryptedStream, output, true /* decrypt */);
/** * This will decrypt an array. * * @param array The array to decrypt. * @param objNum The object number. * @param genNum The object generation number. * * @throws IOException If there is an error accessing the data. */ private void decryptArray(COSArray array, long objNum, long genNum) throws IOException { for (int i = 0; i < array.size(); i++) { decrypt(array.get(i), objNum, genNum); } }
/** * This will encrypt a string. * * @param string the string to encrypt. * @param objNum The object number. * @param genNum The object generation number. * * @throws IOException If an error occurs writing the new string. */ public void encryptString(COSString string, long objNum, int genNum) throws IOException { ByteArrayInputStream data = new ByteArrayInputStream(string.getBytes()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); encryptData(objNum, genNum, data, buffer, false /* encrypt */); string.setValue(buffer.toByteArray()); }
if (securityHandler != null) securityHandler.decryptStream(stream, stmObjNumber, stmGenNumber);
decrypt(value, objNum, genNum);
decryptDictionary(stream, objNum, genNum); byte[] encrypted = IOUtils.toByteArray(stream.createRawInputStream()); ByteArrayInputStream encryptedStream = new ByteArrayInputStream(encrypted); try encryptData(objNum, genNum, encryptedStream, output, true /* decrypt */);
/** * This will decrypt a string. * * @param string the string to decrypt. * @param objNum The object number. * @param genNum The object generation number. * * @throws IOException If an error occurs writing the new string. */ private void decryptString(COSString string, long objNum, long genNum) throws IOException { ByteArrayInputStream data = new ByteArrayInputStream(string.getBytes()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { encryptData(objNum, genNum, data, outputStream, true /* decrypt */); string.setValue(outputStream.toByteArray()); } catch (IOException ex) { LOG.error("Failed to decrypt COSString of length " + string.getBytes().length + " in object " + objNum + ": " + ex.getMessage(), ex); } }
if (securityHandler != null) securityHandler.decryptStream(stream, stmObjNumber, stmGenNumber);
if (securityHandler != null) securityHandler.decryptStream(stream, objNr, objGenNr); securityHandler.decrypt(pb, objNr, objGenNr);
decryptString((COSString) obj, objNum, genNum); decryptStream((COSStream) obj, objNum, genNum); decryptDictionary((COSDictionary) obj, objNum, genNum); decryptArray((COSArray) obj, objNum, genNum);
encryptDataAES256(data, output, decrypt); byte[] finalKey = calcFinalKey(objectNumber, genNumber); encryptDataAESother(finalKey, data, output, decrypt); encryptDataRC4(finalKey, data, output);
/** * This will decrypt an array. * * @param array The array to decrypt. * @param objNum The object number. * @param genNum The object generation number. * * @throws IOException If there is an error accessing the data. */ private void decryptArray(COSArray array, long objNum, long genNum) throws IOException { for (int i = 0; i < array.size(); i++) { decrypt(array.get(i), objNum, genNum); } }
decryptDictionary(stream, objNum, genNum); byte[] encrypted = IOUtils.toByteArray(stream.createRawInputStream()); ByteArrayInputStream encryptedStream = new ByteArrayInputStream(encrypted); try (OutputStream output = stream.createRawOutputStream()) encryptData(objNum, genNum, encryptedStream, output, true /* decrypt */);
/** * This will encrypt a stream, but not the dictionary as the dictionary is * encrypted by visitFromString() in COSWriter and we don't want to encrypt * it twice. * * @param stream The stream to decrypt. * @param objNum The object number. * @param genNum The object generation number. * * @throws IOException If there is an error getting the stream data. */ public void encryptStream(COSStream stream, long objNum, int genNum) throws IOException { byte[] rawData = IOUtils.toByteArray(stream.createRawInputStream()); ByteArrayInputStream encryptedStream = new ByteArrayInputStream(rawData); try (OutputStream output = stream.createRawOutputStream()) { encryptData(objNum, genNum, encryptedStream, output, false /* encrypt */); } }
securityHandler.decryptStream(stream, objKey.getNumber(), objKey.getGeneration()); securityHandler.decrypt(pb, objKey.getNumber(), objKey.getGeneration());
decryptString((COSString) obj, objNum, genNum); decryptStream((COSStream) obj, objNum, genNum); decryptDictionary((COSDictionary) obj, objNum, genNum); decryptArray((COSArray) obj, objNum, genNum);
encryptDataAES256(data, output, decrypt); byte[] finalKey = calcFinalKey(objectNumber, genNumber); encryptDataAESother(finalKey, data, output, decrypt); encryptDataRC4(finalKey, data, output);