Code Monkey home page Code Monkey logo

Comments (5)

rweather avatar rweather commented on June 19, 2024 1

My library provides the basic building blocks for creating larger protocols like PEM, SSL/TLS, Noise, etc but it doesn't currently implement any of them.

Ed25519 is for signatures only. It doesn't provide any encryption facilities. A separate mechanism needs to be provided to encrypt the message contents. The usual method would be to use Curve25519 to establish a shared secret between the parties, and then hash that to create a key for AES-CTR or something similar. Then ed25519 is used to sign the encrypted message that is sent under the shared secret to verify the origin.

In general, encrypt-then-sign is the better choice because if an attacker manages to break the signature scheme, all they learn is statistical information about the ciphertext - which they already have. With sign-then-encrypt, if the signature scheme is broken then the attacker may learn some statistical information about the plaintext. The same applies to authenticated encryption modes like GCM and EAX.

from arduinolibs.

WildCryptoFox avatar WildCryptoFox commented on June 19, 2024 1

Hello. I found this issue while searching for the following link I referenced to a friend.

https://theworld.com/~dtd/sign_encrypt/sign_encrypt7.html

This article describes why you don't want either sign-then-encrypt nor encrypt-then-sign and offers (dated) alternatives.

Short version. If Alice signs a message "I love you" and encrypts it to Bob, then Bob may re-encrypt the signed message and send Alice' love letter to Carol, who now believes Alice loves Carol. If Alice encrypts the same message for Bob and signs it, an active attacker may intercept the message and replace the signature with her own.

The "simple solution" (one of several offered in the article) is to sign the message along with a tag saying who the intended recipient is, then encrypt it.

The typical modern solution is hybrid encryption, meaning you asymmetrically exchange a key you then use to symmetrically authenticate and encrypt the messages. For one-offs use libsodium's crypto_box. To auth-encrypt a sequence of related messages and detect messages being dropped, duplicated, reordered, or truncated; use libsodium's secret_stream interface. Unlike crypto_box the secret_stream consumes a preshared key, so you'll need to do the key exchange yourself. For this I recommend 3DH (triple Diffie-Hellman) with static and ephemeral keypairs on both sides, using curve25519. This gives you 3 uniform keys, hash them together with blake2 to establish the shared session key.

(Ignore the X [dotted line] of Signal's X3DH to get the simpler and stronger 3DH.)

from arduinolibs.

kitmonisit avatar kitmonisit commented on June 19, 2024

Thank you @rweather. I understand only bits and pieces of your comment (no fault of yours, of course), and by now my lack of understanding of encryption should be evident. Do you have examples demonstrating simple interfaces for encrypting, signing, and decrypting? Similar to these: PyNaCl public key encryption and PyNaCl digital signatures.

from arduinolibs.

dastultz avatar dastultz commented on June 19, 2024

In general, encrypt-then-sign is the better choice because if an attacker manages to break the signature scheme

If you sign then encrypt one would need to first break the outer encryption before having access to the signature scheme. This article makes a pretty good case for sign then encrypt: https://www.quora.com/Which-one-is-more-preferable-encrypt-then-sign-or-sign-then-encrypt

from arduinolibs.

patrickduc avatar patrickduc commented on June 19, 2024

In general, encrypt-then-sign is the better choice because if an attacker manages to break the signature scheme

If you sign then encrypt one would need to first break the outer encryption before having access to the signature scheme. This article makes a pretty good case for sign then encrypt: https://www.quora.com/Which-one-is-more-preferable-encrypt-then-sign-or-sign-then-encrypt

Thanks for the comment. However, I don't agree with you. Or I should say, experts don't agree with you. This is a good reference on the subject : https://docs.google.com/viewer?url=https%3A%2F%2Fwww.iacr.org%2Farchive%2Fcrypto2001%2F21390309.pdf

from arduinolibs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.