package dsa
Import Path
crypto/dsa (on go.dev)
Dependency Relation
imports 4 packages, and imported by one package
Involved Source Files
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.
Deprecated: DSA is a legacy algorithm, and modern alternatives such as
Ed25519 (implemented by package crypto/ed25519) should be used instead. Keys
with 1024-bit moduli (L1024N160 parameters) are cryptographically weak, while
bigger keys are not widely supported. Note that FIPS 186-5 no longer approves
DSA for signature generation.
Package-Level Type Names (total 4)
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.
G *big.Int
P *big.Int
Q *big.Int
func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error
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.
func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error
const L1024N160
const L2048N224
const L2048N256
const L3072N256
PrivateKey represents a DSA private key.
PublicKey PublicKey
PublicKey.Parameters Parameters
PublicKey.Parameters.G *big.Int
PublicKey.Parameters.P *big.Int
PublicKey.Parameters.Q *big.Int
PublicKey.Y *big.Int
X *big.Int
func GenerateKey(priv *PrivateKey, rand io.Reader) error
func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error)
PublicKey represents a DSA public key.
Parameters Parameters
Parameters.G *big.Int
Parameters.P *big.Int
Parameters.Q *big.Int
Y *big.Int
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool
Package-Level Functions (total 4)
GenerateKey generates a public&private key pair. The Parameters of the
[PrivateKey] must already be valid (see [GenerateParameters]).
GenerateParameters puts a random, valid set of DSA parameters into params.
This function can take many seconds, even on fast machines.
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.
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.
Package-Level Variables (only one)
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.
Package-Level Constants (total 4)
const L1024N160 ParameterSizes = 0 const L2048N224 ParameterSizes = 1 const L2048N256 ParameterSizes = 2 const L3072N256 ParameterSizes = 3
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |