blockcrypt

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2018 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

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 New

func New() *BlockCrypt

New creates a new, empty BlockCrypt

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) OK

func (r *BlockCrypt) OK() bool

OK returns true if the status text is empty

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL