This repository was archived by the owner on Feb 5, 2021. It is now read-only.
Implemented optimal CMAC calculation for WebCrypto#156
Open
Traktormaster wants to merge 4 commits intomiscreant:developfrom
Open
Implemented optimal CMAC calculation for WebCrypto#156Traktormaster wants to merge 4 commits intomiscreant:developfrom
Traktormaster wants to merge 4 commits intomiscreant:developfrom
Conversation
Author
|
The second optimization further reduces the number of CBC encrypt calls by batching the data together and only calling encrypt once in This helps some more when a lot of small messages are to be handled. For example: encrypting 2000 100B messages took 0.95 seconds before the second patch, while the same only needs 0.6 seconds to complete now. It's a ~30% improvement for this type of load. There is no performance change for encrypting a small number of large messages. This has the trade-off of having to batch and prepare all the data in a single buffer. This uses more RAM, but is vastly superior in execution time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've found myself in a situation where this AES-SIV implementation would be great for use, but its performance was very lacking.
After digging a bit I've found that the CMAC calculation is very badly optimized and (unlike the PMAC) it should be trivial to improve.
I've basically solved the TODO in the
cmac.tsthat said:use AES-CBC with a span of multiple blocks instead of encryptBlock to encrypt many blocks in a single call to the WebCrypto API.I've added the necessary interface changes and compatibility for the software aes fallback provider. Of course the performance of that is not any better. Unit tests are still passing.
In summary this change improved the performance of AES-CMAC-SIV.
For example, the encoding performance improved from 400KB/s to 120MB/s!