Overview

Package dsa implements the Digital Signature Algorithm, as defined in FIPS
186-3.

The DSA operations in this package are not implemented using constant-time
algorithms.

Index

dsa.go

Variables

ErrInvalidPublicKey results when a public key is not usable by this code. FIPS
is quite strict about the format of DSA keys, but other code may be less so.
Thus, when using keys which may have been generated by other code, this error
must be handled.

  1. func GenerateKey(priv *, rand io.) error

GenerateKey generates a public&private key pair. The Parameters of the
PrivateKey must already be valid (see GenerateParameters).

func

  1. func GenerateParameters(params *, rand io., sizes ParameterSizes)

func Sign

Sign signs an arbitrary length hash (which should be the result of hashing a
larger message) using the private key, priv. It returns the signature as a pair
of integers. The security of the private key depends on the entropy of rand.

Note that FIPS 186-3 section 4.6 specifies that the hash should be truncated to
the byte-length of the subgroup. This function does not perform that truncation
itself.

Be aware that calling Sign with an attacker-controlled PrivateKey may require an
arbitrary amount of CPU.

func Verify

  1. func Verify(pub *PublicKey, hash [], r, s *big.) bool

Verify verifies the signature in r, s of hash using the public key, pub. It
reports whether the signature is valid.

Note that FIPS 186-3 section 4.6 specifies that the hash should be truncated to
the byte-length of the subgroup. This function does not perform that truncation
itself.

    ParameterSizes is an enumeration of the acceptable bit lengths of the primes in
    a set of DSA parameters. See FIPS 186-3, section 4.2.

    type

    1. type Parameters struct {
    2. P, Q, G *.Int
    3. }

    Parameters represents the domain parameters for a key. These parameters can be
    shared across many keys. The bit length of Q must be a multiple of 8.

    type

    1. type PrivateKey struct {
    2. X *big.
    3. }

    PrivateKey represents a DSA private key.

    type PublicKey

    PublicKey represents a DSA public key.