Skip to content

Improves/security#132

Merged
cedricfung merged 9 commits into
mainfrom
improves/security
May 25, 2026
Merged

Improves/security#132
cedricfung merged 9 commits into
mainfrom
improves/security

Conversation

@hundredark

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread common/aes.go Outdated
}
nonce := b[:aead.NonceSize()]
cipher := aead.Seal(nil, nonce, b[aead.NonceSize():], nil)
// The nonce must be unique for all time, for a given key

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our code relies on these deterministic nonce for now?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. with the old code, the nonce was the first 12 bytes of plaintext, but decrypt just used it for GCM authentication and reconstructed the plaintext by prepending it back. And it's only used for decrypt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the old already encrypted data in the network.

Comment thread common/aes.go Outdated
panic(err)
}
return append(nonce, d...)
return d

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this break the code if the decrypted data changes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. the original plaintext would be decrypted and returned by aead.Open(), the changes of AESEncrypt and AESDecrypt only change the process of encrypt and decrypt. The both functions are used in many test codes.

@cedricfung cedricfung merged commit 754f635 into main May 25, 2026
6 checks passed
@cedricfung cedricfung deleted the improves/security branch May 25, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants