freedomjs / freedom-pgp-e2e

Wrapping up end-to-end code and provide in freedom custom API.
34 stars 6 forks source link

Soycode newapi #8

Closed agallant closed 9 years ago

agallant commented 10 years ago

These commits change the API to a simpler four functions (as discussed in https://github.com/freedomjs/freedom-pgp-e2e/issues/4), and get it working for the current relatively simple tests and demo chrome app. The main thing that could probably use more cleaning up is the use of e2e.async.Result.getValue (and perhaps async/promises in general) - the e2e people have told me they plan to deprecate that within a year. And also, while I for one like this simple API, we will likely need to extend it if we want to persist encrypted data to disk (i.e. https://github.com/freedomjs/freedom-pgp-e2e/issues/7).

Feedback welcome, and I will likely poke at it a bit more to see if I can make the promise/async stuff a bit better (the exportKey function in particular is hacky, but it was the only way I could get it to not complain for the time being - perhaps getting the e2e people to allow their exportKeyRing function to select only public key would be ideal in the long term).

agallant commented 10 years ago

Oh and another comment - for now I'm encrypting/decrypting strings and not byte arrays. That's because I started work on this before e2e added more direct support for that. I'll change it as desired.

willscott commented 10 years ago

After a chat, we'll be seeing if we can remove the dependency on uProxy's typescript system, since this is meant to be more generic than that app.

ryscheng commented 10 years ago

We've released freedom v0.6.0 We should think about upgrading this repo to use this (I think this only affects the sample app)

ryscheng commented 10 years ago

Trying to build the sample app. Getting errors when loading the app. Is that working in this branch? Errors here:

freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [FrameLink0.9867318710312247].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -createLink-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Proxy guid-213-80-204-165-138-45-192-48-203-63-58-62] -channel announcement-> [FrameLink0.9867318710312247].default freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Redirect-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [Console].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Redirect-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Environment Configuration-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [Module Environment Helper].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -createLink-> [FrameLink0.9867318710312247].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [FrameLink0.5778872908558697] -Initialization-> [Module Environment Helper].default freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Module Environment Helper] -Link to core-> [Local Controller].ModuleInternal-0.6844529791269451 freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Provider].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [Module Environment Helper].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [unbound Provider].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [unbound Provider] -channel announcement-> [unbound Proxy].default c37b0f01-744e-407c-94c1-cf9514d98ca5:1031 Uncaught TypeError: Cannot read property 'script' of undefined freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Initialization-> [Module Environment Helper].default 3freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [FrameLink0.5778872908558697] -channel announcement-> [unbound Proxy].default

agallant commented 10 years ago

Good catch, I'd been focusing on the spec and not the sample app. Probably a matter of freedom 0.6 as you said, I'll look into it.

On Tue, Oct 21, 2014 at 8:09 PM, Raymond Cheng notifications@github.com wrote:

Trying to build the sample app. Getting errors when loading the app. Is that working in this branch? Errors here:

freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [FrameLink0.9867318710312247].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -createLink-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Proxy guid-213-80-204-165-138-45-192-48-203-63-58-62] -channel announcement-> [FrameLink0.9867318710312247].default freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Redirect-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [Console].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Redirect-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Environment Configuration-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [Module Environment Helper].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -createLink-> [FrameLink0.9867318710312247].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [FrameLink0.5778872908558697] -Initialization-> [Module Environment Helper].default freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Module Environment Helper] -Link to core-> [Local Controller].ModuleInternal-0.6844529791269451 freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Provider].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [Module Environment Helper].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [unbound Provider].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [unbound Provider] -channel announcement-> [unbound Proxy].default c37b0f01-744e-407c-94c1-cf9514d98ca5:1031 Uncaught TypeError: Cannot read property 'script' of undefined freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Initialization-> [Module Environment Helper].default 3freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [FrameLink0.5778872908558697] -channel announcement-> [unbound Proxy].default

— Reply to this email directly or view it on GitHub https://github.com/freedomjs/freedom-pgp-e2e/pull/8#issuecomment-60030754 .

agallant commented 10 years ago

Or rather not a matter of freedom 0.6 since the main repo isn't using it yet, and right now can't until uproxy-lib does (until that is factored out). So, not sure what the issue is, but will update when I find something.

On Tue, Oct 21, 2014 at 10:34 PM, Aaron Gallant ag@cs.washington.edu wrote:

Good catch, I'd been focusing on the spec and not the sample app. Probably a matter of freedom 0.6 as you said, I'll look into it.

On Tue, Oct 21, 2014 at 8:09 PM, Raymond Cheng notifications@github.com wrote:

Trying to build the sample app. Getting errors when loading the app. Is that working in this branch? Errors here:

freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [FrameLink0.9867318710312247].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -createLink-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Proxy guid-213-80-204-165-138-45-192-48-203-63-58-62] -channel announcement-> [FrameLink0.9867318710312247].default freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Redirect-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [Console].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Redirect-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Environment Configuration-> [Local Controller].Link0.9867318710312247 freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -setup-> [Module Environment Helper].control freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [Local Controller] -createLink-> [FrameLink0.9867318710312247].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [FrameLink0.5778872908558697] -Initialization-> [Module Environment Helper].default freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [FrameLink0.5778872908558697].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Module Environment Helper] -Link to core-> [Local Controller].ModuleInternal-0.6844529791269451 freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Provider].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [Module Environment Helper].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -setup-> [unbound Proxy].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [Local Controller] -createLink-> [unbound Provider].control freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [unbound Provider] -channel announcement-> [unbound Proxy].default c37b0f01-744e-407c-94c1-cf9514d98ca5:1031 Uncaught TypeError: Cannot read property 'script' of undefined freedom-for-chrome-for-uproxy.js:3812 [Module undefined] [FrameLink0.9867318710312247] -Initialization-> [Module Environment Helper].default 3freedom-for-chrome-for-uproxy.js:3812 [Module e2e sample chromeapp] [FrameLink0.5778872908558697] -channel announcement-> [unbound Proxy].default

— Reply to this email directly or view it on GitHub https://github.com/freedomjs/freedom-pgp-e2e/pull/8#issuecomment-60030754 .

agallant commented 9 years ago

Chrome app fixed: https://github.com/freedomjs/freedom-pgp-e2e/commit/0aaee06882ccbd0d9d25165fec0e38c0962ac034

VerifyDecrypt now returns a: { "data": "buffer", "signedBy": ["array", "string"] }

LMK if merging the branch is okay at this point - I could remove the armor/dearmor stuff as I agree it probably won't really work in all cases, but it does at least pass its unit test.

agallant commented 9 years ago

Here's what I was talking about re: armor headers: https://code.google.com/p/end-to-end/source/browse/javascript/crypto/e2e/openpgp/contextimpl.js#83

The e2e contextimpl (basically what does all the crypto) has an armorHeaders_ field that is passed along to asciiArmor.encode (parsing/decoding doesn't need it, reads it from the input presumably). It looks like it can also be overridden/passed in directly, maybe: https://code.google.com/p/end-to-end/source/browse/javascript/crypto/e2e/openpgp/asciiarmor.js#248

Additionally there's a "type" argument, I'm setting it to default as "MESSAGE" but you can pass in other types as appropriate ("SIGNATURE" is of particular note).

Anyway, I do think that separate e2e armor/dearmor may well be workable, but we should do due diligence to make sure whatever we settle on is compatible with other potential providers (particularly subtlecrypto primitives in browser).

willscott commented 9 years ago

couple minor things, but should be fine to merge this and go from here :+1: