Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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") )
View Source
var ( ErrKeyDataTooLong = fmt.Errorf("ecies: can't supply requested key data") ErrInvalidMessage = fmt.Errorf("ecies: invalid message") )
View Source
var ( DefaultCurve = ethcrypto.S256() ErrUnsupportedECDHAlgorithm = fmt.Errorf("ecies: unsupported ECDH algorithm") ErrUnsupportedECIESParameters = fmt.Errorf("ecies: unsupported ECIES parameters") )
View Source
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使用第1节5.1中指定的ECIES对消息进行加密。
s1和s2包含不属于结果的共享信息 密文。s1被输入到键派生中,s2被输入到mac中。如果 未使用共享信息参数,它们应为零。
func MaxSharedKeyLength ¶
MaxSharedKeyLength返回共享密钥的最大长度 可以生成公钥。
Types ¶
type ECIESParams ¶
type ECIESParams struct { Hash func() hash.Hash //哈希函数 Cipher func([]byte) (cipher.Block, error) //对称加密 BlockSize int //对称密码的块大小 KeyLen int //对称密钥长度 // contains filtered or unexported fields }
func ParamsFromCurve ¶
func ParamsFromCurve(curve elliptic.Curve) (params *ECIESParams)
paramsfromcurve为选定的椭圆曲线选择最佳参数。 仅支持曲线P256、P38 4和P512。
type PrivateKey ¶
private key是椭圆曲线私钥的表示。
func GenerateKey ¶
func GenerateKey(rand io.Reader, curve elliptic.Curve, params *ECIESParams) (prv *PrivateKey, err error)
生成椭圆曲线公钥/私钥对。如果参数为零, the recommended default parameters for the key will be chosen.
func (*PrivateKey) Decrypt ¶
func (prv *PrivateKey) Decrypt(c, s1, s2 []byte) (m []byte, err error)
解密-解密特定的密文。
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密钥协议方法。
Click to show internal directories.
Click to hide internal directories.