Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

espsecure: Run AES-XTS encryption in O(n) instead of O(n^2) time complexity (ESPTOOL-523) #783

Merged
merged 1 commit into from
Sep 21, 2022

Conversation

Emill
Copy link
Contributor

@Emill Emill commented Sep 21, 2022

Description of change

The espsecure tool is currently very slow at encrypting large files with AES-XTS. The code currently runs in $O(n^2)$ time complexity, which is very bad.

Some timing I did on my computer:

Size Time
1 MByte 0.514s
2 MByte 1.973s
4 MByte 8.806s
8 MByte 37.318s

With this patch, these are the new results:

Size Time
1 MByte 0.146s
2 MByte 0.228s
4 MByte 0.391s
8 MByte 0.572s

I have run the esptool.py automated integration tests with this change. The results were:

.......................
----------------------------------------------------------------------
Ran 23 tests in 2.970s

OK

@radimkarnis
Copy link
Collaborator

Hello @Emill,
thank you for contributing. This is a great improvement! Thank you for optimizing this.

I will put this PR through our internal review queue and merge. I also want to ask you to rebase on top of master, you will get a contributor credit (doesn't happen if I rebase for you).

@github-actions github-actions bot changed the title espsecure: Run AES-XTS encryption in O(n) instead of O(n^2) time complexity espsecure: Run AES-XTS encryption in O(n) instead of O(n^2) time complexity (ESPTOOL-523) Sep 21, 2022
@Emill
Copy link
Contributor Author

Emill commented Sep 21, 2022

Ok, rebased!

@dobairoland
Copy link
Collaborator

Thank you for the improvement!

@espressif-bot espressif-bot merged commit 06aab4a into espressif:master Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants