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

Very slow encrypt speed #225

Closed
xqdoo00o opened this issue Mar 3, 2021 · 11 comments
Closed

Very slow encrypt speed #225

xqdoo00o opened this issue Mar 3, 2021 · 11 comments

Comments

@xqdoo00o
Copy link

xqdoo00o commented Mar 3, 2021

Every 16 bytes a async func subtle.encrypt is the most doubtful reason, too much async functions, and it's serial runs.

But If use Web Crypto API, it's necessary to do it, because the ctr mode counter is difference with NIST standard.

So I recommend use sjcl to do it.

I read this 101arrowz/fflate#45 , then I try to use, and found the issue.

@gildas-lormeau
Copy link
Owner

I agree that encryption is slow for the reasons you mentioned. I'll try to integrate sjcl and do some tests. I'm not sure it will be faster though.

@xqdoo00o
Copy link
Author

xqdoo00o commented Mar 3, 2021

I compared with this Stuk/jszip#696 , It's 10x faster on my machine even without fflate(using pako) .

@gildas-lormeau
Copy link
Owner

@xqdoo00o Out of curiosity, wouldn't you want to contribute to zip.js in order to integrate sjcl?

@xqdoo00o
Copy link
Author

xqdoo00o commented Mar 3, 2021

I will if I have time

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Mar 3, 2021

I'm asking you this because I looked at your implementation and I'm realizing you have a certain level of expertise with sjcl that I don't have.

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Mar 9, 2021

I rollbacked the changes, the implementation is still buggy...

@xqdoo00o
Copy link
Author

xqdoo00o commented Mar 9, 2021

To simplify the code, if using pako to deflate, the pako output chunksize is alway 16384 except the last chunk. so don't need pendingInput in AESEncrypt constructor if it's pako mode, the fflate mode need.
And the AESEncrypt constructor need a ctrgladman instance.

@xqdoo00o
Copy link
Author

xqdoo00o commented Mar 9, 2021

I could modify the code today or tomorrow

@gildas-lormeau
Copy link
Owner

Actually, my unit tests worked with my implementation of Deflate/Inflate. However, there was an issue when It tried the implementation with the demos. It was a bit late so I preferred to rollback, I don't think it's a big issue. Hopefully, I'll be able to fix it today. I'll keep you updated :)

@xqdoo00o
Copy link
Author

xqdoo00o commented Mar 9, 2021

Ok, I find a issue that the commit make fromBits return Uint8Array instances, the output length is not input length, so the commit is total useless.

@gildas-lormeau
Copy link
Owner

Oh thank you! As I said, it was late. Sorry for that totally useless commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants