Documentation ¶
Overview ¶
Package sri implements a Subresource Integrity checker for Go. See https://www.w3.org/TR/SRI/ for more information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
A Checker implements checking of a resource against a given subresource integrity string.
It is not safe for concurrent use; each Checker corresponds to a single resource to be checked.
After creation you would typically use it as a Writer to add data to it, then call Check to verify that the content matches the original expression.
func NewChecker ¶
NewChecker creates a new Checker from the given string. It supports SHA256, SHA384 and SHA512 (although will only calculate those needed for the input). Use NewCheckerForHashes if you need support for additional hash types.
func NewCheckerForHashes ¶
NewCheckerForHashes creates a new Checker from the given string and set of hashes. It does not add any hashes by default, although will still only calculate those required by the SRI string given.
func NewCheckerWithSHA1 ¶
NewCheckerWithSHA1 is like NewChecker but adds SHA1 as an optional hash type. This is generally useful only for compatibility and is *not* recommended by the standard, so use at your own risk.
func (*Checker) Check ¶
Check checks the data read so far against the expected hashes. It returns an error if it does not match or nil on success.