version: 1.10

package crypto

import "crypto"

Overview

Package crypto collects common cryptographic constants.

Index

Package files

crypto.go

func RegisterHash

  1. func RegisterHash(h Hash, f func() hash.Hash)

RegisterHash registers a function that returns a new instance of the given hash
function. This is intended to be called from the init function in packages that
implement hash functions.

type Decrypter

  1. type Decrypter interface {
  2. // Public returns the public key corresponding to the opaque,
  3. // private key.
  4. Public() PublicKey
  5.  
  6. // Decrypt decrypts msg. The opts argument should be appropriate for
  7. // the primitive used. See the documentation in each implementation for
  8. // details.
  9. Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error)
  10. }

Decrypter is an interface for an opaque private key that can be used for
asymmetric decryption operations. An example would be an RSA key kept in a
hardware module.

type DecrypterOpts

  1. type DecrypterOpts interface{}

type Hash

  1. type Hash uint

Hash identifies a cryptographic hash function that is implemented in another
package.

  1. const (
  2. MD4 Hash = 1 + iota // import golang.org/x/crypto/md4
  3. MD5 // import crypto/md5
  4. SHA1 // import crypto/sha1
  5. SHA224 // import crypto/sha256
  6. SHA256 // import crypto/sha256
  7. SHA384 // import crypto/sha512
  8. SHA512 // import crypto/sha512
  9. MD5SHA1 // no implementation; MD5+SHA1 used for TLS RSA
  10. RIPEMD160 // import golang.org/x/crypto/ripemd160
  11. SHA3_224 // import golang.org/x/crypto/sha3
  12. SHA3_256 // import golang.org/x/crypto/sha3
  13. SHA3_384 // import golang.org/x/crypto/sha3
  14. SHA3_512 // import golang.org/x/crypto/sha3
  15. SHA512_224 // import crypto/sha512
  16. SHA512_256 // import crypto/sha512
  17. BLAKE2s_256 // import golang.org/x/crypto/blake2s
  18. BLAKE2b_256 // import golang.org/x/crypto/blake2b
  19. BLAKE2b_384 // import golang.org/x/crypto/blake2b
  20. BLAKE2b_512 // import golang.org/x/crypto/blake2b
  21.  
  22. )

func (Hash) Available

  1. func (h Hash) Available() bool

Available reports whether the given hash function is linked into the binary.

func (Hash) HashFunc

  1. func (h Hash) HashFunc() Hash

HashFunc simply returns the value of h so that Hash implements SignerOpts.

func (Hash) New

  1. func (h Hash) New() hash.Hash

New returns a new hash.Hash calculating the given hash function. New panics if
the hash function is not linked into the binary.

func (Hash) Size

  1. func (h Hash) Size() int

Size returns the length, in bytes, of a digest resulting from the given hash
function. It doesn’t require that the hash function in question be linked into
the program.

type PrivateKey

  1. type PrivateKey interface{}

PrivateKey represents a private key using an unspecified algorithm.

type PublicKey

  1. type PublicKey interface{}

PublicKey represents a public key using an unspecified algorithm.

type Signer

  1. type Signer interface {
  2. // Public returns the public key corresponding to the opaque,
  3. // private key.
  4. Public() PublicKey
  5.  
  6. // Sign signs digest with the private key, possibly using entropy from
  7. // rand. For an RSA key, the resulting signature should be either a
  8. // PKCS#1 v1.5 or PSS signature (as indicated by opts). For an (EC)DSA
  9. // key, it should be a DER-serialised, ASN.1 signature structure.
  10. //
  11. // Hash implements the SignerOpts interface and, in most cases, one can
  12. // simply pass in the hash function used as opts. Sign may also attempt
  13. // to type assert opts to other types in order to obtain algorithm
  14. // specific values. See the documentation in each package for details.
  15. //
  16. // Note that when a signature of a hash of a larger message is needed,
  17. // the caller is responsible for hashing the larger message and passing
  18. // the hash (as digest) and the hash function (as opts) to Sign.
  19. Sign(rand io.Reader, digest []byte, opts SignerOpts) (signature []byte, err error)
  20. }

Signer is an interface for an opaque private key that can be used for signing
operations. For example, an RSA key kept in a hardware module.

type SignerOpts

  1. type SignerOpts interface {
  2. // HashFunc returns an identifier for the hash function used to produce
  3. // the message passed to Signer.Sign, or else zero to indicate that no
  4. // hashing was done.
  5. HashFunc() Hash
  6. }

SignerOpts contains options for signing with a Signer.

Subdirectories