xoodoo

package
v1.0.4008 Latest Latest
Warning

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

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

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/deatil/go-cryptobin/cipher/xoodoo/xoodoo"
)

func main() {
	newXoodoo, _ := xoodoo.NewXoodoo(xoodoo.MaxRounds, [xoodoo.StateSizeBytes]byte{})
	fmt.Printf("Starting State:%#v\n", newXoodoo.Bytes())
	newXoodoo.Permutation()
	fmt.Printf("Permuted State:%#v\n", newXoodoo.Bytes())
}
Output:

Starting State:[]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
Permuted State:[]byte{0x8d, 0xd8, 0xd5, 0x89, 0xbf, 0xfc, 0x63, 0xa9, 0x19, 0x2d, 0x23, 0x1b, 0x14, 0xa0, 0xa5, 0xff, 0x6, 0x81, 0xb1, 0x36, 0xfe, 0xc1, 0xc7, 0xaf, 0xbe, 0x7c, 0xe5, 0xae, 0xbd, 0x40, 0x75, 0xa7, 0x70, 0xe8, 0x86, 0x2e, 0xc9, 0xb7, 0xf5, 0xfe, 0xf2, 0xad, 0x4f, 0x8b, 0x62, 0x40, 0x4f, 0x5e}

Index

Examples

Constants

View Source
const (
	// MaxRounds is current ceiling on how many iterations of Xoodoo can be done in the permutation
	// function
	MaxRounds = 12
	// StateSizeBytes describes the Xoodoo object in term of the number of bytes it is made up of
	StateSizeBytes = 48
	// StateSizeWords describes the Xoodoo object in term of the number of 32-bit unsigned ints it is made up of
	StateSizeWords = 12
)

Variables

View Source
var (
	// RoundConstants is the sequence of 32-bit constants applied in each round of Xoodoo
	RoundConstants = [StateSizeWords]uint32{
		0x00000058,
		0x00000038,
		0x000003C0,
		0x000000D0,
		0x00000120,
		0x00000014,
		0x00000060,
		0x0000002C,
		0x00000380,
		0x000000F0,
		0x000001A0,
		0x00000012,
	}
)

Functions

This section is empty.

Types

type State

type State [StateSizeWords]uint32

State represents the 384-bit Xoodoo object as a collection of uint32 words

func XorState

func XorState(a, b State) State

XorState performs the exclusive-or operation on two XoodooState objects and returns the resulting XoodooState

func (*State) MarshalBinary

func (xds *State) MarshalBinary() (data []byte, err error)

MarshalBinary converts the Xoodoo state of the receiver to slice of bytes This method allows State to satisfy the encoding.BinaryMarshaler interface

func (*State) UnmarshalBinary

func (xds *State) UnmarshalBinary(data []byte) error

UnmarshalBinary converts provide byte slice to the Xoodoo state format This method allows State to satisfy the encoding.BinaryUnmarshaler interface

func (*State) XorByte

func (xds *State) XorByte(x byte, offset int) error

XorByte performs an exclusive-or between a single provide byte and byte within the underlying XoodooState based on the provided offset. The result is stored in the XoodooState

func (*State) XorStateBytes

func (xds *State) XorStateBytes(in []byte)

XorStateBytes performs an exclusive-or between the input byte slice and the underlying XoodooState. The result is saved to the internal state

type Xoodoo

type Xoodoo struct {
	State State
	// contains filtered or unexported fields
}

Xoodoo combines the xoodoo state with additional configuration for completing the permutation operation

func NewXoodoo

func NewXoodoo(rounds int, state [StateSizeBytes]byte) (*Xoodoo, error)

NewXoodoo returns a new Xoodoo object initialized with the desired number of rounds for the permutation function to execute

func (*Xoodoo) Bytes

func (xd *Xoodoo) Bytes() []byte

Bytes returns the internal Xoodoo state as a slice of bytes

func (*Xoodoo) Permutation

func (xd *Xoodoo) Permutation()

Permutation executes an optimized implementation of Xoodoo permutation operation over the provided xoodoo state

func (*Xoodoo) XorExtractBytes

func (xd *Xoodoo) XorExtractBytes(x []byte) ([]byte, error)

XorExtractBytes performs an exclusive-or between a provided number of bytes and a matching number of bytes of the underlying Xoodoo state starting from offset 0.

Jump to

Keyboard shortcuts

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