Documentation ¶
Index ¶
- Variables
- func GenerateKey(priv *PrivateKey, rand io.Reader) error
- func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error
- func MarshalXMLPrivateKey(key *PrivateKey) ([]byte, error)
- func MarshalXMLPublicKey(key *PublicKey) ([]byte, error)
- func Sign(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) (r, s *big.Int, err error)
- func SignASN1(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) ([]byte, error)
- func SignBytes(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) (sig []byte, err error)
- func SignUsingK(k *big.Int, priv *PrivateKey, hashFunc Hasher, data []byte) (r, s *big.Int, err error)
- func Verify(pub *PublicKey, hashFunc Hasher, data []byte, r, s *big.Int) bool
- func VerifyASN1(pub *PublicKey, hashFunc Hasher, data []byte, sig []byte) (bool, error)
- func VerifyBytes(pub *PublicKey, hashFunc Hasher, data, sig []byte) bool
- type Hasher
- type ParameterSizes
- type Parameters
- type PrivateKey
- type PublicKey
- type SignerOpts
- type XMLKey
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPublicKey = errors.New("go-cryptobin/sdsa: 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 be less so. Thus, when using keys which may have been generated by other code, this error must be handled.
var (
ErrInvalidSignerOpts = errors.New("go-cryptobin/sdsa: opts must be *SignerOpts")
)
Functions ¶
func GenerateKey ¶
func GenerateKey(priv *PrivateKey, rand io.Reader) error
GenerateKey generates a public&private key pair. The Parameters of the PrivateKey must already be valid (see GenerateParameters).
func GenerateParameters ¶
func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error
GenerateParameters puts a random, valid set of DSA parameters into params. This function can take many seconds, even on fast machines.
func MarshalXMLPrivateKey ¶
func MarshalXMLPrivateKey(key *PrivateKey) ([]byte, error)
Marshal XML PrivateKey
func MarshalXMLPublicKey ¶
Marshal XML PublicKey
func Sign ¶
func Sign(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) (r, s *big.Int, err error)
Sign hash
func SignASN1 ¶
SignASN1 signs a hash (which should be the result of hashing a larger message) using the private key, priv. If the hash is longer than the bit-length of the private key's curve order, the hash will be truncated to that length. It returns the ASN.1 encoded signature.
func SignBytes ¶
func SignBytes(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) (sig []byte, err error)
Sign data returns the Bytes encoded signature.
func SignUsingK ¶ added in v1.0.4006
func SignUsingK(k *big.Int, priv *PrivateKey, hashFunc Hasher, data []byte) (r, s *big.Int, err error)
sign with k
func VerifyASN1 ¶
VerifyASN1 verifies the ASN.1 encoded signature, sig, of hash using the public key, pub. Its return value records whether the signature is valid.
Types ¶
type ParameterSizes ¶
type ParameterSizes int
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.
const ( L1024N160 ParameterSizes = iota L2048N224 L2048N256 L3072N256 )
type Parameters ¶
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 PrivateKey ¶
egdsa PrivateKey
func ParseXMLPrivateKey ¶
func ParseXMLPrivateKey(der []byte) (*PrivateKey, error)
Parse XML PrivateKey
func (*PrivateKey) Equal ¶
func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool
Equal reports whether priv and x have the same value.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
Public returns the public key corresponding to priv.
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(random io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)
Signature generates signature over the given hash. It returns signature value consisting of two parts "r" and "s" as byte arrays.
type PublicKey ¶
type PublicKey struct { Parameters Y *big.Int }
egdsa PublicKey
type SignerOpts ¶
type SignerOpts struct {
Hash Hasher
}
SignerOpts contains options for creating and verifying EC-GDSA signatures.
func (*SignerOpts) GetHash ¶
func (opts *SignerOpts) GetHash() Hasher
GetHash returns func() hash.Hash
func (*SignerOpts) HashFunc ¶
func (opts *SignerOpts) HashFunc() crypto.Hash
HashFunc returns opts.Hash
type XMLKey ¶
type XMLKey struct{}
*
- sdsa xml *
- @create 2024-9-1
- @author deatil
func (XMLKey) MarshalPrivateKey ¶
func (this XMLKey) MarshalPrivateKey(key *PrivateKey) ([]byte, error)
Marshal XML PrivateKey
func (XMLKey) MarshalPublicKey ¶
Marshal XML PublicKey
func (XMLKey) ParsePrivateKey ¶
func (this XMLKey) ParsePrivateKey(data []byte) (*PrivateKey, error)
Parse XML PrivateKey