wotoCrypto

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKey         = errors.New("invalid key")
	ErrInvalidCryptoLayer = errors.New("invalid crypto layer")
)

Functions

func BlockAlgorithmExists

func BlockAlgorithmExists(algorithmId uint8) bool

func DecryptAES

func DecryptAES(key, data []byte) []byte

func DecryptData

func DecryptData(key, data []byte) []byte

func EncryptAES

func EncryptAES(key, data []byte) []byte

func EncryptData

func EncryptData(key, data []byte) []byte

Types

type AlgorithmSupporter

type AlgorithmSupporter interface {
	SetAlgorithm(algorithm WotoAlgorithm) bool
	HasEqualAlgorithm(algorithm WotoAlgorithm) bool
	GetAlgorithm() WotoAlgorithm
	GetHashCount() int
}

type CryptoLayer

type CryptoLayer struct {
	Kind CryptoLayerKind `json:"kind"`
	Hash string          `json:"hash"`
	// contains filtered or unexported fields
}

func (*CryptoLayer) Equal

func (l *CryptoLayer) Equal(layer *CryptoLayer) bool

func (*CryptoLayer) GetLayerLength

func (l *CryptoLayer) GetLayerLength() *LayerLengthContainer

func (*CryptoLayer) IsValid

func (l *CryptoLayer) IsValid() bool

func (*CryptoLayer) ToBytes

func (l *CryptoLayer) ToBytes() ([]byte, error)

type CryptoLayerKind

type CryptoLayerKind uint8
const (
	CryptoLayerKindO27 CryptoLayerKind = 27 << iota
	CryptoLayerKindO54
	CryptoLayerKindO108
	CryptoLayerKindO216
)

type KeyCollection added in v1.0.3

type KeyCollection interface {
	ws.Validator

	ContinueLifeCycle()
	Sync()
}

type KeyLayerCollection

type KeyLayerCollection []CryptoLayer

func (KeyLayerCollection) Contains

func (c KeyLayerCollection) Contains(layer *CryptoLayer) bool

func (KeyLayerCollection) ContainsKind

func (c KeyLayerCollection) ContainsKind(kind CryptoLayerKind) bool

func (KeyLayerCollection) GetKeyLength

func (c KeyLayerCollection) GetKeyLength() int

func (KeyLayerCollection) GetLayerByIndex

func (c KeyLayerCollection) GetLayerByIndex(index int) *CryptoLayer

func (KeyLayerCollection) GetLayerLengthByKind

func (c KeyLayerCollection) GetLayerLengthByKind(kind CryptoLayerKind) *LayerLengthContainer

func (KeyLayerCollection) IsValid

func (c KeyLayerCollection) IsValid() bool

type KeysContainer added in v1.0.3

type KeysContainer interface {
	SetAsKeys(value KeyCollection)
}

type LayerBlock

type LayerBlock interface {
	ContainsLayerKind(kind CryptoLayerKind) bool
	ContainsLayer(layer *CryptoLayer) bool
	AppendLayer(layer *CryptoLayer) bool
	RemoveLayer(layer *CryptoLayer) bool
	RemoveLayers(layers ...*CryptoLayer)
	GetLayerLengthByKind(kind CryptoLayerKind) *LayerLengthContainer
	GetLayerLengthByIndex(index int) *LayerLengthContainer
	GetKeyLayersCount() int
}

type LayerLengthContainer

type LayerLengthContainer struct {
	Length    WotoLayerLength
	LayerKind CryptoLayerKind
}

func (*LayerLengthContainer) IsValid

func (c *LayerLengthContainer) IsValid() bool

type PasswordContainer256 added in v1.0.5

type PasswordContainer256 = passContainer.PasswordContainer256

type PasswordContainer512 added in v1.0.5

type PasswordContainer512 = passContainer.PasswordContainer256

type WotoAlgorithm

type WotoAlgorithm uint16
const (
	// See https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf
	WotoAlgorithmM250 WotoAlgorithm = 2 << ^uint8(250)
	WotoAlgorithmM251 WotoAlgorithm = 3 << ^uint8(251)
	WotoAlgorithmM252 WotoAlgorithm = 5 << ^uint8(252)
	WotoAlgorithmM253 WotoAlgorithm = 8 << ^uint8(253)
)

type WotoKey

type WotoKey interface {
	fmt.Stringer
	ws.Validator
	ws.SignatureContainer
	ws.Serializer
	AlgorithmSupporter
	LayerBlock

	IsFuture() bool
	IsPast() bool
	IsPresent() bool
	IsEmpty() bool
	CanBecomeFuture() bool
	CanBecomePresent() bool
	CanBecomePast() bool
	Decrypt(data []byte) []byte
	Encrypt(data []byte) []byte
	HasEqualKind(key WotoKey) bool
	HasEqualSignature(key WotoKey) bool
	GetKeyLength() int
	GetSignatureRealLength() int
	IsRealLengthInvalid() bool

	// Deprecated: you can't convert any WotoKey to a FutureKey anymore.
	// Please use GenerateFutureKey helper function.
	ToFutureKey() WotoKey
	ToPresentKey() WotoKey
	ToPastKey() WotoKey
	Clone() WotoKey
	// contains filtered or unexported methods
}

func GenerateFutureKey

func GenerateFutureKey(pastKey WotoKey) WotoKey

GenerateFutureKey is supposed to generate a new future key by using the specified paskey's algorithm.

func GeneratePresentKey

func GeneratePresentKey(algo WotoAlgorithm) WotoKey

type WotoLayerLength

type WotoLayerLength uint32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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