if ( bMustDecrypt )
{
m_xCipherContext = ZipFile::StaticGetCipher( xContext, rData, false ); // this is only relevant when padding is used
mnBlockSize = ( rData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 16 : 1 );
}
if (!(bHaveEncryptData && mbWrappedRaw && oDecryptedSize)) return;
// if we have the data needed to decrypt it, but didn't want it decrypted (or // we couldn't decrypt it due to wrong password), then we prepend this // data to the stream
// Make a buffer big enough to hold both the header and the data itself
maHeader.realloc ( n_ConstHeaderSize +
rData->m_aInitVector.getLength() +
rData->m_aSalt.getLength() +
rData->m_aDigest.getLength() +
aMediaType.getLength() * sizeof( sal_Unicode ) );
sal_Int8 * pHeader = maHeader.getArray();
ZipFile::StaticFillHeader(rData, *oDecryptedSize, aMediaType, pHeader);
mnHeaderToRead = static_cast < sal_Int16 > ( maHeader.getLength() );
mnZipSize += mnHeaderToRead;
}
// skip raw header, it must be already parsed to rData
mnZipCurrent = n_ConstHeaderSize + rData->m_aInitVector.getLength() +
rData->m_aSalt.getLength() + rData->m_aDigest.getLength();
try { if ( mxZipSeek.is() )
mnZipSize = mxZipSeek->getLength();
} catch( const Exception& )
{ // in case of problem the size will stay set to 0
TOOLS_WARN_EXCEPTION("package", "ignoring");
}
mnZipEnd = mnZipCurrent + mnZipSize;
// the raw data will not be decrypted, no need for the cipher // m_xCipherContext = ZipFile::StaticGetCipher( xContext, rData, false );
}
mnZipCurrent += nZipRead; // maCompBuffer now has the data, check if we need to decrypt // before passing to the Inflater if ( m_xCipherContext.is() )
{ if ( mbCheckCRC )
maCRC.update( maCompBuffer );
maCompBuffer = m_xCipherContext->convertWithCipherContext( maCompBuffer ); if ( mnZipCurrent == mnZipEnd )
{ // this should throw if AEAD is in use and the tag fails to validate
uno::Sequence< sal_Int8 > aSuffix = m_xCipherContext->finalizeCipherContextAndDispose(); if ( aSuffix.hasElements() )
{
sal_Int32 nOldLen = maCompBuffer.getLength();
maCompBuffer.realloc( nOldLen + aSuffix.getLength() );
memcpy( maCompBuffer.getArray() + nOldLen, aSuffix.getConstArray(), aSuffix.getLength() );
}
}
}
maInflater->setInput ( maCompBuffer );
sal_Int32 SAL_CALL XUnbufferedStream::available( )
{ //available size must include the prepended header in case of wrapped raw stream returnstatic_cast< sal_Int32 > ( std::min< sal_Int64 >( SAL_MAX_INT32, (mnZipSize + mnHeaderToRead - mnMyCurrent) ) );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.