Movatterモバイル変換


[0]ホーム

URL:


dsa

packagestandard library
go1.25.5Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:5Imported by:5,046

Details

Repository

cs.opensource.google/go/go

Links

Documentation

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.

Deprecated: DSA is a legacy algorithm, and modern alternatives such asEd25519 (implemented by package crypto/ed25519) should be used instead. Keyswith 1024-bit moduli (L1024N160 parameters) are cryptographically weak, whilebigger keys are not widely supported. Note that FIPS 186-5 no longer approvesDSA for signature generation.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPublicKey =errors.New("crypto/dsa: invalid public key")

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 beless so. Thus, when using keys which may have been generated by other code,this error must be handled.

Functions

funcGenerateKey

func GenerateKey(priv *PrivateKey, randio.Reader)error

GenerateKey generates a public&private key pair. The Parameters of thePrivateKey must already be valid (seeGenerateParameters).

funcGenerateParameters

func GenerateParameters(params *Parameters, randio.Reader, sizesParameterSizes)error

GenerateParameters puts a random, valid set of DSA parameters into params.This function can take many seconds, even on fast machines.

funcSign

func Sign(randio.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, errerror)

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

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

Be aware that calling Sign with an attacker-controlledPrivateKey mayrequire an arbitrary amount of CPU.

funcVerify

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

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

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

Types

typeParameterSizes

type ParameterSizesint

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

const (L1024N160ParameterSizes =iotaL2048N224L2048N256L3072N256)

typeParameters

type Parameters struct {P, Q, G *big.Int}

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

typePrivateKey

type PrivateKey struct {PublicKeyX *big.Int}

PrivateKey represents a DSA private key.

typePublicKey

type PublicKey struct {ParametersY *big.Int}

PublicKey represents a DSA public key.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp