CryptoOperation and its life cycle

Some short questions on CryptoOperation and its life-cycle:

1. Is there a reason that the init() method needs to be explicit for CryptoOperation objects?  If there's initialization to do, couldn't the operation object just do it on the first non-trivial call it gets?  

2. When do results get passed back?  It's not clear to me from the current spec what the state of the "result" field in the operation should be. One can imagine multiple outcomes.  For example, with digest, MAC, or signature, you would only get results in oncomplete().  But with encryption or decryption, you could get intermediate results in onprogress().  Or perhaps this is implementation-dependent?

3. Is there a reason that complete() doesn't take data?  It seems like it would simplify things slightly if you could pass in the last chunk at that point.  (Internally, the implementation could "processData(data); complete();".)  

Basically, I'm wondering if we could have the following work flow for a simple case:

var e = new Encryptor(/* params */);
e.oncomplete = function(event) {
  // Do something with event.target.results;
}
e.complete("Attack at dawn!");

Thanks,
--Richard

Received on Tuesday, 11 December 2012 14:15:02 UTC