crypto

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HmacSha256

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

HmacSha256 the provided data. Supports WithSalt, WithInfo, 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 ...wrapping.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, opt ...wrapping.Option) (*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, _ := crypto.NewDerivedReader(wrapper, userId, jobId)
key := ed25519.GenerateKey(reader)

func TestHmacSha256

func TestHmacSha256(t *testing.T, key, data []byte, opt ...wrapping.Option) string

TestHmacSha256 produces a test hmac sha256

func TestWithBlake2b

func TestWithBlake2b(t *testing.T, data []byte, w wrapping.Wrapper, opt ...wrapping.Option) string

TestWithBlake2b produces a test hmac sha256 using derived blake2b. Supported options: WithPrk

func TestWithEd25519

func TestWithEd25519(t *testing.T, data []byte, w wrapping.Wrapper, opt ...wrapping.Option) string

TestWithEd25519 produces test hmac sha256 using a derived Ed25519 key

func WithBase58Encoding

func WithBase58Encoding() wrapping.Option

WithBase58Encoding allows an optional request to base58 encode the data returned

func WithBase64Encoding

func WithBase64Encoding() wrapping.Option

WithBase64Encoding allows an optional request to base64 encode the data returned

func WithEd25519

func WithEd25519() wrapping.Option

WithEd25519 allows an optional request to use ed25519 during the operation

func WithInfo

func WithInfo(info []byte) wrapping.Option

WithInfo allows optional info to be specified for an operation.

func WithPrefix

func WithPrefix(prefix string) wrapping.Option

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

func WithPrk

func WithPrk(prk []byte) wrapping.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.

func WithSalt

func WithSalt(salt []byte) wrapping.Option

WithSalt allows optional salt to be specified for an operation.

Types

type OptionFunc

type OptionFunc func(*options) error

OptionFunc holds a function with local options

Jump to

Keyboard shortcuts

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