crypto

package
v2.0.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2015 License: BSD-3-Clause, Apache-2.0 Imports: 2 Imported by: 0

README

go-crypto

A Subset of the Go crypto Package with a Resumable Hash Interface

Documentation

GoDocs: http://godoc.org/github.com/jlhawn/go-crypto

Documentation

Overview

Package crypto is a Subset of the Go `crypto` Package with a Resumable Hash

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHash

func RegisterHash(h Hash, f func() ResumableHash)

RegisterHash registers a function that returns a new instance of the given hash function. This is intended to be called from the init function in packages that implement hash functions.

Types

type Hash

type Hash uint

Hash identifies a cryptographic hash function that is implemented in another package.

const (
	SHA224 Hash = 1 + iota // import crypto/sha256
	SHA256                 // import crypto/sha256
	SHA384                 // import crypto/sha512
	SHA512                 // import crypto/sha512

)

func (Hash) Available

func (h Hash) Available() bool

Available reports whether the given hash function is linked into the binary.

func (Hash) HashFunc

func (h Hash) HashFunc() Hash

HashFunc simply returns the value of h so that Hash implements SignerOpts.

func (Hash) New

func (h Hash) New() ResumableHash

New returns a new ResumableHash calculating the given hash function. New panics if the hash function is not linked into the binary.

func (Hash) Size

func (h Hash) Size() int

Size returns the length, in bytes, of a digest resulting from the given hash function. It doesn't require that the hash function in question be linked into the program.

type ResumableHash

type ResumableHash interface {
	// ResumableHash is a superset of hash.Hash
	hash.Hash
	// Len returns the number of bytes written to the Hash so far.
	Len() uint64
	// State returns a snapshot of the state of the Hash.
	State() ([]byte, error)
	// Restore resets the Hash to the given state.
	Restore(state []byte) error
}

ResumableHash is the common interface implemented by all resumable hash functions.

Directories

Path Synopsis
Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4.
Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4.
Package sha512 implements the SHA384 and SHA512 hash algorithms as defined in FIPS 180-2.
Package sha512 implements the SHA384 and SHA512 hash algorithms as defined in FIPS 180-2.

Jump to

Keyboard shortcuts

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