mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
fix mismerge
This commit is contained in:
10
noise.go
10
noise.go
@@ -38,6 +38,10 @@ type cipherAEADDanger interface {
|
|||||||
// be re-used by callers to minimize garbage collection.
|
// be re-used by callers to minimize garbage collection.
|
||||||
func (s *NebulaCipherState) EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error) {
|
func (s *NebulaCipherState) EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error) {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
|
switch ce := s.c.(type) {
|
||||||
|
case cipherAEADDanger:
|
||||||
|
return ce.EncryptDanger(out, ad, plaintext, n, nb)
|
||||||
|
default:
|
||||||
// TODO: Is this okay now that we have made messageCounter atomic?
|
// TODO: Is this okay now that we have made messageCounter atomic?
|
||||||
// Alternative may be to split the counter space into ranges
|
// Alternative may be to split the counter space into ranges
|
||||||
//if n <= s.n {
|
//if n <= s.n {
|
||||||
@@ -52,6 +56,7 @@ func (s *NebulaCipherState) EncryptDanger(out, ad, plaintext []byte, n uint64, n
|
|||||||
out = s.c.Seal(out, nb, plaintext, ad)
|
out = s.c.Seal(out, nb, plaintext, ad)
|
||||||
//l.Debugf("Encryption: outlen: %d, nonce: %d, ad: %s, plainlen %d", len(out), n, ad, len(plaintext))
|
//l.Debugf("Encryption: outlen: %d, nonce: %d, ad: %s, plainlen %d", len(out), n, ad, len(plaintext))
|
||||||
return out, nil
|
return out, nil
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, errors.New("no cipher state available to encrypt")
|
return nil, errors.New("no cipher state available to encrypt")
|
||||||
}
|
}
|
||||||
@@ -59,12 +64,17 @@ func (s *NebulaCipherState) EncryptDanger(out, ad, plaintext []byte, n uint64, n
|
|||||||
|
|
||||||
func (s *NebulaCipherState) DecryptDanger(out, ad, ciphertext []byte, n uint64, nb []byte) ([]byte, error) {
|
func (s *NebulaCipherState) DecryptDanger(out, ad, ciphertext []byte, n uint64, nb []byte) ([]byte, error) {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
|
switch ce := s.c.(type) {
|
||||||
|
case cipherAEADDanger:
|
||||||
|
return ce.DecryptDanger(out, ad, ciphertext, n, nb)
|
||||||
|
default:
|
||||||
nb[0] = 0
|
nb[0] = 0
|
||||||
nb[1] = 0
|
nb[1] = 0
|
||||||
nb[2] = 0
|
nb[2] = 0
|
||||||
nb[3] = 0
|
nb[3] = 0
|
||||||
noiseEndianness.PutUint64(nb[4:], n)
|
noiseEndianness.PutUint64(nb[4:], n)
|
||||||
return s.c.Open(out, nb, ciphertext, ad)
|
return s.c.Open(out, nb, ciphertext, ad)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user