Documentation ¶
Index ¶
- type BlockCrypt
- func (r *BlockCrypt) Arm() *BlockCrypt
- func (r *BlockCrypt) Decrypt(buf *[]byte) (out *[]byte)
- func (r *BlockCrypt) Disarm() *BlockCrypt
- func (r *BlockCrypt) Encrypt(buf *[]byte) (out *[]byte)
- func (r *BlockCrypt) Error() string
- func (r *BlockCrypt) Generate(p *buf.Secure) *BlockCrypt
- func (r *BlockCrypt) LoadCrypt(crypt *[]byte, iv *[]byte, iterations int) *BlockCrypt
- func (r *BlockCrypt) Lock() *BlockCrypt
- func (r *BlockCrypt) OK() bool
- func (r *BlockCrypt) SetStatus(s string) proto.Status
- func (r *BlockCrypt) SetStatusIf(err error) proto.Status
- func (r *BlockCrypt) Unlock(pass *buf.Secure) *BlockCrypt
- func (r *BlockCrypt) UnsetStatus() proto.Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockCrypt ¶
type BlockCrypt struct { Crypt *buf.Byte Password *buf.Secure Ciphertext *buf.Secure IV *buf.Byte Iterations int GCM *cipher.AEAD Unlocked, Armed bool Status string }
BlockCrypt stores the state of a GCM AES cipher for encrypting up to 4Gb of data
func (*BlockCrypt) Arm ¶
func (r *BlockCrypt) Arm() *BlockCrypt
Arm generates the correct ciphertext that allows the encrypt/decrypt functions to operate
func (*BlockCrypt) Decrypt ¶
func (r *BlockCrypt) Decrypt(buf *[]byte) (out *[]byte)
Decrypt uses the armed cipher to decrypt a buffer
func (*BlockCrypt) Disarm ¶
func (r *BlockCrypt) Disarm() *BlockCrypt
Disarm re-encrypts the ciphertext, destroys the cipher and unmarks the armed flag
func (*BlockCrypt) Encrypt ¶
func (r *BlockCrypt) Encrypt(buf *[]byte) (out *[]byte)
Encrypt uses the armed cipher to encrypt a buffer
func (*BlockCrypt) Error ¶
func (r *BlockCrypt) Error() string
Error implemennts the Error() interface
func (*BlockCrypt) Generate ¶
func (r *BlockCrypt) Generate(p *buf.Secure) *BlockCrypt
Generate creates a new crypt based on a password and a newly generated random ciphertext.
After this function the crypt is unlocked, the crypt contains the encrypted ciphertext and the ciphertext is destroyed and Arm() must be called to activate the cipher
func (*BlockCrypt) LoadCrypt ¶
func (r *BlockCrypt) LoadCrypt(crypt *[]byte, iv *[]byte, iterations int) *BlockCrypt
LoadCrypt loads a crypt, IV and iterations as from the file where the encryption is used.
The password still needs to be loaded to unlock the crypt and the crypt unlocked to arm the BlockCrypt. This function clears any existing data in the Blockcrypt.
func (*BlockCrypt) Lock ¶
func (r *BlockCrypt) Lock() *BlockCrypt
Lock clears the password and disarms the crypt
func (*BlockCrypt) SetStatus ¶
func (r *BlockCrypt) SetStatus(s string) proto.Status
SetStatus sets the status of the crypt
func (*BlockCrypt) SetStatusIf ¶
func (r *BlockCrypt) SetStatusIf(err error) proto.Status
SetStatusIf sets the status according to an error output
func (*BlockCrypt) Unlock ¶
func (r *BlockCrypt) Unlock(pass *buf.Secure) *BlockCrypt
Unlock loads the password, enabling arming of the crypt
func (*BlockCrypt) UnsetStatus ¶
func (r *BlockCrypt) UnsetStatus() proto.Status
UnsetStatus clears the error state