Documentation ¶
Index ¶
- Variables
- func AddParamsForCurve(curve string, params *ECIESParams)
- func DeriveKeys(hash hash.Hash, z, s1 []byte, keyLen int) (Ke, Km []byte)
- func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err error)
- func MaxSharedKeyLength(pub *PublicKey) int
- func MessageTag(hash func() hash.Hash, km, msg, shared []byte) []byte
- func SymDecrypt(params *ECIESParams, key, ct []byte) (m []byte, err error)
- func SymEncrypt(rand io.Reader, params *ECIESParams, key, m []byte) (ct []byte, err error)
- 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") ErrInvalidPublicKey = fmt.Errorf("ecies: invalid public key") )
var ( ErrInvalidMessage = fmt.Errorf("ecies: invalid message") )
var ( DefaultCurve = gost3410.CurveIdtc26gost341012512paramSetA() ErrUnsupportedECDHAlgorithm = fmt.Errorf("ecies: unsupported ECDH algorithm") ErrUnsupportedECIESParameters = fmt.Errorf("ecies: unsupported ECIES parameters") ErrInvalidKeyLen = fmt.Errorf("ecies: invalid key size (> %d) in ECIESParams", maxKeyLen) )
var ( ECIES_AES256_STRBG512 = &ECIESParams{ Hash: gost3411.New512, hashAlgo: crypto.NewStreebogState(64), Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, } )
Functions ¶
func AddParamsForCurve ¶
func AddParamsForCurve(curve string, params *ECIESParams)
func DeriveKeys ¶
deriveKeys creates the encryption and MAC keys using concatKDF.
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.
func MessageTag ¶
messageTag computes the MAC of a message (called the tag) as per SEC 1, 3.5.
func SymDecrypt ¶
func SymDecrypt(params *ECIESParams, key, ct []byte) (m []byte, err error)
symDecrypt carries out CTR decryption using the block cipher specified in the parameters
func SymEncrypt ¶
symEncrypt carries out CTR encryption using the block cipher specified in the
Types ¶
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 string) (params *ECIESParams)
ParamsFromCurve selects parameters optimal for the selected elliptic curve. Only the curves P256, P384, and P512 are supported.
func PubkeyParams ¶
func PubkeyParams(key *PublicKey) (*ECIESParams, error)
type PrivateKey ¶
PrivateKey is a representation of an elliptic curve private key.
func GenerateKey ¶
func GenerateKey(rand io.Reader, curve gost3410.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 *gost3410.PrivateKey) *PrivateKey
Import an ECDSA private key as an ECIES private key.
func (*PrivateKey) Decrypt ¶
func (prv *PrivateKey) Decrypt(c, s1, s2 []byte) (m []byte, err error)
Decrypt decrypts an ECIES ciphertext.
func (*PrivateKey) ExportECDSA ¶
func (prv *PrivateKey) ExportECDSA() *gost3410.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.