Documentation ¶
Index ¶
- Constants
- func CryptoDecryptAEAD(in, key, id, ad, tag []byte) (pt []byte, valid bool, err error)
- func CryptoEncryptAEAD(in, key, id, ad []byte) (ct, tag []byte, err error)
- func HashXoodyak(in []byte) []byte
- func HashXoodyakLen(in []byte, hLen uint) []byte
- func MACXoodyak(key, msg []byte, macLen uint) []byte
- func NewXoodyakAEAD(key []byte) (cipher.AEAD, error)
- func NewXoodyakHash() hash.Hash
- func NewXoodyakMac(key []byte) hash.Hash
- type CryptMode
- type CyclistMode
- type CyclistPhase
- type Xoodyak
- func (xk *Xoodyak) Absorb(x []byte)
- func (xk *Xoodyak) AbsorbAny(x []byte, r uint, cd uint8)
- func (xk *Xoodyak) AbsorbBlock(x []byte, cd uint8)
- func (xk *Xoodyak) AbsorbKey(key, id, counter []byte)
- func (xk *Xoodyak) Crypt(msg []byte, cm CryptMode) []byte
- func (xk *Xoodyak) Decrypt(ct []byte) []byte
- func (xk *Xoodyak) Down(Xi []byte, Cd byte)
- func (xk *Xoodyak) Encrypt(pt []byte) []byte
- func (xk *Xoodyak) Ratchet()
- func (xk *Xoodyak) Squeeze(outLen uint) []byte
- func (xk *Xoodyak) SqueezeAny(YLen uint, Cu uint8) []byte
- func (xk *Xoodyak) SqueezeKey(keyLen uint) []byte
- func (xk *Xoodyak) Up(Cu byte, Yilen uint) []byte
Examples ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func CryptoDecryptAEAD ¶
CryptoDecryptAEAD decrypts and authenticates a ciphertext message given a 16-byte key, 16-byte nonce. optional associated metadata bytes, and a 16 byte authentication tag generated at encryption. A plaintext message is only returned if authentication is successful. This decryption process is compatible with the Xoodyak LWC AEAD implementation.
func CryptoEncryptAEAD ¶
CryptoEncryptAEAD encrypts a plaintext message given a 16-byte key, 16-bytes nonce, and optional associated metadata bytes. Along with a cipher text, a 16-byte authentication tag is also generated The ciphertext and tag data is compatible with the Xoodyak LWC AEAD implementation.
func HashXoodyak ¶
HashXoodyak calculates a 32-byte hash on a provided slice of bytes. The output is compatible with the Xoodyak LWC definition
Example ¶
package main import ( "fmt" "github.com/inmcm/xoodoo/xoodyak" ) func main() { myMsg := []byte("hello xoodoo") myHash := xoodyak.HashXoodyak(myMsg) fmt.Printf("Msg:'%s'\nHash:%x\n", myMsg, myHash) }
Output: Msg:hello xoodoo Hash:5c9a95363d79b2157cbdfff49dddaf1f20562dc64644f2d28211478537e6b29a
func HashXoodyakLen ¶
HashXoodyakLen calculates a cryptographic hash of arbitrary length on a provided slice of bytes
Example ¶
package main import ( "fmt" "github.com/inmcm/xoodoo/xoodyak" ) func main() { myMsg := []byte("hello xoodoo") myHash := xoodyak.HashXoodyakLen(myMsg, 64) fmt.Printf("Msg:%s\nHash:%x\n", myMsg, myHash) }
Output: Msg:hello xoodoo Hash:5c9a95363d79b2157cbdfff49dddaf1f20562dc64644f2d28211478537e6b29a5675a6d4a3fe18b985e7ae018133c118a44c5f82b3672492a30408937e5712cb
func MACXoodyak ¶ added in v0.9.3
MACXoodyak generates a message authentication code of the desired length in bytes for the provided message based on the provided key data. This implements the MAC behavior described in section 1.3.2 of the Xoodyak specification.
func NewXoodyakAEAD ¶
NewXoodyakAEAD accepts a set of key bytes and returns object compatible with the stdlib crypto/cipher AEAD interface
func NewXoodyakHash ¶
NewXoodyakHash returns a initialized Xoodyak digest object compatible with the stdlib Hash interface
func NewXoodyakMac ¶ added in v0.9.3
NewXoodyakMac generates a new hashing object with the provided key data already baked in. Writing Any data then written to the hash object is part of the MAC check. Note that the length of the resulting MAC matches that of the offical Xoodyak hash output: 32 bytes
Types ¶
type CryptMode ¶
type CryptMode int
CryptMode defines if a Xoodyak instance (already running in keyed mode) is encrypting or decrypting provided message data
type CyclistMode ¶
type CyclistMode int
CyclistMode defines if a Xoodyak instance should be running in hashing mode or encryption (keyed) modes
const ( Hash CyclistMode = iota + 1 Keyed )
type CyclistPhase ¶
type CyclistPhase int
CyclistPhase defines if a Xoodyak instance should perform the Up or Down method in the current Cyclist iteration
const ( Down CyclistPhase = iota + 1 Up )
type Xoodyak ¶
type Xoodyak struct { Instance *xoodoo.Xoodoo Mode CyclistMode Phase CyclistPhase AbsorbSize uint SqueezeSize uint }
Xoodyak is a cryptographic object that allows execution of the Cyclist operating mode on the Xoodoo permutation primitive. Xoodyak allows for construction of a variety of hashing, encryption and authentication schemes through assembly of its various operating methods
func Instantiate ¶
Instantiate generate a new Xoodoo object initialized for hashing or keyed operations
func (*Xoodyak) Absorb ¶
Absorb ingests a provided message at the rate of the Xoodyak instance's absorption size
func (*Xoodyak) AbsorbBlock ¶
AbsorbBlock ingests a single block of bytes encompassing a single iteration of the Cyclist sequence
func (*Xoodyak) AbsorbKey ¶
AbsorbKey is special Xoodyak method that ingests provided key, id (nonce), and counter messages into the Xoodoo state enabling the keyed mode of operation typically used for authenticated encryption
func (*Xoodyak) Crypt ¶
Crypt is core encryption function of Xoodyak/Cyclist. It accepts a byte message of arbitrary length and generates either a ciphertext or plaintext based on the mode provided. Encryption or decryption is accomplished via XOR against a keystream generated from the Xoodoo primitive
func (*Xoodyak) Decrypt ¶
Decrypt transforms the provided ciphertext message into a plainext message of equal size based on the Xoodyak instance provided (key, nonce, counter have already been processed)
func (*Xoodyak) Down ¶
Down injects the provided slice of bytes into the provided Xoodoo state via xor with the existing state
func (*Xoodyak) Encrypt ¶
Encrypt transforms the provided plaintext message into a ciphertext message of equal size based on the Xoodyak instance provided (key, nonce, counter have already been processed)
func (*Xoodyak) Ratchet ¶
func (xk *Xoodyak) Ratchet()
Ratchet performs a irreversible transformation of the underlying Xoodoo state to prevent key recovery
func (*Xoodyak) Squeeze ¶
Squeeze outputs a provided stream of pseudo-random bytes at the rate of the Xoodyak instance's squeeze size
func (*Xoodyak) SqueezeAny ¶
SqueezeAny allow generation of a message of pseudo-random bytes of any size based on permutating the underlying Xoodoo state
func (*Xoodyak) SqueezeKey ¶
SqueezeKey can generate a new encryption key from the existing Xoodyak state