This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
Implemented optimal CMAC calculation for WebCrypto #156
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.ts
that 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!