oox: remove AgileEncryptionPreset::AES_128_SHA1

Should never be produced in practice.
SHA1 may still be used when loading existing document.

Signed-off-by: Michael Stahl <michael.stahl@collabora.com>
Change-Id: Id14c10186a8fae270e75b6cc1cda191dabd9392c
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5166
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
(cherry picked from commit de8c258fac0c878cbb52b9bf819e16ea16e0b484)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207315
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Michael Stahl
2026-06-25 23:57:14 +02:00
committed by Xisco Fauli
parent 25d359ed07
commit b76587cda0
3 changed files with 1 additions and 50 deletions
-1
View File
@@ -63,7 +63,6 @@ struct OOX_DLLPUBLIC AgileEncryptionParameters
enum class AgileEncryptionPreset
{
AES_128_SHA1,
AES_128_SHA384,
AES_192_SHA384,
AES_256_SHA512,
-46
View File
@@ -175,52 +175,6 @@ void CryptoTest::testAgileEncryptionInfoWritingAndParsing()
OUString aPassword(u"Password"_ustr);
std::vector<sal_uInt8> aKeyDataSalt;
{ // Preset AES128 - SHA1
SvMemoryStream aEncryptionInfo;
{
oox::crypto::AgileEngine aEngine;
aEngine.setPreset(oox::crypto::AgileEncryptionPreset::AES_128_SHA1);
aEngine.setupEncryption(aPassword);
aKeyDataSalt = aEngine.getInfo().keyDataSalt;
oox::BinaryXOutputStream aBinaryEncryptionInfoOutputStream(
new utl::OSeekableOutputStreamWrapper(aEncryptionInfo), true);
aEngine.writeEncryptionInfo(aBinaryEncryptionInfoOutputStream);
aBinaryEncryptionInfoOutputStream.close();
CPPUNIT_ASSERT_EQUAL(sal_uInt64(996), aEncryptionInfo.GetSize());
}
aEncryptionInfo.Seek(STREAM_SEEK_TO_BEGIN);
{
oox::crypto::AgileEngine aEngine;
uno::Reference<io::XInputStream> xInputStream(
new utl::OSeekableInputStreamWrapper(aEncryptionInfo));
xInputStream->skipBytes(4); // Encryption type -> Agile
CPPUNIT_ASSERT(aEngine.readEncryptionInfo(xInputStream));
oox::crypto::AgileEncryptionInfo& rInfo = aEngine.getInfo();
CPPUNIT_ASSERT_EQUAL(sal_Int32(100000), rInfo.spinCount);
CPPUNIT_ASSERT_EQUAL(sal_Int32(16), rInfo.saltSize);
CPPUNIT_ASSERT_EQUAL(sal_Int32(128), rInfo.keyBits);
CPPUNIT_ASSERT_EQUAL(sal_Int32(20), rInfo.hashSize);
CPPUNIT_ASSERT_EQUAL(sal_Int32(16), rInfo.blockSize);
CPPUNIT_ASSERT_EQUAL(u"AES"_ustr, rInfo.cipherAlgorithm);
CPPUNIT_ASSERT_EQUAL(u"ChainingModeCBC"_ustr, rInfo.cipherChaining);
CPPUNIT_ASSERT_EQUAL(u"SHA1"_ustr, rInfo.hashAlgorithm);
CPPUNIT_ASSERT_EQUAL(toString(aKeyDataSalt), toString(rInfo.keyDataSalt));
CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"));
CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword));
}
}
{ // Preset AES128 - SHA384
SvMemoryStream aEncryptionInfo;
{
+1 -3
View File
@@ -730,9 +730,7 @@ bool AgileEngine::encryptEncryptionKey(std::u16string_view rPassword)
bool AgileEngine::setupEncryption(OUString const & rPassword)
{
if (meEncryptionPreset == AgileEncryptionPreset::AES_128_SHA1)
setupEncryptionParameters({ 100000, 16, 128, 20, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA1"_ustr });
else if (meEncryptionPreset == AgileEncryptionPreset::AES_128_SHA384)
if (meEncryptionPreset == AgileEncryptionPreset::AES_128_SHA384)
setupEncryptionParameters({ 100000, 16, 128, 48, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA384"_ustr });
else if (meEncryptionPreset == AgileEncryptionPreset::AES_192_SHA384)
setupEncryptionParameters({ 100000, 16, 192, 48, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA384"_ustr });