hyperledger-archives / ursa

Hyperledger Ursa (a shared cryptographic library) has moved to end-of-life status, with the components of Ursa still in use moved to their relevant Hyperledger projects (AnonCreds, Indy, Aries and Iroha).
https://wiki.hyperledger.org/display/ursa
Apache License 2.0
321 stars 142 forks source link

Add non-extended chacha20poly1305 #111

Closed andrewwhitehead closed 4 years ago

andrewwhitehead commented 4 years ago

Also updates chacha20poly1305 crate to 0.4.1

mikelodder7 commented 4 years ago

@andrewwhitehead Thanks for this PR. Is there a compatibility reason or streaming reason for using chacha20poly1305? In most cases xchacha20poly1305 is preferred except in those two cases.

andrewwhitehead commented 4 years ago

@mikelodder7 Yes, it's for compatibility with the current Indy pack/unpack, which advertises xchacha but doesn't actually use it.

kdenhartog commented 4 years ago

@mikelodder7 Yes, it's for compatibility with the current Indy pack/unpack, which advertises xchacha but doesn't actually use it.

@andrewwhitehead Yeahhhhh.... Sorry bout that headache. Maybe we can make it consistent eventually?

andrewwhitehead commented 4 years ago

@kdenhartog Because the nonce is detached, it would be pretty easy to support both by checking its length first (12 or 24 bytes).

andrewwhitehead commented 4 years ago

Also the updated pack/unpack exists here now: https://github.com/bcgov/indy-shared-rs/blob/master/indy-utils/src/pack/alg.rs

It uses the crypto_box crate to create/open the nacl crypto box, and implements the sealed box manually.

kdenhartog commented 4 years ago

@kdenhartog Because the nonce is detached, it would be pretty easy to support both by checking its length first (12 or 24 bytes).

We could just add support for both rather than relying on the implementation supporting only xchacha as well. I think it would be good to not indicate the wrong type of algorithm being used in the headers if it's possible to get everyone doing that.

Also the updated pack/unpack exists here now: https://github.com/bcgov/indy-shared-rs/blob/master/indy-utils/src/pack/alg.rs

It uses the crypto_box crate to create/open the nacl crypto box, and implements the sealed box manually.

Thanks for sending me this link, I wasn't sure where the code for this was at these days.