I have thought a bit more about how to integrate WebWorker/Multithreading
support gracefully into OpenPGP.js. Here's my suggestion:


   1. We create a "wrapper" for the web worker code in
   'src/ciphers/openpgp.crypto.worker.js'
   2. This file gets a dependeny to the synchronous symmetric entryption
   logic currently in 'src/ciphers/openpgp.crypto.sym.js' (see webworker
   branch).
   3. We add an additional (optional) asynchronous callback to the place
   that usually invokes 'openpgp_crypto_symmetricEncrypt' and
   'openpgp_crypto_symmetricDecrypt'. In that place, we check for WebWorker
   support and 'if(window.Worker)' we
   invoke 'src/ciphers/openpgp.crypto.worker.js' else we invoke the symmetric
   crypto in 'src/ciphers/openpgp.crypto.sym.js' as usual. Only that the
   values will be returned through the "asynchronous" callback rather than
   through return. If the optional callback is not defined by the caller, we
   return the synchronous/blocking symmetric crypto as usual.

This approach would not break the current public API of openpgp.js, but
rather add optional multithreading support. I think it would be better to
do it this way than refactor the API for only asynchronous style, since
it's easier to get started using the librara if it's synchronous by
default. Also most applications such as simple email encryption will not
require multithreading.

Carsten, Sean... I am currently not familiar enough with the code to know
where 3. should take place. Any thoughts?

Tankred


Am 7. April 2012 07:23 schrieb Tankred Hase <[email protected]>:

> Here's a link to the changes on Github:
> https://github.com/openpgpjs/openpgpjs/pull/39
>
> Oh, and Happy Easter from the bunny, btw :)
>
> Tankred
>
> Am 6. April 2012 23:12 schrieb Tankred Hase <[email protected]>:
>
> Hi,
>>
>> I've got openpgp.js' symmetric encryption working in a seperate web
>> worker thread. If anyone is interest, here's the code:
>>
>>
>> https://github.com/tanx/SafeWith.me/blob/webworker/war/js/safewithme.crypto.js#L336
>>
>> This required some minor refactoring/modularization to openpgp.js and I
>> created a pull request on Github. Feedback is welcome.
>>
>> Tankred
>>
>
>
_______________________________________________

http://openpgpjs.org

Reply via email to