Documentation ¶
Overview ¶
ECDH , inspired by go-ethereum
Index ¶
- Variables
- func CheckHMAC(h func() hash.Hash, message, messageMAC, key []byte) bool
- func GetDN(name pkix.Name) string
- func HashSha256(data []byte) []byte
- func HashSha512(data []byte) []byte
- func NewHMAC(h func() hash.Hash, message, key []byte) []byte
- func ParseCertPem(pemBytes []byte) *x509.Certificate
- type ECDSASignature
- type ECIESParams
- type ECPriv
- type ECPub
- type PKCS8
Constants ¶
This section is empty.
Variables ¶
var ( ECIES_AES128_SHA256 = ECIESParams{ Hash: sha256.New, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 16, // contains filtered or unexported fields } ECIES_AES256_SHA256 = ECIESParams{ Hash: sha256.New, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, // contains filtered or unexported fields } ECIES_AES256_SHA384 = ECIESParams{ Hash: sha512.New384, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, // contains filtered or unexported fields } ECIES_AES256_SHA512 = ECIESParams{ Hash: sha512.New, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, // contains filtered or unexported fields } )
var AttributeTypeNames = map[string]string{
"2.5.4.6": "C",
"2.5.4.10": "O",
"2.5.4.11": "OU",
"2.5.4.3": "CN",
"2.5.4.5": "SERIALNUMBER",
"2.5.4.7": "L",
"2.5.4.8": "ST",
"2.5.4.9": "STREET",
"2.5.4.17": "POSTALCODE",
}
Functions ¶
func GetDN ¶
Get the DN (distinguished name) associated with a pkix.Name. NOTE: This code is almost a direct copy of the String() function in https://go-review.googlesource.com/c/go/+/67270/1/src/crypto/x509/pkix/pkix.go#26 which returns a DN as defined by RFC 2253.
func HashSha256 ¶
func HashSha512 ¶
func ParseCertPem ¶
func ParseCertPem(pemBytes []byte) *x509.Certificate
Types ¶
type ECDSASignature ¶
func (ECDSASignature) Marshal ¶
func (t ECDSASignature) Marshal() []byte
func (ECDSASignature) Unmarshal ¶
func (ECDSASignature) Unmarshal(signature []byte) (ecdsaSignature ECDSASignature)
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.
func (ECIESParams) SymDecrypt ¶
func (params ECIESParams) SymDecrypt(key, cipherText []byte) (m []byte)
symDecrypt carries out CTR decryption using the block cipher specified in the parameters
func (ECIESParams) SymEncrypt ¶
func (params ECIESParams) SymEncrypt(rand io.Reader, key, m []byte) (cipherText []byte)
symEncrypt carries out CTR encryption using the block cipher specified in the parameters.
type ECPriv ¶
type ECPriv struct {
*ecdsa.PrivateKey
}
Used for both ECDSA and ECDH
func (ECPriv) GenerateShared ¶
ECDH key agreement method used to establish secret keys for encryption.