crypto

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize int = 8 * 1024

BufferSize defines the size of the stream buffer in bytes.

View Source
const IvSize int = 12

IvSize defines the length of the iv in bytes.

View Source
const KeyPasses int = 872791

KeyPasses defines the number of rounds for PBKDF2.

View Source
const KeySize int = 32

KeySize defines the length of the key in bytes.

View Source
const SaltSize int = 32

SaltSize defines the length of the salt in bytes.

Variables

This section is empty.

Functions

func ClearMem

func ClearMem(data *[]byte) bool

ClearMem overwrites the memory of the byte array passed as data with random data.

It returns true if the overwrite was successfull, false if not.

func DecryptFile

func DecryptFile(args *DecryptArgs) error

DecryptFile decrypts a file using the cipher and writes it to the output defined in args.

func EncryptFile

func EncryptFile(args *EncryptArgs) error

EncryptFile encrypts a file using the cipher and writes it to the output defined in args.

func GenKey

func GenKey(pass *[]byte, salt []byte) *[]byte

GenKey generates a secure key based on a password and salt using the PBKDF2 function with SHA512. The key length is fixed and defined by KeySize.

It returns a pointer to a byte array containing the key.

func RandomIv

func RandomIv() (bool, []byte)

RandomIv generates a secure, random iv with a fixed length defined by IvSize.

It returns true or false on success or failure and the iv as byte array.

func RandomSalt

func RandomSalt() (bool, []byte)

RandomSalt generates a secure, random salt with a fixed length defined by SaltSize.

It returns true or false on success or failure and the salt as byte array.

Types

type DecryptArgs

type DecryptArgs struct {
	Input   os.File
	Output  string
	Info    os.FileInfo
	Aes     cipher.AEAD
	Verbose bool
}

DecryptArgs contains the arguments for the DecryptFile function.

type EncryptArgs

type EncryptArgs struct {
	Input   os.File
	Output  os.File
	Aes     cipher.AEAD
	Salt    []byte
	Verbose bool
}

EncryptArgs contains the arguments for the EncryptFile function.

Jump to

Keyboard shortcuts

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