security

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(signatureType SignatureType, buffer []byte) ([]byte, error)

Sign signs the provided buffer using the appropriate signer.

func Verify

func Verify(signatureType SignatureType, buffer []byte, signature []byte) (bool, error)

Verify verifies the provided signature against the provided buffer using the appropriate signer.

Types

type DigestSha256

type DigestSha256 struct {
}

DigestSha256 represents a signer that performs a SHA-256 digest over the packet.

func (*DigestSha256) Sign

func (d *DigestSha256) Sign(buf []byte) ([]byte, error)

Sign signs a buffer using DigestSha256.

func (*DigestSha256) Validate

func (d *DigestSha256) Validate(buf []byte, signature []byte) bool

Validate returns whether the provided signature is valid for the provided buffer.

type SignatureType

type SignatureType uint64

SignatureType represents the type of a signature.

const (
	DigestSha256Type             SignatureType = 0
	SignatureSha256WithRsaType   SignatureType = 1
	SignatureSha256WithEcdsaType SignatureType = 3
	SignatureHmacWithSha256Type  SignatureType = 4
	SignatureNullType            SignatureType = 200
)

The various possible values of SignatureType.

type Signer

type Signer interface {
	Sign(buffer []byte) ([]byte, error)
	Validate(buffer []byte, signature []byte) bool
}

Signer represents an implementation of a signature type.

Jump to

Keyboard shortcuts

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