Documentation
¶
Overview ¶
Package crypto contains cryptographic utilities.
Index ¶
- Constants
- Variables
- func IsValidDefaultPSK(s string) bool
- func IsValidPSK(s string, length int) bool
- func IsValidPSKBytes(b []byte, length int) bool
- func Sign(data []byte, psk PSK) ([]byte, error)
- func Verify(data, signature []byte, psk PSK) error
- type PSK
- func (p PSK) DeterministicSign(data []byte) ([]byte, error)
- func (p PSK) DeterministicSignatureSize() int
- func (p PSK) DeterministicVerify(data, signature []byte) error
- func (p PSK) IsValid() bool
- func (p PSK) Sign(data []byte) ([]byte, error)
- func (p PSK) SignatureSize() int
- func (p PSK) String() string
- func (p PSK) Verify(data, signature []byte) error
- type Signer
Constants ¶
const DefaultPSKLength = 32
DefaultPSKLength is the default length of a PSK.
Variables ¶
var ErrInvalidSignature = fmt.Errorf("invalid signature")
ErrInvalidSignature is returned when a signature is invalid.
var ValidPSKChars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
ValidPSKChars is the set of valid characters for a PSK.
Functions ¶
func IsValidDefaultPSK ¶ added in v0.4.1
IsValidDefaultPSK returns true if the given string is a valid PSK.
func IsValidPSK ¶ added in v0.4.1
IsValidPSK returns true if the given string is a valid PSK.
func IsValidPSKBytes ¶ added in v0.4.1
IsValidPSKBytes returns true if the given byte slice is a valid PSK.
Types ¶
type PSK ¶
type PSK []byte
PSK is a pre-shared key.
func GeneratePSKWithLength ¶
GeneratePSKWithLength generates a PSK with a given length.
func MustGeneratePSK ¶
func MustGeneratePSK() PSK
MustGeneratePSK generates a PSK and panics on error.
func (PSK) DeterministicSign ¶ added in v0.4.1
DeterministicSign creates a signature of the given data using this PSK.
func (PSK) DeterministicSignatureSize ¶ added in v0.4.1
func (PSK) DeterministicVerify ¶ added in v0.4.1
DeterministicVerify verifies the given signature against the given data using this PSK.
func (PSK) SignatureSize ¶ added in v0.4.1
type Signer ¶ added in v0.4.1
type Signer interface {
// Sign signs the given data.
Sign(data []byte) ([]byte, error)
// Verify verifies the given signature against the given data.
Verify(data, signature []byte) error
// SignatureSize returns the size of the signature.
SignatureSize() int
}
Signer is a type that can sign data.