utils

package
v0.0.0-...-b5b62ee Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2009 The Go Authors. All rights reserved.

Index

Constants

View Source
const (
	STRING     = 1
	INTEGER    = 2
	BINARY     = 3
	STRUCTURED = 4

	TLC = 1 // type-length-content
	NT  = 0 // null terminated

	MAX_UINT64        uint64 = 0xFFFFFFFFFFFFFFFF
	MAX_UINT64_DIV_10 uint64 = MAX_UINT64 / 10
	MAX_UINT64_MOD_10 uint64 = MAX_UINT64 % 10
)
View Source
const (
	DUMMY = iota
	SYSTEM
	USER
)

Variables

This section is empty.

Functions

func CurrentVersion

func CurrentVersion() (uint64, uint64, uint64)

func Decrypt

func Decrypt(name string, iv []byte, key []byte, ciphertext []byte) (plaintext []byte, err error)

Note that ciphertext is overwritten

func Encrypt

func Encrypt(name string, iv []byte, key []byte, plaintext []byte) (ciphertext []byte, err error)

Note that plaintext is overwritten

func GetPadding

func GetPadding(pad string) (*padding, error)

func NewByteArray

func NewByteArray(s string) []byte

func NewCipher

func NewCipher(alg string, key []byte) (cipher.Block, error)

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block, iv []byte) cipher.BlockMode

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block, iv []byte) cipher.BlockMode

func NewLog

func NewLog(id string) *logStructure

func NewRCBCDecrypter

func NewRCBCDecrypter(b cipher.Block, iv []byte) cipher.BlockMode

func NewRCBCEncrypter

func NewRCBCEncrypter(b cipher.Block, iv []byte) cipher.BlockMode

func SetModeFuncs

func SetModeFuncs(name string, enc newModeEncFunc, dec newModeDecFunc)

func SetNewCipherFunc

func SetNewCipherFunc(name string, fun newCipherFunc)

func SetPaddingFuncs

func SetPaddingFuncs(name string, pad padFunc, remove removeFunc)

func SetStrict

func SetStrict(v bool)

func StreamDecrypt

func StreamDecrypt(name string, iv []byte, key []byte, ciphertext io.Reader, plaintext io.Writer) error

func StreamEncrypt

func StreamEncrypt(name string, iv []byte, key []byte, plaintext io.Reader, ciphertext io.Writer) error

func Version

func Version()

Types

type Debug

type Debug interface {
	Printf(format string, a ...interface{})
	PrintBuffer(buffer []byte, format string, a ...interface{})
}
var Default Debug

func NewDebug

func NewDebug(t DebugType, id string) Debug

type DebugType

type DebugType byte

type IByteStream

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

func MakeIByteStream

func MakeIByteStream(data []byte) *IByteStream

func (*IByteStream) ReadByte

func (stream *IByteStream) ReadByte() (byte, error)

type IEncoding

type IEncoding interface {
	ReadUint64() (uint64, error)
	ReadString() (string, error)
	ReadInteger() (string, error)
	ReadBig() (*big.Int, error)
	ReadBinary() (b []byte, err error)
	ReadStructured() ([]byte, error)
}

func MakeByteIEncoding

func MakeByteIEncoding(data []byte) IEncoding

func MakeTcpIEncoding

func MakeTcpIEncoding(conn *net.TCPConn) IEncoding

type INtEncoding

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

func MakeINtEncoding

func MakeINtEncoding(stream IStream) *INtEncoding

func (*INtEncoding) ReadBig

func (enc *INtEncoding) ReadBig() (*big.Int, error)

func (*INtEncoding) ReadBinary

func (enc *INtEncoding) ReadBinary() (b []byte, err error)

func (*INtEncoding) ReadByteOrEOS

func (enc *INtEncoding) ReadByteOrEOS() (int, error)

func (*INtEncoding) ReadInteger

func (enc *INtEncoding) ReadInteger() (string, error)

func (*INtEncoding) ReadString

func (enc *INtEncoding) ReadString() (string, error)

func (*INtEncoding) ReadStructured

func (enc *INtEncoding) ReadStructured() ([]byte, error)

func (*INtEncoding) ReadUint64

func (enc *INtEncoding) ReadUint64() (uint64, error)

type IStream

type IStream interface {
	ReadByte() (byte, error)
}

type ITcpStream

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

func MakeITcpStream

func MakeITcpStream(conn *net.TCPConn) *ITcpStream

func (*ITcpStream) ReadByte

func (stream *ITcpStream) ReadByte() (byte, error)

