corecrypter

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2017 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// AES128KeySize - Key size (bytes) for AES128
	AES128KeySize = 16

	// AES192KeySize - Key size (bytes) for AES192
	AES192KeySize = 24

	// AES256KeySize - Key size (bytes) for AES256
	AES256KeySize = 32
)
View Source
const (
	// DES - Crypt type: software DES
	DES = 1 + iota
	// AES128 - Crypt type: software AES128
	AES128
	// AES192 - Crypt type: software AES192
	AES192
	// AES256 - Crypt type: software AES256
	AES256
)
View Source
const (
	// DESKeySize - Key size (bytes) for DES
	DESKeySize = 8
)

Variables

This section is empty.

Functions

func RandBytes

func RandBytes(n int) []byte

RandBytes gets "n" random bytes from /dev/urandom or panics

func RandUint64

func RandUint64() uint64

RandUint64 returns a secure random uint64

func RandomKey

func RandomKey(mode int) ([]byte, error)

RandomKey generate a random key

Types

type AesCrypter

type AesCrypter struct {
	// contains filtered or unexported fields
}

AesCrypter implement CoreCrypter interface using AES-128/192/256 depending on the given key length

func NewAesCrypter

func NewAesCrypter(key []byte) *AesCrypter

NewAesCrypter create a new AesCrypter

func (*AesCrypter) Decrypt

func (ac *AesCrypter) Decrypt(dest, src []byte) error

Decrypt decrypt cipher

func (*AesCrypter) Encrypt

func (ac *AesCrypter) Encrypt(dest, src []byte) error

Encrypt encrypt plain It's important to remember that ciphertexts must be authenticated (i.e. by using crypto/hmdc) as well as being encrypted in order to be secure. authentication will be done outside core crypter, (in content encrypter) to include file ID and block No.

func (*AesCrypter) EncryptWithIV

func (ac *AesCrypter) EncryptWithIV(dest, src []byte, iv []byte)

EncryptWithIV encrypt plain using given IV

func (*AesCrypter) LenAfterDecrypted

func (ac *AesCrypter) LenAfterDecrypted(cipherLen int) int

LenAfterDecrypted decrypted info length given cipher with specific length

func (*AesCrypter) LenAfterEncrypted

func (ac *AesCrypter) LenAfterEncrypted(plainLen int) int

LenAfterEncrypted encrypted info length given plain info with specific length

type CoreCrypter

type CoreCrypter interface {
	LenAfterEncrypted(plainLen int) int
	LenAfterDecrypted(cipherLen int) int
	// Encrypt encrypt src to dest
	Encrypt(dest, src []byte) error
	// Decrypt decrypt src to dest
	Decrypt(dest, src []byte) error
}

CoreCrypter defines interface for core crypt module

func NewCoreCrypter

func NewCoreCrypter(mode int, key []byte) CoreCrypter

NewCoreCrypter return a new CoreCrypter

type DesCrypter

type DesCrypter struct {
	// contains filtered or unexported fields
}

DesCrypter implement CoreCrypter interfdce

func NewDesCrypter

func NewDesCrypter(key []byte) *DesCrypter

NewDesCrypter create a new DesCrypter

func (*DesCrypter) Decrypt

func (dc *DesCrypter) Decrypt(dest, src []byte) error

Decrypt decrypt cipher

func (*DesCrypter) Encrypt

func (dc *DesCrypter) Encrypt(dest, src []byte) error

Encrypt encrypt plain It's important to remember that ciphertexts must be authenticated (i.e. by using crypto/hmdc) as well as being encrypted in order to be secure. authentication will be done outside core crypter, (in content encrypter) to include file ID and block No.

func (*DesCrypter) EncryptWithIV

func (dc *DesCrypter) EncryptWithIV(dest, src []byte, iv []byte)

EncryptWithIV encrypt plain using given IV

func (*DesCrypter) LenAfterDecrypted

func (dc *DesCrypter) LenAfterDecrypted(cipherLen int) int

LenAfterDecrypted decrypted info length given cipher with specific length

func (*DesCrypter) LenAfterEncrypted

func (dc *DesCrypter) LenAfterEncrypted(plainLen int) int

LenAfterEncrypted encrypted info length given plain info with specific length

Jump to

Keyboard shortcuts

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