crypto

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidParameter = errors.New("Invalid parameter")

Functions

func HmacSha256

func HmacSha256(ctx context.Context, data []byte, cipher wrapping.Wrapper, salt, info []byte, opt ...Option) (string, error)

HmacSha256 the provided data. Supports WithPrefix, WithEd25519 and WithPrk options. WithEd25519 is a "legacy" way to complete this operation and should not be used in new operations unless backward compatibility is needed. The WithPrefix option will prepend the prefix to the hmac-sha256 value.

func HmacSha256WithPrk

func HmacSha256WithPrk(ctx context.Context, data, prk []byte, opt ...Option) (string, error)

HmacSha256WithPrk will HmacSha256 using the provided prk. See HmacSha256 for options supported.

func NewDerivedReader

func NewDerivedReader(ctx context.Context, wrapper wrapping.Wrapper, lenLimit int64, salt, info []byte) (*io.LimitedReader, error)

DerivedReader returns a reader from which keys can be read, using the given wrapper, reader length limit, salt and context info. Salt and info can be nil.

Example:

reader, _ := NewDerivedReader(wrapper, userId, jobId)
key := ed25519.GenerateKey(reader)

func TestWrapper

func TestWrapper(t testing.TB) wrapping.Wrapper

TestWrapper initializes an AEAD wrapping.Wrapper for testing

Types

type Option

type Option func(*options) error

Option - how Options are passed as arguments.

func WithBase58Encoding

func WithBase58Encoding() Option

WithBase58Encoding allows an optional request to base58 encode the data returned

func WithBase64Encoding

func WithBase64Encoding() Option

WithBase64Encoding allows an optional request to base64 encode the data returned

func WithEd25519

func WithEd25519() Option

WithEd25519 allows an optional request to use ed25519 during the operation

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix allows an optional prefix to be specified for the data returned

func WithPrk

func WithPrk(prk []byte) Option

WithPrk allows an optional PRK (pseudorandom key) to be specified for an operation. If you're using this option with HmacSha256, you might consider using HmacSha256WithPrk instead.

Jump to

Keyboard shortcuts

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