crypto

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstantTimeByteCompare

func ConstantTimeByteCompare(x, y []byte) (int, error)

ConstantTimeByteCompare is a constant-time byte comparison of x and y. This function performs an absolute comparison if the two byte slices assuming they represent a big-endian number.

	 error if len(x) != len(y)
  -1 if x <  y
   0 if x == y
  +1 if x >  y

func ECDSAKey

func ECDSAKey(curve elliptic.Curve, d []byte) *ecdsa.PrivateKey

ECDSAKey takes the given elliptic curve, and private key (d) byte slice and returns the private ECDSA key.

func ECDSAKeyFromPoint

func ECDSAKeyFromPoint(curve elliptic.Curve, d *big.Int) *ecdsa.PrivateKey

ECDSAKeyFromPoint takes the given elliptic curve and point and returns the private and public keypair

func ECDSAPublicKey

func ECDSAPublicKey(curve elliptic.Curve, x, y []byte) (*ecdsa.PublicKey, error)

ECDSAPublicKey takes the provide curve and (x, y) coordinates and returns *ecdsa.PublicKey. Returns an error if the given points are not on the curve.

func HMACKeyDerivation

func HMACKeyDerivation(hash func() hash.Hash, bitLen int, key []byte, label, context []byte) ([]byte, error)

HMACKeyDerivation provides an implementation of a NIST-800-108 of a KDF (Key Derivation Function) in Counter Mode. For the purposes of this implantation HMAC is used as the PRF (Pseudorandom function), where the value of `r` is defined as a 4 byte counter.

func VerifySignature

func VerifySignature(key *ecdsa.PublicKey, hash []byte, signature []byte) (bool, error)

VerifySignature takes the provided public key, hash, and asn1 encoded signature and returns whether the given signature is valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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