Documentation
¶
Index ¶
- Variables
- func AddNamedCurve(curve elliptic.Curve, oid asn1.ObjectIdentifier)
- func Decrypt(priv *PrivateKey, C1x, C1y *big.Int, C2 *big.Int) (plain []byte, err error)
- func DecryptASN1(priv *PrivateKey, data []byte) ([]byte, error)
- func Encrypt(random io.Reader, pub *PublicKey, data []byte) (C1x, C1y *big.Int, C2 *big.Int, err error)
- func EncryptASN1(random io.Reader, pub *PublicKey, data []byte) ([]byte, error)
- 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
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
var ( ErrPrivateKey = errors.New("go-cryptobin/elgamalecc: incorrect private key") ErrPublicKey = errors.New("go-cryptobin/elgamalecc: incorrect public key") )
Functions ¶
func AddNamedCurve ¶
func AddNamedCurve(curve elliptic.Curve, oid asn1.ObjectIdentifier)
func DecryptASN1 ¶
func DecryptASN1(priv *PrivateKey, data []byte) ([]byte, error)
Decrypt asn.1 marshal data
func Encrypt ¶
func Encrypt(random io.Reader, pub *PublicKey, data []byte) (C1x, C1y *big.Int, C2 *big.Int, err error)
Encrypt with Elgamal
func EncryptASN1 ¶
Encrypted and return asn.1 data
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)
Types ¶
type PrivateKey ¶
bign PrivateKey
func GenerateKey ¶
Generate the PrivateKey
func NewPrivateKey ¶
func NewPrivateKey(curve elliptic.Curve, k []byte) (*PrivateKey, error)
New a PrivateKey from privatekey data
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) Decrypt ¶
func (priv *PrivateKey) Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
Decrypt decrypts ciphertext with priv.
func (*PrivateKey) Equal ¶
func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool
Equal reports whether pub and x have the same value.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
Public returns the public key corresponding to priv.
type PublicKey ¶
bign PublicKey
func NewPublicKey ¶
New a PublicKey from publicKey data
func ParsePublicKey ¶
Parse PublicKey der