Skip to content

Commit

Permalink
Add a warning about AEAD use
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeickert committed Dec 19, 2023
1 parent 78e7d1e commit bfa4851
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libspark/aead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace spark {

// Perform authenticated encryption with ChaCha20-Poly1305 using key commitment
// NOTE: This uses a fixed zero nonce, which is safe when used in Spark as directed
// It is NOT safe in general to do this!
AEADEncryptedData AEAD::encrypt(const GroupElement& prekey, const std::string additional_data, CDataStream& data) {
// Set up the result structure
AEADEncryptedData result;
Expand Down Expand Up @@ -43,6 +45,8 @@ AEADEncryptedData AEAD::encrypt(const GroupElement& prekey, const std::string ad
}

// Perform authenticated decryption with ChaCha20-Poly1305 using key commitment
// NOTE: This uses a fixed zero nonce, which is safe when used in Spark as directed
// It is NOT safe in general to do this!
CDataStream AEAD::decrypt_and_verify(const GroupElement& prekey, const std::string additional_data, AEADEncryptedData& data) {
// Derive the key and commitment
std::vector<unsigned char> key = SparkUtils::kdf_aead(prekey);
Expand Down

0 comments on commit bfa4851

Please sign in to comment.