@SuppressWarnings("resource") private StandardCipherOutputStream(DirectoryNode dir, File fileOut) throws IOException { // although not documented, we need the same padding as with agile encryption // and instead of calculating the missing bytes for the block size ourselves // we leave it up to the CipherOutputStream, which generates/saves them on close() // ... we can't use "NoPadding" here // // see also [MS-OFFCRYPT] - 2.3.4.15 // The final data block MUST be padded to the next integral multiple of the // KeyData.blockSize value. Any padding bytes can be used. Note that the StreamSize // field of the EncryptedPackage field specifies the number of bytes of // unencrypted data as specified in section 2.3.4.4. super( new CipherOutputStream(new FileOutputStream(fileOut), getCipher(getSecretKey(), "PKCS5Padding")) ); this.fileOut = fileOut; this.dir = dir; }
@SuppressWarnings("resource") private StandardCipherOutputStream(DirectoryNode dir, File fileOut) throws IOException { // although not documented, we need the same padding as with agile encryption // and instead of calculating the missing bytes for the block size ourselves // we leave it up to the CipherOutputStream, which generates/saves them on close() // ... we can't use "NoPadding" here // // see also [MS-OFFCRYPT] - 2.3.4.15 // The final data block MUST be padded to the next integral multiple of the // KeyData.blockSize value. Any padding bytes can be used. Note that the StreamSize // field of the EncryptedPackage field specifies the number of bytes of // unencrypted data as specified in section 2.3.4.4. super( new CipherOutputStream(new FileOutputStream(fileOut), getCipher(getSecretKey(), "PKCS5Padding")) ); this.fileOut = fileOut; this.dir = dir; }