snowfive

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 8 Imported by: 0

README

snowfive

A highly optimized Go implementation of the SNOW-V and SNOW-Vi synchronous stream ciphers.

API

GoDoc

const KeySize = 32
const IVSize = 16

func NewSnowVCipher(key, iv []byte) (*SnowVCipher, error)
func (c *SnowVCipher) Rekey(key, iv []byte) error
func (c *SnowVCipher) XORKeyStream(dst, src []byte)
func (c *SnowVCipher) Destroy()

func NewSnowViCipher(key, iv []byte) (*SnowViCipher, error)
func (c *SnowViCipher) Rekey(key, iv []byte) error
func (c *SnowViCipher) XORKeyStream(dst, src []byte)
func (c *SnowViCipher) Destroy()

Benchmark

16 KiB stream throughput

Algorithm Gbps vs AES-256-CTR
SNOW-Vi 78.03 1.59×
SNOW-V 52.47 1.07×
AES-256-CTR 48.98 1.00×
ChaCha20 11.21 0.23×

References

Documentation

Overview

Package snowfive implements the SNOW-V and SNOW-Vi synchronous stream ciphers.

Both variants provide confidentiality only. They do not authenticate ciphertext; applications that need integrity must use a separate, secure authentication construction. SNOW-V and SNOW-Vi keystreams are not interchangeable.

Index

Constants

View Source
const (
	// KeySize is the SNOW-V and SNOW-Vi key size in bytes.
	KeySize = 32
	// IVSize is the SNOW-V and SNOW-Vi initialization-vector size in bytes.
	IVSize = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SnowVCipher

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

SnowVCipher is a SNOW-V stream cipher. A SnowVCipher must not be copied after first use, including by dereferencing it for formatting. Its methods are not safe for concurrent calls.

func NewSnowVCipher

func NewSnowVCipher(key, iv []byte) (*SnowVCipher, error)

NewSnowVCipher constructs a SNOW-V stream cipher from a 32-byte key and a 16-byte initialization vector. It reads but does not retain key or iv. The caller must ensure that iv is unique for key.

func (*SnowVCipher) Destroy

func (c *SnowVCipher) Destroy()

Destroy overwrites the cipher's live derived-key state and disables streaming until a successful Rekey. It is idempotent.

func (*SnowVCipher) Rekey

func (c *SnowVCipher) Rekey(key, iv []byte) error

Rekey initializes a zero-value cipher or replaces a live or destroyed cipher's state with a new key and IV. This supports a Destroy-Put/Get-Rekey sync.Pool lifecycle. Invalid key or IV lengths leave the existing state unchanged. The caller must ensure that iv is unique for key.

func (SnowVCipher) String

func (SnowVCipher) String() string

func (*SnowVCipher) XORKeyStream

func (c *SnowVCipher) XORKeyStream(dst, src []byte)

XORKeyStream XORs src with the cipher stream and writes the result to dst. Dst may be longer than src, but otherwise must overlap src exactly or not at all. XORKeyStream panics before initialization and after Destroy until a successful Rekey.

type SnowViCipher

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

SnowViCipher is a SNOW-Vi stream cipher. A SnowViCipher must not be copied after first use, including by dereferencing it for formatting. Its methods are not safe for concurrent calls.

func NewSnowViCipher

func NewSnowViCipher(key, iv []byte) (*SnowViCipher, error)

NewSnowViCipher constructs a SNOW-Vi stream cipher from a 32-byte key and a 16-byte initialization vector. It reads but does not retain key or iv. The caller must ensure that iv is unique for key.

func (*SnowViCipher) Destroy

func (c *SnowViCipher) Destroy()

Destroy overwrites the cipher's live derived-key state and disables streaming until a successful Rekey. It is idempotent.

func (*SnowViCipher) Rekey

func (c *SnowViCipher) Rekey(key, iv []byte) error

Rekey initializes a zero-value cipher or replaces a live or destroyed cipher's state with a new key and IV. This supports a Destroy-Put/Get-Rekey sync.Pool lifecycle. Invalid key or IV lengths leave the existing state unchanged. The caller must ensure that iv is unique for key.

func (SnowViCipher) String

func (SnowViCipher) String() string

func (*SnowViCipher) XORKeyStream

func (c *SnowViCipher) XORKeyStream(dst, src []byte)

XORKeyStream XORs src with the cipher stream and writes the result to dst. Dst may be longer than src, but otherwise must overlap src exactly or not at all. XORKeyStream panics before initialization and after Destroy until a successful Rekey.

Jump to

Keyboard shortcuts

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