Documentation
¶
Index ¶
- Variables
- func AddNamedCurve(curve elliptic.Curve, oid asn1.ObjectIdentifier)
- func MarshalECPrivateKey(key *PrivateKey) ([]byte, error)
- func MarshalPrivateKey(key *PrivateKey) ([]byte, error)
- func MarshalPublicKey(pub *PublicKey) ([]byte, error)
- func NamedCurveFromOid(oid asn1.ObjectIdentifier) elliptic.Curve
- func OidFromNamedCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, bool)
- func PrivateKeyTo(key *PrivateKey) []byte
- func PublicKeyTo(key *PublicKey) []byte
- func SignASN1(rand io.Reader, priv *PrivateKey, hashFunc Hasher, msg []byte) ([]byte, error)
- func SignToRS(random io.Reader, priv *PrivateKey, hashFunc Hasher, msg []byte) (r, s *big.Int, err error)
- func SignUsingKToRS(k *big.Int, priv *PrivateKey, hashFunc Hasher, msg []byte) (r, s *big.Int, err error)
- func VerifyASN1(pub *PublicKey, hashFunc Hasher, msg, signature []byte) (bool, error)
- func VerifyWithRS(pub *PublicKey, hashFunc Hasher, msg []byte, r, s *big.Int) (bool, error)
- type Hasher
- type PrivateKey
- type PublicKey
- type SignerOpts
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCurve = errors.New("go-cryptobin/kg: invalid curve") ErrInvalidK = errors.New("go-cryptobin/kg: use another K") ErrInvalidPrivateKey = errors.New("go-cryptobin/kg: invalid private key") ErrInvalidPublicKey = errors.New("go-cryptobin/kg: invalid public key") ErrInvalidSignature = errors.New("go-cryptobin/kg: invalid signature") ErrInvalidCurvesMatch = errors.New("go-cryptobin/kg: curves miss match") ErrInvalidASN1 = errors.New("go-cryptobin/kg: invalid ASN.1 encoding") ErrInvalidSignerOpts = errors.New("go-cryptobin/kg: opts must be *SignerOpts") )
Functions ¶
func AddNamedCurve ¶
func AddNamedCurve(curve elliptic.Curve, oid asn1.ObjectIdentifier)
func MarshalECPrivateKey ¶
func MarshalECPrivateKey(key *PrivateKey) ([]byte, error)
MarshalECPrivateKey converts an EC private key to SEC 1, ASN.1 DER form.
This kind of key is commonly encoded in PEM blocks of type "EC PRIVATE KEY". For a more flexible key format which is not EC specific, use MarshalPKCS8PrivateKey.
func MarshalPrivateKey ¶
func MarshalPrivateKey(key *PrivateKey) ([]byte, error)
Marshal PrivateKey to der
func MarshalPublicKey ¶
Marshal PublicKey to der
func NamedCurveFromOid ¶
func NamedCurveFromOid(oid asn1.ObjectIdentifier) elliptic.Curve
func OidFromNamedCurve ¶
func OidFromNamedCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, bool)
func SignToRS ¶
func SignToRS(random io.Reader, priv *PrivateKey, hashFunc Hasher, msg []byte) (r, s *big.Int, err error)
* KG signature.
func SignUsingKToRS ¶
func SignUsingKToRS(k *big.Int, priv *PrivateKey, hashFunc Hasher, msg []byte) (r, s *big.Int, err error)
*| IUF - KG signature
func VerifyASN1 ¶
Verify asn.1 marshal data
Types ¶
type PrivateKey ¶
func GenerateKey ¶
generate a private key
func NewPrivateKey ¶
func NewPrivateKey(curve elliptic.Curve, d []byte) (*PrivateKey, error)
New a private key from key data bytes
func ParseECPrivateKey ¶
func ParseECPrivateKey(der []byte) (*PrivateKey, error)
ParseECPrivateKey parses an EC private key in SEC 1, ASN.1 DER form.
This kind of key is commonly encoded in PEM blocks of type "EC PRIVATE KEY".
func ParsePrivateKey ¶
func ParsePrivateKey(derBytes []byte) (*PrivateKey, error)
Parse PrivateKey der
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
The KG's private key contains the public key
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
sign data and return asn.1 or bytes marshal data, default asn.1
type PublicKey ¶
func NewPublicKey ¶
New a PublicKey from publicKey data
func ParsePublicKey ¶
Parse PublicKey der
type SignerOpts ¶
type SignerOpts struct {
Hash Hasher
}
SignerOpts contains options for creating and verifying KG 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