Revert "cleanup"

This reverts commit 08ee2ab35f.
This commit is contained in:
Wade Simmons
2026-04-27 16:22:09 -04:00
parent 08ee2ab35f
commit 243cf4a7c5
2 changed files with 16 additions and 0 deletions

View File

@@ -23,6 +23,11 @@ func NewNebulaCipherState(s *noise.CipherState) *NebulaCipherState {
return &NebulaCipherState{c: x.(cipher.AEAD)} return &NebulaCipherState{c: x.(cipher.AEAD)}
} }
type cipherAEADDanger interface {
EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error)
DecryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error)
}
// EncryptDanger encrypts and authenticates a given payload. // EncryptDanger encrypts and authenticates a given payload.
// //
// out is a destination slice to hold the output of the EncryptDanger operation. // out is a destination slice to hold the output of the EncryptDanger operation.

View File

@@ -65,3 +65,14 @@ func (c aeadCipher) Encrypt(out []byte, n uint64, ad, plaintext []byte) []byte {
func (c aeadCipher) Decrypt(out []byte, n uint64, ad, ciphertext []byte) ([]byte, error) { func (c aeadCipher) Decrypt(out []byte, n uint64, ad, ciphertext []byte) ([]byte, error) {
return c.Open(out, c.nonce(n), ciphertext, ad) return c.Open(out, c.nonce(n), ciphertext, ad)
} }
func (c aeadCipher) EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error) {
binary.BigEndian.PutUint64(nb[4:], n)
out = c.Seal(out, nb[4:], plaintext, ad)
return out, nil
}
func (c aeadCipher) DecryptDanger(out, ad, ciphertext []byte, n uint64, nb []byte) ([]byte, error) {
binary.BigEndian.PutUint64(nb[4:], n)
return c.Open(out, nb[4:], ciphertext, ad)
}