Documentation ¶
Overview ¶
Package crypto provides security tools
Index ¶
Constants ¶
View Source
const ( // CKeySize is the cipher key size - AES-256 CKeySize = 32 // MKeySize is the HMAC key size - HMAC-SHA-256 MKeySize = 32 // KeySize is the encryption key size KeySize = CKeySize + MKeySize // AESNonceSize is an AES nonce size AESNonceSize = aes.BlockSize // GCMNonceSize is a GCM nonce size GCMNonceSize = 12 // SenderSize is the size allocated to add the sender ID SenderSize = 4 // MACSize MAC size MACSize = 32 )
Variables ¶
View Source
var ( // ErrEncrypt occurs when the encryption process fails. The reason of failure // is concealed for security reason ErrEncrypt = errors.New("sec: encryption failed") // ErrDecrypt occurs when the decryption process fails. ErrDecrypt = errors.New("sec: decryption failed") )
Functions ¶
Types ¶
type Rotor ¶
type Rotor struct { NonceSize int // contains filtered or unexported fields }
Rotor is a encryption/decryption tool that supports key rotation
Note: Data encrypted with sec.Encrypt cannot be decrypted with Rotor
func NewRotor ¶
NewRotor creates a new Rotor with the given keys. The defaultSender will be used as the default sender ID during the encryption process
func (*Rotor) Decrypt ¶
Decrypt takes an incoming message and uses the sender ID to retrieve the appropriate key. It then attempts to recover the message using that key.
Click to show internal directories.
Click to hide internal directories.