Correct typos in noise.go (#205)

This commit is contained in:
Felix Yan 2020-03-30 13:23:55 -05:00 committed by GitHub
parent 1297090af3
commit 9e2ff7df57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -299,9 +299,9 @@ func Main(configPath string, configTest bool, buildVersion string) {
switch ifConfig.Cipher { switch ifConfig.Cipher {
case "aes": case "aes":
noiseEndiannes = binary.BigEndian noiseEndianness = binary.BigEndian
case "chachapoly": case "chachapoly":
noiseEndiannes = binary.LittleEndian noiseEndianness = binary.LittleEndian
default: default:
l.Fatalf("Unknown cipher: %v", ifConfig.Cipher) l.Fatalf("Unknown cipher: %v", ifConfig.Cipher)
} }

View File

@ -8,11 +8,11 @@ import (
"github.com/flynn/noise" "github.com/flynn/noise"
) )
type endiannes interface { type endianness interface {
PutUint64(b []byte, v uint64) PutUint64(b []byte, v uint64)
} }
var noiseEndiannes endiannes = binary.BigEndian var noiseEndianness endianness = binary.BigEndian
type NebulaCipherState struct { type NebulaCipherState struct {
c noise.Cipher c noise.Cipher
@ -37,7 +37,7 @@ func (s *NebulaCipherState) EncryptDanger(out, ad, plaintext []byte, n uint64, n
nb[1] = 0 nb[1] = 0
nb[2] = 0 nb[2] = 0
nb[3] = 0 nb[3] = 0
noiseEndiannes.PutUint64(nb[4:], n) noiseEndianness.PutUint64(nb[4:], n)
out = s.c.(cipher.AEAD).Seal(out, nb, plaintext, ad) out = s.c.(cipher.AEAD).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
@ -52,7 +52,7 @@ func (s *NebulaCipherState) DecryptDanger(out, ad, ciphertext []byte, n uint64,
nb[1] = 0 nb[1] = 0
nb[2] = 0 nb[2] = 0
nb[3] = 0 nb[3] = 0
noiseEndiannes.PutUint64(nb[4:], n) noiseEndianness.PutUint64(nb[4:], n)
return s.c.(cipher.AEAD).Open(out, nb, ciphertext, ad) return s.c.(cipher.AEAD).Open(out, nb, ciphertext, ad)
} else { } else {
return []byte{}, nil return []byte{}, nil