fte

package
v0.0.0-...-5d0d25f Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IV_LENGTH          = 7
	MSG_COUNTER_LENGTH = 8
	CTXT_EXPANSION     = 1 + IV_LENGTH + MSG_COUNTER_LENGTH + aes.BlockSize
)
View Source
const (
	COVERTEXT_HEADER_LEN_CIPHERTTEXT = 16
)

Variables

View Source
var (
	ErrShortCiphertext        = errors.New("fte: short ciphertext")
	ErrInvalidMessageLength   = errors.New("fte: invalid message length")
	ErrHMACVerificationFailed = errors.New("fte: hmac verification failed")
)
View Source
var (
	K1 = []byte("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")
	K2 = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
)
View Source
var (
	ErrInsufficientCapacity = errors.New("fte: insufficient capacity")
)
View Source
var (
	ErrLanguageIsEmptySet = errors.New("fte: language is empty set")
)
View Source
var Verbose bool

Functions

func Log2

func Log2(v *big.Int) int

Log2 returns floor(log2(v)).

Types

type Cache

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

Cache represents a cache of Ciphers & DFAs.

func NewCache

func NewCache() *Cache

NewCache returns a new instance of Cache.

func (*Cache) Cipher

func (c *Cache) Cipher(regex string, n int) (_ *Cipher, err error)

Cipher returns a instance of Cipher associated with regex & n. Creates a new cipher if one doesn't already exist.

func (*Cache) Close

func (c *Cache) Close() (err error)

Close close and removes all ciphers & dfas.

func (*Cache) DFA

func (c *Cache) DFA(regex string, n int) (_ *DFA, err error)

DFA returns a instance of DFA associated with regex & n. Creates a new DFA if one doesn't already exist.

type Cipher

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

func NewCipher

func NewCipher(regex string, n int) (_ *Cipher, err error)

NewCipher returns a new instance of Cipher.

func (*Cipher) Capacity

func (c *Cipher) Capacity() int

Capacity returns the capacity left in the encoder.

func (*Cipher) Close

func (c *Cipher) Close() error

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(ciphertext []byte) (plaintext, remainder []byte, err error)

Decrypt decrypts ciphertext into plaintext. Returns ErrShortCiphertext if the ciphertext is too short to be decrypted.

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(plaintext []byte) (ciphertext []byte, err error)

Encrypt encrypts plaintext into ciphertext.

type DFA

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

func NewDFA

func NewDFA(regex string, n int) (*DFA, error)

func (*DFA) Capacity

func (dfa *DFA) Capacity() int

Capacity returns the capacity of the encoder.

func (*DFA) Close

func (dfa *DFA) Close() error

func (*DFA) N

func (dfa *DFA) N() int

N returns the n passed into the DFA.

func (*DFA) NumWordsInLanguage

func (dfa *DFA) NumWordsInLanguage(min, max int) (*big.Int, error)

func (*DFA) NumWordsInSlice

func (dfa *DFA) NumWordsInSlice(n int) (*big.Int, error)

func (*DFA) Rank

func (dfa *DFA) Rank(s string) (*big.Int, error)

Rank maps s into an integer ranking.

func (*DFA) Regex

func (dfa *DFA) Regex() string

Regex returns the regex passed into the DFA.

func (*DFA) Unrank

func (dfa *DFA) Unrank(rank *big.Int) (string, error)

Unrank reverses the map from an integer to a string.

type Decrypter

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

func NewDecrypter

func NewDecrypter() (*Decrypter, error)

func (*Decrypter) CiphertextLen

func (dec *Decrypter) CiphertextLen(ciphertext []byte) int

func (*Decrypter) Decrypt

func (dec *Decrypter) Decrypt(ciphertext []byte) ([]byte, error)

type Encrypter

type Encrypter struct {
	IV []byte
	// contains filtered or unexported fields
}

func NewEncrypter

func NewEncrypter() (*Encrypter, error)

func (*Encrypter) Encrypt

func (enc *Encrypter) Encrypt(plaintext []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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