Bug 116964 - Calc file with password takes a long time to open and save
Summary: Calc file with password takes a long time to open and save
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.1.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, perf
: 122060 122377 (view as bug list)
Depends on:
Blocks: Password-Protected
  Show dependency treegraph
 
Reported: 2018-04-12 09:52 UTC by Salim Habchi
Modified: 2020-07-12 19:45 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
File for testing (password: 1811) (567.36 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-04-12 09:52 UTC, Salim Habchi
Details
same file without password (549.24 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-04-12 09:53 UTC, Salim Habchi
Details
New file with patch (password: 1811) (566.97 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-04-18 08:51 UTC, Salim Habchi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Salim Habchi 2018-04-12 09:52:02 UTC
Created attachment 141304 [details]
File for testing (password: 1811)

Problem description: 
When you choose to save your file with a password, it takes long time to save and open.

Steps to reproduce:
1. Create a file with a large amount of contents.
2. Save your file with a password (Edit -> Save as).
3. Try to open it.

Operating System: All
Version: 6.1.0.0.alpha0+ Master
Comment 1 Salim Habchi 2018-04-12 09:53:28 UTC
Created attachment 141305 [details]
same file without password
Comment 2 Julien Nabet 2018-04-12 13:12:16 UTC Comment hidden (obsolete)
Comment 3 Salim Habchi 2018-04-12 13:40:04 UTC Comment hidden (obsolete)
Comment 4 Julien Nabet 2018-04-12 13:43:55 UTC Comment hidden (obsolete)
Comment 5 Xavier Van Wijmeersch 2018-04-13 06:42:39 UTC
opening the test file with password, it take 7.0 seconds and without 4.0 seconds a bit slow when switching between sheets and i think its because of the many chart on every sheet

Version: 6.1.0.0.alpha0+
Build ID: 4ab0912cd214a4b0bdcbcdd2711b831dab9ca60a
CPU threads: 8; OS: Linux 4.14; UI render: default; VCL: kde4; 
Locale: nl-BE (en_US.UTF-8); Calc: group
Comment 6 Salim Habchi 2018-04-13 07:40:25 UTC
(In reply to Xavier Van Wijmeersch from comment #5)
> opening the test file with password, it take 7.0 seconds and without 4.0
> seconds a bit slow when switching between sheets and i think its because of
> the many chart on every sheet
> 
> Version: 6.1.0.0.alpha0+
> Build ID: 4ab0912cd214a4b0bdcbcdd2711b831dab9ca60a
> CPU threads: 8; OS: Linux 4.14; UI render: default; VCL: kde4; 
> Locale: nl-BE (en_US.UTF-8); Calc: group

Hello,

Try to add a simple modification to the file with password and save it.

It will take a lot of time.
Comment 7 Xisco Faulí 2018-04-13 07:49:35 UTC
Yes, it hangs in 

Version: 6.1.0.0.alpha0+
Build ID: 24a57e2b854a1b8b3b8533ac72a6614ee29e374a
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group
Comment 8 Xisco Faulí 2018-04-13 07:55:36 UTC
In previous versions like

Version: 5.2.0.0.alpha0+
Build ID: 3ca42d8d51174010d5e8a32b96e9b4c0b3730a53
Threads 4; Ver: 4.10; Render: default;

or

Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e

it hangs at import time...
Comment 9 Xisco Faulí 2018-04-13 08:11:03 UTC
The import hang was fixed by

author	Mike Kaganski <mike.kaganski@collabora.com>	2017-11-07 13:33:48 +0300
committer	Noel Grandin <noel.grandin@collabora.co.uk>	2017-11-07 14:26:11 +0100
commit	f657454b69c813b90a8b3c1adb2feef1066dbd35 (patch)
tree	d1c57e8dc220ae1a5e7d1a2b49025685042318f3
parent	55d00081d0dc4cfa3361fa9da9389042f98773b5 (diff)
tdf#31231: properly check for SvXMLImportFlags::ALL
A regression from commit dc28e90d200a839d4017d548217ee5ce8a23f84

Adding Mike Kaganski to the loop in case Salim Habchi needs help to fix the export part...
Comment 10 Salim Habchi 2018-04-13 08:43:41 UTC
Import = when you open the file ?
Export = when you save the file ?

Thank you very much, I will explore the tracks you gave me.
Comment 11 Salim Habchi 2018-04-18 08:07:19 UTC
here is my commit on gerrit for this bug

https://gerrit.libreoffice.org/#/c/53083/
Comment 12 Salim Habchi 2018-04-18 08:35:30 UTC
I decreased the number of iterations in PBDFK2 because it was set to 100000 but it 

takes a lot of time to save a file (10 min).

the problem comes from these iterations.

I put the number of iterations to 1000.

now it takes 10 sec to save a file.

the derived key is sufficient for this type of files and it is very secure if you choose a good password.

The informations below shows how long an attacker would take to cover the entire password space of a single salted hashed password.

Complexity password

* Comprehensive8: 4 hours 46 minutes

* 8 random lowercase letters: 12 hours

* 8 random letters: 123 days

* 8 letters + digits + punctuation OR 4 random Diceware words: 325 years

From: https://cryptosense.com/blog/parameter-choice-for-pbkdf2/
Other link: https://www.cloudberrylab.com/download/CloudBerry%20Lab%20Security%20Considerations.pdf

If you want to test this patch with the old testing file you must save at least one time the file with this patch.

I will add the same file with my patch.
Comment 13 Julien Nabet 2018-04-18 08:37:27 UTC
Thorsten: noticing you had removed a similar loop in https://cgit.freedesktop.org/libreoffice/core/commit/?id=39805f65189cd0085fe8f1071ae75cdec450c65e, thought you might be interested in the patch proposed by Salim.
Comment 14 Salim Habchi 2018-04-18 08:51:43 UTC
Created attachment 141448 [details]
New file with patch (password: 1811)
Comment 15 Telesto 2018-05-19 19:54:08 UTC
See also bug 105844 comment 12 & 13
Comment 16 Buovjaga 2019-04-18 20:40:04 UTC
*** Bug 122060 has been marked as a duplicate of this bug. ***
Comment 17 Buovjaga 2019-04-18 20:40:41 UTC
*** Bug 122377 has been marked as a duplicate of this bug. ***