package subtle
import "github.com/google/tink/go/hybrid/subtle"
Package subtle provides subtle implementations of the Hybrid Encryption primitive.
Index ¶
- func ComputeSharedSecret(pub *ECPoint, priv *ECPrivateKey) ([]byte, error)
- func GetCurve(c string) (elliptic.Curve, error)
- func KeysetHandleFromSerializedPublicKey(pubKeyBytes []byte, template *tinkpb.KeyTemplate) (*keyset.Handle, error)
- func PointEncode(c elliptic.Curve, pFormat string, pt ECPoint) ([]byte, error)
- func SerializePrimaryPublicKey(handle *keyset.Handle, template *tinkpb.KeyTemplate) ([]byte, error)
- type ECIESAEADHKDFHybridDecrypt
- func NewECIESAEADHKDFHybridDecrypt(pvt *ECPrivateKey, hkdfSalt []byte, hkdfHMACAlgo string, ptFormat string, demHelper EciesAEADHKDFDEMHelper) (*ECIESAEADHKDFHybridDecrypt, error)
- func (e *ECIESAEADHKDFHybridDecrypt) Decrypt(ciphertext, contextInfo []byte) ([]byte, error)
- type ECIESAEADHKDFHybridEncrypt
- func NewECIESAEADHKDFHybridEncrypt(pub *ECPublicKey, hkdfSalt []byte, hkdfHMACAlgo string, ptFormat string, demHelper EciesAEADHKDFDEMHelper) (*ECIESAEADHKDFHybridEncrypt, error)
- func (e *ECIESAEADHKDFHybridEncrypt) Encrypt(plaintext, contextInfo []byte) ([]byte, error)
- type ECIESHKDFRecipientKem
- type ECIESHKDFSenderKem
- type ECPoint
- type ECPrivateKey
- func GenerateECDHKeyPair(c elliptic.Curve) (*ECPrivateKey, error)
- func GetECPrivateKey(c elliptic.Curve, b []byte) *ECPrivateKey
- type ECPublicKey
- type EciesAEADHKDFDEMHelper
- type KEMKey
Functions ¶
func ComputeSharedSecret ¶
func ComputeSharedSecret(pub *ECPoint, priv *ECPrivateKey) ([]byte, error)
ComputeSharedSecret is used to compute a shared secret using given private key and peer public key.
func GetCurve ¶
GetCurve returns the elliptic.Curve for a given standard curve name.
func KeysetHandleFromSerializedPublicKey ¶
func KeysetHandleFromSerializedPublicKey(pubKeyBytes []byte, template *tinkpb.KeyTemplate) (*keyset.Handle, error)
KeysetHandleFromSerializedPublicKey returns a keyset handle containing a primary key that has the specified pubKeyBytes and matches template.
Supported templates are the same as PublicKeyFromPrimaryKey's:
- DHKEM_X25519_HKDF_SHA256_HKDF_SHA256_CHACHA20_POLY1305_Raw_Key_Template, which requires pubKeyBytes to be the KEM-encoding of the public key, i.e. SerializePublicKey in https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1.1.
func PointEncode ¶
PointEncode encodes a point into the format specified.
func SerializePrimaryPublicKey ¶
SerializePrimaryPublicKey serializes a public keyset handle's primary key if the primary key is a public key and matches both the template argument and a supported template.
Supported templates are the same as KeysetHandleFromSerializedPublicKey's:
- DHKEM_X25519_HKDF_SHA256_HKDF_SHA256_CHACHA20_POLY1305_Raw_Key_Template, which returns the KEM-encoding of the public key, i.e. SerializePublicKey in https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1.1.
Types ¶
type ECIESAEADHKDFHybridDecrypt ¶
type ECIESAEADHKDFHybridDecrypt struct {
// contains filtered or unexported fields
}
ECIESAEADHKDFHybridDecrypt is an instance of ECIES decryption with HKDF-KEM (key encapsulation mechanism) and AEAD-DEM (data encapsulation mechanism).
func NewECIESAEADHKDFHybridDecrypt ¶
func NewECIESAEADHKDFHybridDecrypt(pvt *ECPrivateKey, hkdfSalt []byte, hkdfHMACAlgo string, ptFormat string, demHelper EciesAEADHKDFDEMHelper) (*ECIESAEADHKDFHybridDecrypt, error)
NewECIESAEADHKDFHybridDecrypt returns ECIES decryption construct with HKDF-KEM (key encapsulation mechanism) and AEAD-DEM (data encapsulation mechanism).
func (*ECIESAEADHKDFHybridDecrypt) Decrypt ¶
func (e *ECIESAEADHKDFHybridDecrypt) Decrypt(ciphertext, contextInfo []byte) ([]byte, error)
Decrypt is used to decrypt using ECIES with a HKDF-KEM and AEAD-DEM mechanisms.
type ECIESAEADHKDFHybridEncrypt ¶
type ECIESAEADHKDFHybridEncrypt struct {
// contains filtered or unexported fields
}
ECIESAEADHKDFHybridEncrypt is an instance of ECIES encryption with HKDF-KEM (key encapsulation mechanism) and AEAD-DEM (data encapsulation mechanism).
func NewECIESAEADHKDFHybridEncrypt ¶
func NewECIESAEADHKDFHybridEncrypt(pub *ECPublicKey, hkdfSalt []byte, hkdfHMACAlgo string, ptFormat string, demHelper EciesAEADHKDFDEMHelper) (*ECIESAEADHKDFHybridEncrypt, error)
NewECIESAEADHKDFHybridEncrypt returns ECIES encryption construct with HKDF-KEM (key encapsulation mechanism) and AEAD-DEM (data encapsulation mechanism).
func (*ECIESAEADHKDFHybridEncrypt) Encrypt ¶
func (e *ECIESAEADHKDFHybridEncrypt) Encrypt(plaintext, contextInfo []byte) ([]byte, error)
Encrypt is used to encrypt using ECIES with a HKDF-KEM and AEAD-DEM mechanisms.
type ECIESHKDFRecipientKem ¶
type ECIESHKDFRecipientKem struct {
// contains filtered or unexported fields
}
ECIESHKDFRecipientKem represents a HKDF-based KEM (key encapsulation mechanism) for ECIES recipient.
type ECIESHKDFSenderKem ¶
type ECIESHKDFSenderKem struct {
// contains filtered or unexported fields
}
ECIESHKDFSenderKem represents HKDF-based ECIES-KEM (key encapsulation mechanism) for ECIES sender.
type ECPoint ¶
ECPoint represents a point on the elliptic curve.
func PointDecode ¶
PointDecode decodes a encoded point to return an ECPoint
type ECPrivateKey ¶
type ECPrivateKey struct { PublicKey ECPublicKey D *big.Int }
ECPrivateKey represents a elliptic curve private key.
func GenerateECDHKeyPair ¶
func GenerateECDHKeyPair(c elliptic.Curve) (*ECPrivateKey, error)
GenerateECDHKeyPair will create a new private key for a given curve.
func GetECPrivateKey ¶
func GetECPrivateKey(c elliptic.Curve, b []byte) *ECPrivateKey
GetECPrivateKey converts a stored private key to ECPrivateKey.
type ECPublicKey ¶
ECPublicKey represents a elliptic curve public key.
type EciesAEADHKDFDEMHelper ¶
type EciesAEADHKDFDEMHelper interface { // GetSymmetricKeySize gives the size of the DEM-key in bytes GetSymmetricKeySize() uint32 // GetAEADOrDAEAD returns the newly created AEAD or Deterministic Aead primitive. GetAEADOrDAEAD(symmetricKeyValue []byte) (interface{}, error) }
EciesAEADHKDFDEMHelper a helper for DEM (data encapsulation mechanism) of ECIES-AEAD-HKDF.
type KEMKey ¶
type KEMKey struct { Kem, SymmetricKey []byte }
KEMKey represents a KEM managed key.
Source Files ¶
ecies_aead_hkdf_dem_helper.go ecies_aead_hkdf_hybrid_decrypt.go ecies_aead_hkdf_hybrid_encrypt.go ecies_hkdf_recipient_kem.go ecies_hkdf_sender_kem.go elliptic_curves.go public_key.go subtle.go
- Version
- v1.7.0 (latest)
- Published
- Aug 10, 2022
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 3 months ago –
Tools for package owners.