Kaydet (Commit) 6d673473 authored tarafından Eike Rathke's avatar Eike Rathke

Move OOXML password definitions to struct ScOoxPasswordHash, tdf#104250 prep

Change-Id: I595d5ae8db6f739900afdfdde1e36b0a0b1d2179
üst 1f159a4d
......@@ -39,6 +39,18 @@ enum ScPasswordHash
PASSHASH_UNSPECIFIED
};
/// OOXML password definitions: algorithmName, hashValue, saltValue, spinCount
struct ScOoxPasswordHash
{
OUString maAlgorithmName; /// "SHA-512", ...
OUString maHashValue; /// base64 encoded hash value
OUString maSaltValue; /// base64 encoded salt value
sal_uInt32 mnSpinCount; /// spin count, iteration runs
ScOoxPasswordHash() : mnSpinCount(0) {}
bool hasPassword() const { return !maHashValue.isEmpty(); }
};
namespace ScPassHashHelper
{
/** Check for the compatibility of all password hashes. If there is at
......@@ -117,13 +129,9 @@ struct ScEnhancedProtection
OUString maTitle;
::std::vector< sal_uInt8 > maSecurityDescriptor; // imported as raw BIFF data
OUString maSecurityDescriptorXML; // imported from OOXML
// OOXML password definitions
OUString maAlgorithmName;
OUString maHashValue;
OUString maSaltValue;
sal_uInt32 mnSpinCount;
ScOoxPasswordHash maPasswordHash;
ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0), mnSpinCount(0) {}
ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0) {}
bool hasSecurityDescriptor() const
{
......@@ -132,7 +140,7 @@ struct ScEnhancedProtection
bool hasPassword() const
{
return mnPasswordVerifier != 0 || !maHashValue.isEmpty();
return mnPasswordVerifier != 0 || maPasswordHash.hasPassword();
}
};
......
......@@ -516,10 +516,10 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm )
* 'algorithmName', 'hashValue', 'saltValue' and
* 'spinCount' are absent; so do we if it was present. */
XML_password, (*it).mnPasswordVerifier ? OString::number( (*it).mnPasswordVerifier, 16).getStr() : nullptr,
XML_algorithmName, (*it).maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maAlgorithmName).getStr(),
XML_hashValue, (*it).maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maHashValue).getStr(),
XML_saltValue, (*it).maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maSaltValue).getStr(),
XML_spinCount, (*it).mnSpinCount ? OString::number( (*it).mnSpinCount).getStr() : nullptr,
XML_algorithmName, (*it).maPasswordHash.maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maPasswordHash.maAlgorithmName).getStr(),
XML_hashValue, (*it).maPasswordHash.maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maPasswordHash.maHashValue).getStr(),
XML_saltValue, (*it).maPasswordHash.maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maPasswordHash.maSaltValue).getStr(),
XML_spinCount, (*it).maPasswordHash.mnSpinCount ? OString::number( (*it).maPasswordHash.mnSpinCount).getStr() : nullptr,
XML_sqref, (*it).maRangeList.is() ? XclXmlUtils::ToOString( *(*it).maRangeList).getStr() : nullptr,
FSEND);
}
......
......@@ -144,10 +144,10 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs )
* 'saltValue' and 'spinCount' that are written if the protection was newly
* created. */
aProt.mnPasswordVerifier = rAttribs.getIntegerHex( XML_password, 0);
aProt.maAlgorithmName = rAttribs.getString( XML_algorithmName, OUString());
aProt.maHashValue = rAttribs.getString( XML_hashValue, OUString());
aProt.maSaltValue = rAttribs.getString( XML_saltValue, OUString());
aProt.mnSpinCount = rAttribs.getUnsigned( XML_spinCount, 0);
aProt.maPasswordHash.maAlgorithmName = rAttribs.getString( XML_algorithmName, OUString());
aProt.maPasswordHash.maHashValue = rAttribs.getString( XML_hashValue, OUString());
aProt.maPasswordHash.maSaltValue = rAttribs.getString( XML_saltValue, OUString());
aProt.maPasswordHash.mnSpinCount = rAttribs.getUnsigned( XML_spinCount, 0);
OUString aRefs( rAttribs.getString( XML_sqref, OUString()));
if (!aRefs.isEmpty())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment