Closed hackwaly closed 6 years ago
Hi, starting from https://github.com/vibornoff/asmcrypto.js/commit/4e64ff14cb91621e0f9900a8eb9e98e5a8325fff you can use progressive cipher interface.
var encryptor = new asmCrypto.AES_CFB.Encrypt( { key: ..., iv: ... } );
var ciphertext1 = encryptor.process(cleartext1).result;
var ciphertext2 = encryptor.process(cleartext2).result;
...
var ciphertextN = encryptor.finish().result;
This is quite new feature and it hasn't been release yet, so you have to build asmcrypto.js from the source.
It's pretty good! I've tried it yesterday. But it doesn't cover my needs. CFB mode do not need padding, and it can encrypt any length plaintext. Somehow I need this feature: The process method in CFB mode should returns ciphertext as same length as plaintext. So I can use it for socket encryption with no delay and no wrappings.
I'm trying to adapt this library to gopherjs to get huge performance improvement. In gopherjs, AES encryption takes nearly 1 second when encrypt 1MB text.
Thanks for your awesome works!
CFB mode do not need padding
Yup, it doesn't. Just a doc error.
The process method in CFB mode should returns ciphertext as same length as plaintext.
Unfortunely it's not possible for now. I'm working on this. That relates to CTR, CCM, GCM and OBF modes too.
Thanks. That's will be excited!
You can check pako.js' inflate/deflate stream interface, I think we could apply it here.
You can check pako.js' inflate/deflate stream interface, I think we could apply it here.
Bad idea, take a look to pako.js README:
var inflator = new pako.Inflate();
inflator.push(chunk1, false);
inflator.push(chunk2, false);
...
inflator.push(chunkN, true); // true -> last chunk
...
var output = inflator.result;
Great, we end up with a gigabyte of inflator.result
held in memory.
Sorry, I didn't mean the default API: http://nodeca.github.io/pako/#Deflate.prototype.onData
AES_CFB.encrypt
doesn't return the iv for next encrypt. Maybe it will preserve iv internally for next encrypt, but it looks like all aes encrypt or decrypt operation share one asm module. It will conflict when more than one cfb stream encrypt process with out of order. So, how can I use asmcrypto to implement aes-cfb stream?