paragonie / halite

High-level cryptography interface powered by libsodium
https://paragonie.com/project/halite
Mozilla Public License 2.0
1.13k stars 85 forks source link

What's the best way to handle offline decryption? #126

Open elliot-sawyer opened 5 years ago

elliot-sawyer commented 5 years ago

I'm using File::seal to encrypt an uploaded file with a public key. I would like to decrypt it with File::unseal in a separate application using the correct private key, but I'm not able to run a server in the decryption environment. I'd like to create an offline application that replicates what File::unseal does... I attempted to decrypt the cipher with a x25519 Javascript library, but there seems to be more to it than a simple decryption with the private key. Can you outline what steps Halite does, and which ciphers are used, as part of the decryption process?

This library is excellent, thanks so much for creating it!

paragonie-scott commented 5 years ago

It's using crypto_box_seal_open() internally:

https://github.com/paragonie/halite/blob/2879a0e7dfc5d6b00ab12cd2cf0db6cd5ca14e06/src/Asymmetric/Crypto.php#L358-L388

larowlan commented 5 years ago

File:seal seems to be doing something different to Crypto:seal eg adding the version tag, public key and salt - is libsodium's crypto_box_seal_open able to unseal content sealed with File::seal?

elliot-sawyer commented 5 years ago

The JS library I was looking at required some knowledge of the nonce. I don't think Halite exposes it directly, but you might be able to extract it from beginning of the ciphertext