diff --git a/crypto/crypto.go b/crypto/crypto.go index 25f317545..035d304a8 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -71,7 +71,7 @@ var poly1305KeyMask = [16]byte{ } // key is a [32]byte, in the form k||r -func poly1305_sign(msg []byte, nonce []byte, key *SigningKey) []byte { +func poly1305Sign(msg []byte, nonce []byte, key *SigningKey) []byte { // prepare key for low-level poly1305.Sum(): r||n var k [32]byte @@ -113,7 +113,7 @@ func macKeyFromSlice(mk *SigningKey, data []byte) { } // key: k||r -func poly1305_verify(msg []byte, nonce []byte, key *SigningKey, mac []byte) bool { +func poly1305Verify(msg []byte, nonce []byte, key *SigningKey, mac []byte) bool { // prepare key for low-level poly1305.Sum(): r||n var k [32]byte @@ -228,7 +228,7 @@ func Encrypt(ks *Key, ciphertext, plaintext []byte) ([]byte, error) { copy(ciphertext, iv[:]) ciphertext = ciphertext[:ivSize+len(plaintext)] - mac := poly1305_sign(ciphertext[ivSize:], ciphertext[:ivSize], &ks.Sign) + mac := poly1305Sign(ciphertext[ivSize:], ciphertext[:ivSize], &ks.Sign) ciphertext = append(ciphertext, mac...) return ciphertext, nil @@ -252,7 +252,7 @@ func Decrypt(ks *Key, plaintext, ciphertext []byte) ([]byte, error) { ciphertext, mac := ciphertext[:l], ciphertext[l:] // verify mac - if !poly1305_verify(ciphertext[ivSize:], ciphertext[:ivSize], &ks.Sign, mac) { + if !poly1305Verify(ciphertext[ivSize:], ciphertext[:ivSize], &ks.Sign, mac) { return nil, ErrUnauthenticated } diff --git a/crypto/crypto_int_test.go b/crypto/crypto_int_test.go index c7b06e418..881dff649 100644 --- a/crypto/crypto_int_test.go +++ b/crypto/crypto_int_test.go @@ -48,13 +48,13 @@ func TestPoly1305(t *testing.T) { key := &SigningKey{} copy(key.K[:], test.k) copy(key.R[:], test.r) - mac := poly1305_sign(test.msg, test.nonce, key) + mac := poly1305Sign(test.msg, test.nonce, key) if !bytes.Equal(mac, test.mac) { t.Fatalf("wrong mac calculated, want: %02x, got: %02x", test.mac, mac) } - if !poly1305_verify(test.msg, test.nonce, key, test.mac) { + if !poly1305Verify(test.msg, test.nonce, key, test.mac) { t.Fatalf("mac does not verify: mac: %02x", test.mac) } } diff --git a/crypto/writer.go b/crypto/writer.go index 856fb5fff..5ac51ee8d 100644 --- a/crypto/writer.go +++ b/crypto/writer.go @@ -22,7 +22,7 @@ type encryptWriter struct { func (e *encryptWriter) Close() error { // write mac - mac := poly1305_sign(e.data.Bytes()[ivSize:], e.data.Bytes()[:ivSize], &e.key.Sign) + mac := poly1305Sign(e.data.Bytes()[ivSize:], e.data.Bytes()[:ivSize], &e.key.Sign) _, err := e.origWr.Write(mac) if err != nil { return err