common

package
v0.0.0-...-9b7c71c Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMarshalUnmarshalFailed = "marshal unmarshal %v failed: \nexpected %#v,\ngot %#v"
)

Test strings

Variables

HashMap is a map from signature schemes to the hash that they use.

MintSupportedSignatureSchemes is a list of all signature schemes supported by the mint package.

Functions

func GetExtensionListFromSignatureScheme

func GetExtensionListFromSignatureScheme(sigScheme mint.SignatureScheme) mint.ExtensionList

GetExtensionListFromSignatureScheme returns an ExtensionList containing the given signature scheme.

func GetExtensionListFromSignatureSchemes

func GetExtensionListFromSignatureSchemes(sigSchemes []mint.SignatureScheme) mint.ExtensionList

GetExtensionListFromSignatureSchemes returns an ExtensionList containing the given signature schemes.

func GetRandomBytes

func GetRandomBytes(n int) []byte

GetRandomBytes returns n random bytes.

func MarshalErrorAsJSON

func MarshalErrorAsJSON(target error) ([]byte, error)

MarshalErrorAsJSON marshals an error as json.

func MarshalList

func MarshalList(toMarshal []Marshaler) ([]byte, error)

MarshalList marshals a list of values that are marshal-able.

func SelfSignedCert

func SelfSignedCert(domain string, roots *x509.CertPool, scheme mint.SignatureScheme) (*mint.Certificate, error)

SelfSignedCert creates a new self-signed cert for the given domain and adds it to the roots pool (if provided).

func SelfSignedCerts

func SelfSignedCerts(domain string, roots *x509.CertPool) ([]*mint.Certificate, error)

SelfSignedCerts returns a list of self-signed certificates, each signed with a different signature scheme supported by mint.

func UnmarshalList

func UnmarshalList(toUnmarshal []Unmarshaler, data []byte) (int, error)

UnmarshalList unmarshals a list of values that are unmarshal-able.

func XORBytes

func XORBytes(a, b []byte) ([]byte, error)

XORBytes xors b into a. Byte slices a and b must be of equal length.

Types

type Causer

type Causer interface {
	Cause() error
}

Causer is an interface for the cause of an error.

type Error

type Error uint8

Error represents an error for the library.

const (
	// ErrorNoError represents an empty error.
	ErrorNoError Error = 0 + iota

	// ErrorSpontaneousAuthForbidden represents error when an spontaneous session is forbidden.
	ErrorSpontaneousAuthForbidden
	// ErrorSessionNotFound represents error when the session is not found.
	ErrorSessionNotFound
	// ErrorIncorrectState represents error it reaches an incorrect state.
	ErrorIncorrectState
	// ErrorIncorrectRole represents error when it reaches an incorrect role.
	ErrorIncorrectRole
	// ErrorUnrecognizedMessage represents error when the message is not recognized.
	ErrorUnrecognizedMessage
	// ErrorNoCertificates represents error when there are no certificates.
	ErrorNoCertificates
	// ErrorInconsistentContext represents error when the context is inconsistent.
	ErrorInconsistentContext
	// ErrorReusedContext represents error when context is reused.
	ErrorReusedContext
	// ErrorInvalidContext represents error when the context is invalid.
	ErrorInvalidContext
	// ErrorUnrecognizedLabel represents error when the label is not recognized.
	ErrorUnrecognizedLabel
	// ErrorNoPasswordTable represents error when there is no password table.
	ErrorNoPasswordTable
	// ErrorUserNotRegistered represents error when the user is not yet registered.
	ErrorUserNotRegistered
	// ErrorUserAlreadyRegistered represents error when the user is already registered.
	ErrorUserAlreadyRegistered
	// ErrorUnexpectedMessage represents error when an unexpected message arrives.
	ErrorUnexpectedMessage
	// ErrorHmacTagInvalid represents error when HMAC tag is invalid.
	ErrorHmacTagInvalid
	// ErrorForbiddenPolicy represents error when there is a forbidden credential encoding policy.
	ErrorForbiddenPolicy
	// ErrorUnexpectedData represents error when unexpected data arrived.
	ErrorUnexpectedData
	// ErrorInvalidFinishedMac represents error when the finished MAC is invalid.
	ErrorInvalidFinishedMac
	// ErrorBadEnvelope represents error when decription of the envelope fails.
	ErrorBadEnvelope
	// ErrorInvalidAuthenticator represents error when the authenticator is invalid.
	ErrorInvalidAuthenticator
	// ErrorUnsupportedCiphersuite represents error when the ciphersuite is not supported.
	ErrorUnsupportedCiphersuite
	// ErrorNotFound represents error when a field is not found.
	ErrorNotFound

	// ErrorOtherError represents other kinds of errors not previously covered.
	ErrorOtherError
)

func (Error) Error

func (e Error) Error() string

Error returns the corresponding string to the error.

func (Error) Is

func (e Error) Is(target error) bool

Is compares two errors.

func (Error) Wrap

func (e Error) Wrap(err error) error

Wrap coverts an stdlib error to a library one.

type MarshalUnmarshaler

type MarshalUnmarshaler interface {
	Marshaler
	Unmarshaler
}

MarshalUnmarshaler is a type that can marshal and unmarshal itself.

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
}

Marshaler is the interface implemented by types that can be marshaled (converted to raw bytes).

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte) (int, error)
}

Unmarshaler is the interface implemented by types that can be unmarshaled (converted from raw bytes to a struct).

Jump to

Keyboard shortcuts

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