Documentation ¶
Overview ¶
Package gcm supports gcm encryption - gcm is authenticated by default
Index ¶
- Constants
- func Decrypt(key, ciphertext []byte, nonceSize int) ([]byte, error)
- func DecryptString(key, ciphertext string, nonceSize int) (string, error)
- func DecryptStringWithID(message string, k KeyRetriever, nonceSize int) (string, error)
- func DecryptWithID(message []byte, k KeyRetriever, nonceSize int) ([]byte, error)
- func Encrypt(key, plaintext []byte, nonceSize int) ([]byte, error)
- func EncryptString(key, plaintext string, nonceSize int) (string, error)
- func EncryptStringWithID(key, message string, sender uint32, nonceSize int) (string, error)
- func EncryptWithID(key, message []byte, sender uint32, nonceSize int) ([]byte, error)
- type Cipher
- func (c *Cipher) Decrypt(key, ciphertext []byte) ([]byte, error)
- func (c *Cipher) DecryptWithID(message []byte, k KeyRetriever) ([]byte, error)
- func (c *Cipher) Encrypt(key, plaintext []byte) ([]byte, error)
- func (c *Cipher) EncryptWithID(key, plaintext []byte, sender uint32) ([]byte, error)
- func (c *Cipher) KeySize() int
- type GCMHelper
- type KeyRetriever
Constants ¶
const KeySize = generate.KeySize
KeySize // generic KeySize
const NonceSize = 12 // https://tools.ietf.org/html/rfc5084
NonceSize // generic NonceSize from RFC5084
Variables ¶
This section is empty.
Functions ¶
func DecryptString ¶
DecryptString is a convenience function for working with strings
func DecryptStringWithID ¶
func DecryptStringWithID(message string, k KeyRetriever, nonceSize int) (string, error)
DecryptStringWithID is a helper function to work with strings instead of bytes
func DecryptWithID ¶
func DecryptWithID(message []byte, k KeyRetriever, nonceSize int) ([]byte, error)
DecryptWithID takes an encrypted message and a KeyForID function (to get a key from a cache or a database perhaps) It checks the first 4 bytes for prepended header data, in this case, a sender ID
func EncryptString ¶
EncryptString is a convenience function for working with strings
func EncryptStringWithID ¶
EncryptStringWithID is a helper function to work with strings instead of bytes
Types ¶
type Cipher ¶
type Cipher struct {
NonceSize int
}
Cipher to implement the BlockCipher interface
func (*Cipher) DecryptWithID ¶
func (c *Cipher) DecryptWithID(message []byte, k KeyRetriever) ([]byte, error)
DecryptWithID calls the package DecryptWithID and passes c.NonceSize
func (*Cipher) EncryptWithID ¶
EncryptWithID calls the package EncryptWithID and passes c.NonceSize
type GCMHelper ¶
GCMHelper is designed to make it easy to call EncryptWithID and DecryptWithID by assigning the KeyForIDFunc it implements KeyRetriever and provides convenience functions It also serves as an example for how to use KeyRetriever
func NewGCMHelper ¶
NewGCMHelper returns a new helper
type KeyRetriever ¶
KeyRetriever represents a type that should be used in order to retrieve a key from a datastore