enc

package
v0.0.0-...-7757972 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2016 License: GPL-3.0 Imports: 11 Imported by: 1

README

go-enc

A block/stream encryption library for Golang, the original code base comes from kcp-go. I refactor it to a standalone library, which is more reuseable.

Documentation

Index

Constants

View Source
const (
	NONE      = Cipher("None")
	SALSA20   = Cipher("salsa20")
	AES256CFB = Cipher("aes256cfb")
	AES128CFB = Cipher("aes128cfb")
	SALT      = "i'm salt"
)
View Source
const (
	EnclessEnlargeSize = aont.AontHashSize + aont.AontKeySize*cnw.EnlargeFactor
)

Variables

View Source
var (
	Rand io.Reader = rand.Reader
)

Functions

func EnclessDecode

func EnclessDecode(authKey *[32]byte, nonce, in []byte) ([]byte, error)

Decode EnclessEncode-ed data.

func EnclessEncode

func EnclessEncode(authKey *[32]byte, nonce, in []byte) ([]byte, error)

Confidentiality preserving (but encryptionless) encoding.

It uses Chaffing-and-Winnowing technology (it is neither encryption nor steganography) over All-Or-Nothing-Transformed data. nonce is 64-bit nonce. Output data will be EnclessEnlargeSize larger. It also consumes 64-bits of entropy.

func GetKey

func GetKey(k string, kenLen int) []byte

func SliceZero

func SliceZero(data []byte)

Zero each byte.

Types

type AESBlockCrypt

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

AESBlockCrypt implements BlockCrypt

func (*AESBlockCrypt) Decrypt

func (c *AESBlockCrypt) Decrypt(dst, src []byte)

Decrypt implements Decrypt interface

func (*AESBlockCrypt) Encrypt

func (c *AESBlockCrypt) Encrypt(dst, src []byte)

Encrypt implements Encrypt interface

type BlockConfig

type BlockConfig struct {
	Cipher   Cipher
	Password string
}

type BlockCrypt

type BlockCrypt interface {
	// Encrypt encrypts the whole block in src into dst.
	// Dst and src may point at the same memory.
	Encrypt(dst, src []byte)

	// Decrypt decrypts the whole block in src into dst.
	// Dst and src may point at the same memory.
	Decrypt(dst, src []byte)
}

BlockCrypt defines encryption/decryption methods for a given byte slice

func NewAESBlockCrypt

func NewAESBlockCrypt(key []byte) (BlockCrypt, error)

NewAESBlockCrypt initates BlockCrypt by the given key

func NewBlock

func NewBlock(config *BlockConfig) (BlockCrypt, error)

func NewNoneBlockCrypt

func NewNoneBlockCrypt(key []byte) (BlockCrypt, error)

NewNoneBlockCrypt initate by the given key

func NewSalsa20BlockCrypt

func NewSalsa20BlockCrypt(key []byte) (BlockCrypt, error)

NewSalsa20BlockCrypt initates BlockCrypt by the given key

type Cipher

type Cipher string

type NoneBlockCrypt

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

NoneBlockCrypt simple returns the plaintext

func (*NoneBlockCrypt) Decrypt

func (c *NoneBlockCrypt) Decrypt(dst, src []byte)

Decrypt implements Decrypt interface

func (*NoneBlockCrypt) Encrypt

func (c *NoneBlockCrypt) Encrypt(dst, src []byte)

Encrypt implements Encrypt interface

type Salsa20BlockCrypt

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

Salsa20BlockCrypt implements BlockCrypt

func (*Salsa20BlockCrypt) Decrypt

func (c *Salsa20BlockCrypt) Decrypt(dst, src []byte)

Decrypt implements Decrypt interface

func (*Salsa20BlockCrypt) Encrypt

func (c *Salsa20BlockCrypt) Encrypt(dst, src []byte)

Encrypt implements Encrypt interface

Directories

Path Synopsis
All-Or-Nothing-Transform, based on OAEP.
All-Or-Nothing-Transform, based on OAEP.
Chaffing-and-Winnowing.
Chaffing-and-Winnowing.

Jump to

Keyboard shortcuts

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