Documentation ¶
Index ¶
- Variables
- func AddParamsForCurve(curve elliptic.Curve, params *ECIESParams)
- func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err error)
- func MaxSharedKeyLength(pub *PublicKey) int
- type BitCurve
- func (BitCurve *BitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool
- func (BitCurve *BitCurve) Marshal(x, y *big.Int) []byte
- func (BitCurve *BitCurve) Params() *elliptic.CurveParams
- func (BitCurve *BitCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) Unmarshal(data []byte) (x, y *big.Int)
- type ECIESParams
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
var ( ErrImport = fmt.Errorf("ecies: failed to import key") ErrInvalidCurve = fmt.Errorf("ecies: invalid elliptic curve") ErrInvalidParams = fmt.Errorf("ecies: invalid ECIES parameters") ErrInvalidPublicKey = fmt.Errorf("ecies: invalid public key") )
var ( ErrKeyDataTooLong = fmt.Errorf("ecies: can't supply requested key data") ErrInvalidMessage = fmt.Errorf("ecies: invalid message") )
var ( DefaultCurve = S256() ErrUnsupportedECDHAlgorithm = fmt.Errorf("ecies: unsupported ECDH algorithm") ErrUnsupportedECIESParameters = fmt.Errorf("ecies: unsupported ECIES parameters") )
var ( ECIES_AES128_SHA256 = &ECIESParams{ Hash: sha256.New, hashAlgo: crypto.SHA256, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 16, } ECIES_AES256_SHA256 = &ECIESParams{ Hash: sha256.New, hashAlgo: crypto.SHA256, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, } ECIES_AES256_SHA384 = &ECIESParams{ Hash: sha512.New384, hashAlgo: crypto.SHA384, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, } ECIES_AES256_SHA512 = &ECIESParams{ Hash: sha512.New, hashAlgo: crypto.SHA512, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, } )
Functions ¶
func AddParamsForCurve ¶
func AddParamsForCurve(curve elliptic.Curve, params *ECIESParams)
func Encrypt ¶
Encrypt encrypts a message using ECIES as specified in SEC 1, 5.1.
s1 and s2 contain shared information that is not part of the resulting ciphertext. s1 is fed into key derivation, s2 is fed into the MAC. If the shared information parameters aren't being used, they should be nil.
func MaxSharedKeyLength ¶
MaxSharedKeyLength returns the maximum length of the shared key the public key can produce.
Types ¶
type BitCurve ¶
type BitCurve struct { P *big.Int // the order of the underlying field N *big.Int // the order of the base point B *big.Int // the constant of the BitCurve equation Gx, Gy *big.Int // (x,y) of the base point BitSize int // the size of the underlying field }
A BitCurve represents a Koblitz Curve with a=0. See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html
func (*BitCurve) Marshal ¶
Marshal converts a point into the form specified in section 4.3.6 of ANSI X9.62.
func (*BitCurve) Params ¶
func (BitCurve *BitCurve) Params() *elliptic.CurveParams
func (*BitCurve) ScalarBaseMult ¶
ScalarBaseMult returns k*G, where G is the base point of the group and k is an integer in big-endian form.
func (*BitCurve) ScalarMult ¶
type ECIESParams ¶
type ECIESParams struct { Hash func() hash.Hash // hash function Cipher func([]byte) (cipher.Block, error) // symmetric cipher BlockSize int // block size of symmetric cipher KeyLen int // length of symmetric key // contains filtered or unexported fields }
func ParamsFromCurve ¶
func ParamsFromCurve(curve elliptic.Curve) (params *ECIESParams)
ParamsFromCurve selects parameters optimal for the selected elliptic curve. Only the curves P256, P384, and P512 are supported.
type PrivateKey ¶
PrivateKey is a representation of an elliptic curve private key.
func GenerateKey ¶
func GenerateKey(rand io.Reader, curve elliptic.Curve, params *ECIESParams) (prv *PrivateKey, err error)
Generate an elliptic curve public / private keypair. If params is nil, the recommended default parameters for the key will be chosen.
func ImportECDSA ¶
func ImportECDSA(prv *ecdsa.PrivateKey) *PrivateKey
Import an ECDSA private key as an ECIES private key.
func (*PrivateKey) ExportECDSA ¶
func (prv *PrivateKey) ExportECDSA() *ecdsa.PrivateKey
Export an ECIES private key as an ECDSA private key.
func (*PrivateKey) GenerateShared ¶
func (prv *PrivateKey) GenerateShared(pub *PublicKey, skLen, macLen int) (sk []byte, err error)
ECDH key agreement method used to establish secret keys for encryption.
type PublicKey ¶
PublicKey is a representation of an elliptic curve public key.
func ImportECDSAPublic ¶
Import an ECDSA public key as an ECIES public key.
func (*PublicKey) ExportECDSA ¶
Export an ECIES public key as an ECDSA public key.