crypto_mb

package
v0.9.3-0...-e3c37e7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHA1chunk = 64
	SHA1init0 = 0x67452301
	SHA1init1 = 0xEFCDAB89
	SHA1init2 = 0x98BADCFE
	SHA1init3 = 0x10325476
	SHA1init4 = 0xC3D2E1F0
)
View Source
const BlockSizeSHA1 = 64

The blocksize of SHA1 in bytes.

View Source
const SizeSHA1 = 20

The size of a SHA1 checksum in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiBlock

type MultiBlock interface {
	// BlockSize returns the cipher's block size.
	BlockSize() int

	// VecSize return a number of blocks encrypted at once
	VecSize() int

	// DecryptMany decrypts the first block in src into dst.
	// Dst and src may point at the same memory.
	DecryptMany(dst, src [][]byte)
}

A MultiBlock represents an implementation of block cipher using a given key and acting on a several blocks ata once. All blocks must use the same key. It provides the capability to encrypt or decrypt "vectors" of individual blocks. The mode implementations extend that capability to streams of blocks.

func NewAESMultiBlock

func NewAESMultiBlock(key []byte) MultiBlock

TODO accept number of blocks

type MultiBlockMode

type MultiBlockMode interface {
	// BlockSize returns the mode's block size.
	BlockSize() int
	// VecSize return a number of blocks encrypted at once
	VecSize() int
	// CryptManyBlocks encrypts or decrypts a number of blocks. The length of
	// src must be a multiple of the block size. Dst and src may point to
	// the same memory.
	CryptManyBlocks(dst, src [][]byte)
}

A BlockMode represents a block cipher running in a block-based mode (CBC, ECB etc).

func NewMultiCBCDecrypter

func NewMultiCBCDecrypter(mb MultiBlock, iv [][]byte) MultiBlockMode

func NewMultiCBCEncrypter

func NewMultiCBCEncrypter(mb MultiBlock, iv [][]byte) MultiBlockMode

type MultiHash

type MultiHash interface {
	// Write adds more data to the running hash.
	Write(p [][]byte) (n int) // TODO []io.writer?

	// Sum appends the current hash to b and returns the resulting slice.
	// It does not change the underlying hash state.
	Sum(b [][]byte) [][]byte

	// Reset resets the MultiHash to its initial state.
	Reset()

	// Size returns the number of bytes Sum will return.
	Size() int

	// VecSize returns numer of blocks summed in parallel
	VecSize() int

	// BlockSize returns the hash's underlying block size.
	// The Write method must be able to accept any amount
	// of data, but it may operate more efficiently if all writes
	// are a multiple of the block size.
	BlockSize() int
}

MultiHash is the common interface implemented by all hash functions.

func New

func New() MultiHash

TODO rename to sha1new or move to separate package New returns a new MultiHash computing the SHA1 checksum.

func NewHmac

func NewHmac(h func() MultiHash, key []byte) MultiHash

TODO separate packages to avoid name collisions New returns a new HMAC hash using the given hash.Hash type and key.

type MultiSetIVer

type MultiSetIVer interface {
	SetIV(IV [][]byte)
	SetIVat(IVslice []byte, index int)
}

Jump to

Keyboard shortcuts

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