Documentation ¶
Index ¶
- func HmacSha256(ctx context.Context, data []byte, cipher wrapping.Wrapper, ...) (string, error)
- func HmacSha256WithPrk(ctx context.Context, data, prk []byte, opt ...wrapping.Option) (string, error)
- func NewDerivedReader(ctx context.Context, wrapper wrapping.Wrapper, lenLimit int64, ...) (*io.LimitedReader, error)
- func Sha256Sum(ctx context.Context, r io.Reader, opt ...wrapping.Option) ([]byte, error)
- func TestHmacSha256(t *testing.T, key, data []byte, opt ...wrapping.Option) string
- func TestWithBlake2b(t *testing.T, data []byte, w wrapping.Wrapper, opt ...wrapping.Option) string
- func TestWithEd25519(t *testing.T, data []byte, w wrapping.Wrapper, opt ...wrapping.Option) string
- func WithBase58Encoding() wrapping.Option
- func WithBase64Encoding() wrapping.Option
- func WithEd25519() wrapping.Option
- func WithHexEncoding(withHexEncoding bool) wrapping.Option
- func WithInfo(info []byte) wrapping.Option
- func WithMarshaledSigInfo() wrapping.Option
- func WithPrefix(prefix string) wrapping.Option
- func WithPrk(prk []byte) wrapping.Option
- func WithSalt(salt []byte) wrapping.Option
- type OptionFunc
- type Sha256SumReader
- type Sha256SumWriter
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, WithPrk, WithMarshaledSigInfo, WithBase64Encoding, WithBase58Encoding 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 Sha256Sum ¶
Sha256Sum computes SHA256 message digest. Options supported: WithHexEncoding (which is compatible/comparable with GNU sha256sum's output)
func TestHmacSha256 ¶
TestHmacSha256 produces a test hmac sha256. Supported options: WithBase64Encoding, WithBase58Encoding, WithPrefix
func TestWithBlake2b ¶
TestWithBlake2b produces a test hmac sha256 using derived blake2b. Supported options: WithPrk, WithBase64Encoding, WithBase58Encoding, WithMarshaledSigInfo
func TestWithEd25519 ¶
TestWithEd25519 produces test hmac sha256 using a derived Ed25519 key
func WithBase58Encoding ¶
WithBase58Encoding allows an optional request to base58 encode the data returned
func WithBase64Encoding ¶
WithBase64Encoding allows an optional request to base64 encode the data returned
func WithEd25519 ¶
WithEd25519 allows an optional request to use ed25519 during the operation
func WithHexEncoding ¶
WithHexEncoding allows an optional request to use hex encoding.
func WithMarshaledSigInfo ¶
WithMarshaledSigInfo allows an optional request to wrap the returned data into a marshaled wrapping.SigInfo protobuf
func WithPrefix ¶
WithPrefix allows an optional prefix to be specified for the data returned
Types ¶
type OptionFunc ¶
type OptionFunc func(*options) error
OptionFunc holds a function with local options
type Sha256SumReader ¶
type Sha256SumReader struct {
// contains filtered or unexported fields
}
Sha256SumReader provides an io.Reader which can be used to calculate a sum while reading a file. It implements io.ReaderCloser.
func NewSha256SumReader ¶
NewSha256SumReader creates a new Sha256Reader.
func (*Sha256SumReader) Close ¶
func (r *Sha256SumReader) Close() error
Close checks to see if the Sha256SumReader's io.Reader implements the optional io.Closer and if so, then Close() is called; otherwise this is a noop
type Sha256SumWriter ¶
type Sha256SumWriter struct {
// contains filtered or unexported fields
}
Sha256SumWriter provides multi-writer which will be used to write to a hash and produce a sum. It implements io.WriterCloser and io.StringWriter.
func NewSha256SumWriter ¶
NewSha256SumWriter creates a new Sha256SumWriter
func (*Sha256SumWriter) Close ¶
func (w *Sha256SumWriter) Close() error
Close checks to see if the Sha256SumWriter implements the optional io.Closer and if so, then Close() is called; otherwise this is a noop
func (*Sha256SumWriter) Write ¶
func (w *Sha256SumWriter) Write(b []byte) (int, error)
Write will write the bytes to the hash. Implements the required io.Writer func.
func (*Sha256SumWriter) WriteString ¶
func (w *Sha256SumWriter) WriteString(s string) (int, error)
WriteString will write the string to hash.