type ITlcEncoding

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

func MakeITlcEncoding

func MakeITlcEncoding(stream IStream) *ITlcEncoding

func (*ITlcEncoding) ReadBig

func (enc *ITlcEncoding) ReadBig() (*big.Int, error)

func (*ITlcEncoding) ReadBinary

func (enc *ITlcEncoding) ReadBinary() (b []byte, err error)

func (*ITlcEncoding) ReadInteger

func (enc *ITlcEncoding) ReadInteger() (string, error)

func (*ITlcEncoding) ReadString

func (enc *ITlcEncoding) ReadString() (string, error)

func (*ITlcEncoding) ReadStructured

func (enc *ITlcEncoding) ReadStructured() ([]byte, error)

func (*ITlcEncoding) ReadUint64

func (enc *ITlcEncoding) ReadUint64() (uint64, error)

type Log

type Log interface {
	Printf(format string, a ...interface{})
	PrintBuffer(buffer []byte, format string, a ...interface{})
}

type ModeParams

type ModeParams interface {
}

type OByteStream

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

func MakeOByteStream

func MakeOByteStream(size int) *OByteStream

func (*OByteStream) GetBuffer

func (stream *OByteStream) GetBuffer() ([]byte, error)

func (*OByteStream) WriteByte

func (stream *OByteStream) WriteByte(b byte) error

type OEncoding

type OEncoding interface {
	WriteUint64(x uint64) error
	WriteString(str string) error
	WriteInteger(str string) error
	WriteBig(*big.Int) error
	WriteBinary(data []byte) error
	WriteBinaryWithDelay(delay int64, data []byte) error
	WriteStructured(data []byte) error
	GetBuffer() ([]byte, error)
}

func MakeByteOEncoding

func MakeByteOEncoding(size int) OEncoding

func MakeTcpOEncoding

func MakeTcpOEncoding(conn *net.TCPConn) OEncoding

type ONtEncoding

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

func MakeONtEncoding

func MakeONtEncoding(stream OStream) *ONtEncoding

func (*ONtEncoding) GetBuffer

func (enc *ONtEncoding) GetBuffer() ([]byte, error)

func (*ONtEncoding) WriteBig

func (enc *ONtEncoding) WriteBig(x *big.Int) error

func (*ONtEncoding) WriteBinary

func (enc *ONtEncoding) WriteBinary(data []byte) error

func (*ONtEncoding) WriteBinaryWithDelay

func (enc *ONtEncoding) WriteBinaryWithDelay(delay int64, data []byte) error

func (*ONtEncoding) WriteInteger

func (enc *ONtEncoding) WriteInteger(str string) error

func (*ONtEncoding) WriteString

func (enc *ONtEncoding) WriteString(str string) error

func (*ONtEncoding) WriteStructured

func (enc *ONtEncoding) WriteStructured(data []byte) error

func (*ONtEncoding) WriteUint64

func (enc *ONtEncoding) WriteUint64(x uint64) error

type OStream

type OStream interface {
	WriteByte(b byte) error
	GetBuffer() ([]byte, error)
}

type OTcpStream

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

func MakeOTcpStream

func MakeOTcpStream(conn *net.TCPConn) *OTcpStream

func (*OTcpStream) GetBuffer

func (stream *OTcpStream) GetBuffer() ([]byte, error)

func (*OTcpStream) WriteByte

func (stream *OTcpStream) WriteByte(b byte) error

type OTlcEncoding

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

func MakeOTlcEncoding

func MakeOTlcEncoding(stream OStream) *OTlcEncoding

func (*OTlcEncoding) GetBuffer

func (enc *OTlcEncoding) GetBuffer() ([]byte, error)

func (*OTlcEncoding) WriteBig

func (enc *OTlcEncoding) WriteBig(x *big.Int) error

func (*OTlcEncoding) WriteBinary

func (enc *OTlcEncoding) WriteBinary(data []byte) error

func (*OTlcEncoding) WriteBinaryWithDelay

func (enc *OTlcEncoding) WriteBinaryWithDelay(delay int64, data []byte) error

func (*OTlcEncoding) WriteInteger

func (enc *OTlcEncoding) WriteInteger(str string) error

func (*OTlcEncoding) WriteString

func (enc *OTlcEncoding) WriteString(str string) error

func (*OTlcEncoding) WriteStructured

func (enc *OTlcEncoding) WriteStructured(data []byte) error

func (*OTlcEncoding) WriteUint64

func (enc *OTlcEncoding) WriteUint64(x uint64) error

Jump to

Keyboard shortcuts

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