From f63da97e27f3776d79310f8ce0f4e9d610ff095e Mon Sep 17 00:00:00 2001 From: Jonathan Rudenberg Date: Tue, 12 Jul 2016 22:56:22 -0400 Subject: [PATCH] Hide cipher functions from docs Signed-off-by: Jonathan Rudenberg --- cipher_suite.go | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/cipher_suite.go b/cipher_suite.go index 76deea5..d07a440 100644 --- a/cipher_suite.go +++ b/cipher_suite.go @@ -136,41 +136,39 @@ func (c cipherFn) Cipher(k [32]byte) Cipher { return c.fn(k) } func (c cipherFn) CipherName() string { return c.name } // CipherAESGCM is the AES256-GCM AEAD cipher. -var CipherAESGCM CipherFunc = cipherFn{ - func(k [32]byte) Cipher { - c, err := aes.NewCipher(k[:]) - if err != nil { - panic(err) - } - gcm, err := cipher.NewGCM(c) - if err != nil { - panic(err) - } - return aeadCipher{ - gcm, - func(n uint64) []byte { - var nonce [12]byte - binary.BigEndian.PutUint64(nonce[4:], n) - return nonce[:] - }, - } - }, - "AESGCM", +var CipherAESGCM CipherFunc = cipherFn{cipherAESGCM, "AESGCM"} + +func cipherAESGCM(k [32]byte) Cipher { + c, err := aes.NewCipher(k[:]) + if err != nil { + panic(err) + } + gcm, err := cipher.NewGCM(c) + if err != nil { + panic(err) + } + return aeadCipher{ + gcm, + func(n uint64) []byte { + var nonce [12]byte + binary.BigEndian.PutUint64(nonce[4:], n) + return nonce[:] + }, + } } // CipherChaChaPoly is the ChaCha20-Poly1305 AEAD cipher construction. -var CipherChaChaPoly CipherFunc = cipherFn{ - func(k [32]byte) Cipher { - return aeadCipher{ - chap.NewCipher(&k), - func(n uint64) []byte { - var nonce [12]byte - binary.LittleEndian.PutUint64(nonce[4:], n) - return nonce[:] - }, - } - }, - "ChaChaPoly", +var CipherChaChaPoly CipherFunc = cipherFn{cipherChaChaPoly, "ChaChaPoly"} + +func cipherChaChaPoly(k [32]byte) Cipher { + return aeadCipher{ + chap.NewCipher(&k), + func(n uint64) []byte { + var nonce [12]byte + binary.LittleEndian.PutUint64(nonce[4:], n) + return nonce[:] + }, + } } type aeadCipher struct {