Documentation
¶
Overview ¶
Package bc is a library for operating a password protected AES-GCM-256 encryption cipher for encrypting and decrypting blocks of data
Index ¶
- type BlockCrypt
- func (r *BlockCrypt) Arm() *BlockCrypt
- func (r *BlockCrypt) CopyCipher(password *buf.Secure, BC *BlockCrypt) *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) LoadCiphertext(ciphertext, password *buf.Secure, IV *buf.Byte, iterations int64) *BlockCrypt
- func (r *BlockCrypt) LoadCrypt(crypt *[]byte, iv *[]byte, iterations int64) *BlockCrypt
- func (r *BlockCrypt) Lock() *BlockCrypt
- func (r *BlockCrypt) OK() bool
- func (r *BlockCrypt) SetStatus(s string) core.Status
- func (r *BlockCrypt) SetStatusIf(err error) core.Status
- func (r *BlockCrypt) Unlock(pass *buf.Secure) *BlockCrypt
- func (r *BlockCrypt) UnsetStatus() core.Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockCrypt ¶
type BlockCrypt struct { Idx *[]byte Crypt *buf.Byte Password *buf.Secure Ciphertext *buf.Secure IV *buf.Byte Iterations int64 GCM *cipher.AEAD Unlocked, Armed bool core.State }
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) CopyCipher ¶
func (r *BlockCrypt) CopyCipher(password *buf.Secure, BC *BlockCrypt) *BlockCrypt
CopyCipher creates a new blockcrypt based on an old one with a new password
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) LoadCiphertext ¶
func (r *BlockCrypt) LoadCiphertext(ciphertext, password *buf.Secure, IV *buf.Byte, iterations int64) *BlockCrypt
LoadCiphertext takes a password and a ciphertext and loads them into a BlockCrypt
func (*BlockCrypt) LoadCrypt ¶
func (r *BlockCrypt) LoadCrypt(crypt *[]byte, iv *[]byte, iterations int64) *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) core.Status
SetStatus sets the status of the crypt
func (*BlockCrypt) SetStatusIf ¶
func (r *BlockCrypt) SetStatusIf(err error) core.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() core.Status
UnsetStatus clears the error state