crypto

package
v0.0.0-...-934465a Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package crypto provides interface for cipher method providers. Clients can using those cipher methods via io.ReadWriter interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStream

func NewStream(cipherName string, keyGen KeyGenerator, rw io.ReadWriter) (io.ReadWriter, error)

NewStream wraps rw through stream cipher provided by cipherName. On Read, first few bytes will be interpreted as iv used for decryption. On Write, plaintext iv will be prepended in first call for read end decryption.

func Register

func Register(name string, cipher Cipher)

Register makes a cipher implementation available by the provided name. If Register is called twice with the same name or if cipher is nil, it panics.

Types

type Cipher

type Cipher interface {
	KeyLen() int
	IVLen() int
	NewEncrypter(key, iv []byte) (cipher.Stream, error)
	NewDecrypter(key, iv []byte) (cipher.Stream, error)
}

Cipher is the interface that implemented by cipher provider.

type DuplicatedCipherMethodError

type DuplicatedCipherMethodError string

func (DuplicatedCipherMethodError) Error

func (name DuplicatedCipherMethodError) Error() string

type KeyGenerator

type KeyGenerator func(keyLen int) []byte

KeyGenerator is cipher key generator. For given generator, it must generate the same key for the same input.

type UnsupportedCipherMethodError

type UnsupportedCipherMethodError string

func (UnsupportedCipherMethodError) Error

func (name UnsupportedCipherMethodError) Error() string

Directories

Path Synopsis
Package aes implements cipher methods based on AES encryption.
Package aes implements cipher methods based on AES encryption.
Package rc4 implements cipher methods based on RC4 encryption.
Package rc4 implements cipher methods based on RC4 encryption.

Jump to

Keyboard shortcuts

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