checksum

package module
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInputMiddleware

func AddInputMiddleware(stack *middleware.Stack, options InputMiddlewareOptions) (err error)

AddInputMiddleware adds the middleware for performing checksum computing of request payloads, and checksum validation of response payloads.

func AddOutputMiddleware

func AddOutputMiddleware(stack *middleware.Stack, options OutputMiddlewareOptions) error

AddOutputMiddleware adds the middleware for validating response payload's checksum.

func AlgorithmChecksumLength

func AlgorithmChecksumLength(v Algorithm) (int, error)

AlgorithmChecksumLength returns the length of the algorithm's checksum in bytes. If the algorithm is not known, an error is returned.

func AlgorithmHTTPHeader

func AlgorithmHTTPHeader(v Algorithm) string

AlgorithmHTTPHeader returns the HTTP header for the algorithm's hash.

func GetComputedInputChecksums

func GetComputedInputChecksums(m middleware.Metadata) (map[string]string, bool)

GetComputedInputChecksums returns the map of checksum algorithm to their computed value stored in the middleware Metadata. Returns false if no values were stored in the Metadata.

func GetOutputValidationAlgorithmsUsed

func GetOutputValidationAlgorithmsUsed(m middleware.Metadata) ([]string, bool)

GetOutputValidationAlgorithmsUsed returns the checksum algorithms used stored in the middleware Metadata. Returns false if no algorithms were stored in the Metadata.

func NewAlgorithmHash

func NewAlgorithmHash(v Algorithm) (hash.Hash, error)

NewAlgorithmHash returns a hash.Hash for the checksum algorithm. Error is returned if the algorithm is unknown.

func RemoveInputMiddleware

func RemoveInputMiddleware(stack *middleware.Stack)

RemoveInputMiddleware Removes the compute input payload checksum middleware handlers from the stack.

func RemoveOutputMiddleware

func RemoveOutputMiddleware(stack *middleware.Stack)

RemoveOutputMiddleware Removes the compute input payload checksum middleware handlers from the stack.

func SetComputedInputChecksums

func SetComputedInputChecksums(m *middleware.Metadata, vs map[string]string)

SetComputedInputChecksums stores the map of checksum algorithm to their computed value in the middleware Metadata. Overwrites any values that currently exist in the metadata.

func SetOutputValidationAlgorithmsUsed

func SetOutputValidationAlgorithmsUsed(m *middleware.Metadata, vs []string)

SetOutputValidationAlgorithmsUsed stores the checksum algorithms used in the middleware Metadata.

Types

type Algorithm

type Algorithm string

Algorithm represents the checksum algorithms supported

const (
	// AlgorithmCRC32C represents CRC32C hash algorithm
	AlgorithmCRC32C Algorithm = "CRC32C"

	// AlgorithmCRC32 represents CRC32 hash algorithm
	AlgorithmCRC32 Algorithm = "CRC32"

	// AlgorithmSHA1 represents SHA1 hash algorithm
	AlgorithmSHA1 Algorithm = "SHA1"

	// AlgorithmSHA256 represents SHA256 hash algorithm
	AlgorithmSHA256 Algorithm = "SHA256"
)

Enumeration values for supported checksum Algorithms.

func FilterSupportedAlgorithms

func FilterSupportedAlgorithms(vs []string) []Algorithm

FilterSupportedAlgorithms filters the set of algorithms, returning a slice of algorithms that are supported.

func ParseAlgorithm

func ParseAlgorithm(v string) (Algorithm, error)

ParseAlgorithm attempts to parse the provided value into a checksum algorithm, matching without case. Returns the algorithm matched, or an error if the algorithm wasn't matched.

func (Algorithm) String

func (a Algorithm) String() string

type InputMiddlewareOptions

type InputMiddlewareOptions struct {
	// GetAlgorithm is a function to get the checksum algorithm of the
	// input payload from the input parameters.
	//
	// Given the input parameter value, the function must return the algorithm
	// and true, or false if no algorithm is specified.
	GetAlgorithm func(interface{}) (string, bool)

	// Forces the middleware to compute the input payload's checksum. The
	// request will fail if the algorithm is not specified or unable to compute
	// the checksum.
	RequireChecksum bool

	// Enables support for wrapping the serialized input payload with a
	// content-encoding: aws-check wrapper, and including a trailer for the
	// algorithm's checksum value.
	//
	// The checksum will not be computed, nor added as trailing checksum, if
	// the Algorithm's header is already set on the request.
	EnableTrailingChecksum bool

	// Enables support for computing the SHA256 checksum of input payloads
	// along with the algorithm specified checksum. Prevents downstream
	// middleware handlers (computePayloadSHA256) re-reading the payload.
	//
	// The SHA256 payload checksum will only be used for computed for requests
	// that are not TLS, or do not enable trailing checksums.
	//
	// The SHA256 payload hash will not be computed, if the Algorithm's header
	// is already set on the request.
	EnableComputeSHA256PayloadHash bool

	// Enables support for setting the aws-chunked decoded content length
	// header for the decoded length of the underlying stream. Will only be set
	// when used with trailing checksums, and aws-chunked content-encoding.
	EnableDecodedContentLengthHeader bool
}

InputMiddlewareOptions provides the options for the request checksum middleware setup.

type OutputMiddlewareOptions

type OutputMiddlewareOptions struct {
	// GetValidationMode is a function to get the checksum validation
	// mode of the output payload from the input parameters.
	//
	// Given the input parameter value, the function must return the validation
	// mode and true, or false if no mode is specified.
	GetValidationMode func(interface{}) (string, bool)

	// The set of checksum algorithms that should be used for response payload
	// checksum validation. The algorithm(s) used will be a union of the
	// output's returned algorithms and this set.
	//
	// Only the first algorithm in the union is currently used.
	ValidationAlgorithms []string

	// If set the middleware will ignore output multipart checksums. Otherwise
	// an checksum format error will be returned by the middleware.
	IgnoreMultipartValidation bool

	// When set the middleware will log when output does not have checksum or
	// algorithm to validate.
	LogValidationSkipped bool

	// When set the middleware will log when the output contains a multipart
	// checksum that was, skipped and not validated.
	LogMultipartValidationSkipped bool
}

OutputMiddlewareOptions provides options for configuring output checksum validation middleware.

Jump to

Keyboard shortcuts

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