stef / pysodium

wrapper for libsodium providing high level crypto primitives
Other
130 stars 50 forks source link

how to use a specific algorithm #94

Open rofl0r opened 4 years ago

rofl0r commented 4 years ago

i'd like to use crypto_box_curve25519xsalsa20poly1305 so i know what i get, but it isn't provided.

stef commented 4 years ago

it's kinda organic, if people miss a function they most of the time add it themselves and i just merge it in. it's pretty easy, checkout this https://github.com/stef/pysodium/blob/master/pysodium/__init__.py - and also previous closed PRs are a good info source.

jedisct1 commented 4 years ago

It's already there and it's simply called crypto_box().

The full name crypto_box_curve25519xsalsa20poly1305 is just a deprecated alias for backward compatibility with the original NaCl API.

rofl0r commented 4 years ago

It's already there and it's simply called crypto_box().

no, it isn't. i want to use the full name of the API so if in 5 years a new algorithm is considered more secure and the default changed to point to that, my program will continue working because it explicitily calls crypto_box_curve25519xsalsa20poly1305.

jedisct1 commented 4 years ago

https://doc.libsodium.org/quickstart#shall-i-call-crypto_generichash_blake-2-b-or-just-crypto_generichash

What is more likely is that undocumented, low-level APIs like this one will eventually get removed.

rofl0r commented 4 years ago

What is more likely is that undocumented, low-level APIs like this one will eventually get removed.

if they'd do that, generated keys for the current "whatever-is-currently-standard" API would suddenly stop working. imagine if you'd lose the key to your bitcoin wallet due to such a change... i suppose djb had a reason that e.g. tweetnacl ships with a huge header file that defines all these "undocumented, low-level APIs"

jedisct1 commented 4 years ago

Just use crypto_box (or, better, crypto_kx and an AEAD). It won't be changed to a different algorithm. All high-level APIs won't see breaking changes.

Anyway, the good news is that what you are asking already exists in PySodium.

stef commented 3 years ago

if you agree i'll close this issue next time i come across it.