Documentation ¶
Overview ¶
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
- type ECIESAEADHKDFHybridEncrypt
- type ECIESHKDFRecipientKem
- type ECIESHKDFSenderKem
- type ECPoint
- type ECPrivateKey
- type ECPublicKey
- type EciesAEADHKDFDEMHelper
- type KEMKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 KeysetHandleFromSerializedPublicKey ¶ added in v1.7.0
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 ¶ added in v1.5.0
PointEncode encodes a point into the format specified.
func SerializePrimaryPublicKey ¶ added in v1.7.0
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).
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).
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 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.