diff options
Diffstat (limited to 'package/source/manifest')
-rw-r--r-- | package/source/manifest/ManifestExport.cxx | 31 | ||||
-rw-r--r-- | package/source/manifest/ManifestImport.cxx | 6 |
2 files changed, 20 insertions, 17 deletions
diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx index 9921b1bad8c8..aa9e9aa2a32f 100644 --- a/package/source/manifest/ManifestExport.cxx +++ b/package/source/manifest/ManifestExport.cxx @@ -337,7 +337,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con xHandler->ignorableWhitespace ( sWhiteSpace ); xHandler->startElement( ELEMENT_FILE_ENTRY , pAttrList); - if ( pVector && pSalt && pIterationCount && pDigest && pDigestAlg && pEncryptAlg && pStartKeyAlg && pDerivedKeySize ) + if (pVector && pSalt && pIterationCount && pEncryptAlg && pStartKeyAlg && pDerivedKeySize) { // ==== Encryption Data rtl::Reference<::comphelper::AttributeList> pNewAttrList = new ::comphelper::AttributeList; @@ -347,20 +347,23 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con xHandler->ignorableWhitespace ( sWhiteSpace ); // ==== Digest - OUString sChecksumType; - sal_Int32 nDigestAlgID = 0; - *pDigestAlg >>= nDigestAlgID; - if ( nDigestAlgID == xml::crypto::DigestID::SHA256_1K ) - sChecksumType = sSHA256_1k_URL; - else if ( nDigestAlgID == xml::crypto::DigestID::SHA1_1K ) - sChecksumType = sSHA1_1k_Name; - else - throw uno::RuntimeException( THROW_WHERE "Unexpected digest algorithm is provided!" ); + if (pDigest && pDigestAlg && pDigestAlg->hasValue()) + { + OUString sChecksumType; + sal_Int32 nDigestAlgID = 0; + *pDigestAlg >>= nDigestAlgID; + if ( nDigestAlgID == xml::crypto::DigestID::SHA256_1K ) + sChecksumType = sSHA256_1k_URL; + else if ( nDigestAlgID == xml::crypto::DigestID::SHA1_1K ) + sChecksumType = sSHA1_1k_Name; + else + throw uno::RuntimeException( THROW_WHERE "Unexpected digest algorithm is provided!" ); - pNewAttrList->AddAttribute ( ATTRIBUTE_CHECKSUM_TYPE, sChecksumType ); - *pDigest >>= aSequence; - ::comphelper::Base64::encode(aBuffer, aSequence); - pNewAttrList->AddAttribute ( ATTRIBUTE_CHECKSUM, aBuffer.makeStringAndClear() ); + pNewAttrList->AddAttribute(ATTRIBUTE_CHECKSUM_TYPE, sChecksumType); + *pDigest >>= aSequence; + ::comphelper::Base64::encode(aBuffer, aSequence); + pNewAttrList->AddAttribute(ATTRIBUTE_CHECKSUM, aBuffer.makeStringAndClear()); + } xHandler->startElement( ELEMENT_ENCRYPTION_DATA , pNewAttrList); diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx index b7aa57f99ff1..0458eb9c4b8e 100644 --- a/package/source/manifest/ManifestImport.cxx +++ b/package/source/manifest/ManifestImport.cxx @@ -164,10 +164,10 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs) } else if ( aString == SHA256_1K_URL ) { aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty; aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA256_1K; - } else - bIgnoreEncryptData = true; + } + // note: digest is now *optional* - expected not to be used with AEAD - if ( !bIgnoreEncryptData ) { + if (aSequence[PKG_MNFST_DIGESTALG].Value.hasValue()) { aString = rConvertedAttribs[ATTRIBUTE_CHECKSUM]; uno::Sequence < sal_Int8 > aDecodeBuffer; ::comphelper::Base64::decode(aDecodeBuffer, aString); |