subtle

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 12 Imported by: 22

Documentation

Overview

Package subtle provides subtle implementations of the Hybrid Encryption primitive.

Index

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 GetCurve

func GetCurve(c string) (elliptic.Curve, error)

GetCurve returns the elliptic.Curve for a given standard curve name.

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:

func PointEncode added in v1.5.0

func PointEncode(c elliptic.Curve, pFormat string, pt ECPoint) ([]byte, error)

PointEncode encodes a point into the format specified.

func SerializePrimaryPublicKey added in v1.7.0

func SerializePrimaryPublicKey(handle *keyset.Handle, template *tinkpb.KeyTemplate) ([]byte, error)

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:

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

type ECPoint struct {
	X, Y *big.Int
}

ECPoint represents a point on the elliptic curve.

func PointDecode added in v1.5.0

func PointDecode(c elliptic.Curve, pFormat string, e []byte) (*ECPoint, error)

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

type ECPublicKey struct {
	elliptic.Curve
	Point ECPoint
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL