checksum

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMismatch = errors.New("checksum mismatch error")

ErrMismatch indicates a checksum verification failure due to a derived checksum not being equal to expected checksum

Functions

func Verify

func Verify(
	payload proto.Marshaler,
	checksum Checksum,
) error

Verify verifies that the checksum generated from the given thrift object matches the specified expected checksum Return ErrMismatch when checksums mismatch

Types

type Checksum

type Checksum struct {
	// Version represents version of the payload from
	Version int
	// which this checksum was derived
	Flavor Flavor
	// Value is the checksum value
	Value []byte
}

Checksum represents a checksum value along with associated metadata

func FromProto

func FromProto(c *persistenceblobsspb.Checksum) *Checksum

FromProto returns a new checksum using the proto fields

func GenerateCRC32

func GenerateCRC32(
	payload proto.Marshaler,
	payloadVersion int,
) (Checksum, error)

GenerateCRC32 generates an IEEE crc32 checksum on the serilized byte array of the given thrift object. The serialization proto used will be of type thriftRW

func (*Checksum) ToProto

func (c *Checksum) ToProto() *persistenceblobsspb.Checksum

FromProto returns a new checksum using the proto fields

type Flavor

type Flavor int

Flavor is an enum type that represents the type of checksum

const (
	// FlavorUnknown represents an unknown/uninitialized checksum flavor
	FlavorUnknown Flavor = iota
	// FlavorIEEECRC32OverProto3Binary represents crc32 checksum generated over proto3 serialized payload
	FlavorIEEECRC32OverProto3Binary
)

func (Flavor) IsValid

func (f Flavor) IsValid() bool

IsValid returns true if the checksum flavor is valid

Jump to

Keyboard shortcuts

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