Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a warning about AEAD use #1382

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading