backup

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMAC = errors.New("invalid MAC")

Functions

This section is empty.

Types

type EncryptedSessionData

type EncryptedSessionData[T any] struct {
	Ciphertext jsonbytes.UnpaddedBytes `json:"ciphertext"`
	Ephemeral  EphemeralKey            `json:"ephemeral"`
	MAC        jsonbytes.UnpaddedBytes `json:"mac"`
}

EncryptedSessionData is the encrypted session_data field of a key backup as defined in Section 11.12.3.2.2 of the Spec.

The type parameter T represents the format of the session data contained in the encrypted payload.

func EncryptSessionData

func EncryptSessionData[T any](backupKey *MegolmBackupKey, sessionData T) (*EncryptedSessionData[T], error)

EncryptSessionData encrypts the given session data with the given recovery key as defined in Section 11.12.3.2.2 of the Spec.

func (*EncryptedSessionData[T]) Decrypt

func (esd *EncryptedSessionData[T]) Decrypt(backupKey *MegolmBackupKey) (*T, error)

Decrypt decrypts the EncryptedSessionData into a *T using the recovery key by reversing the process described in Section 11.12.3.2.2 of the Spec.

type EphemeralKey

type EphemeralKey struct {
	*ecdh.PublicKey
}

EphemeralKey is a wrapper around an ECDH X25519 public key that implements JSON marshalling and unmarshalling.

func (*EphemeralKey) MarshalJSON

func (k *EphemeralKey) MarshalJSON() ([]byte, error)

func (*EphemeralKey) UnmarshalJSON

func (k *EphemeralKey) UnmarshalJSON(data []byte) error

type MegolmAuthData

type MegolmAuthData struct {
	PublicKey  id.Ed25519            `json:"public_key"`
	Signatures signatures.Signatures `json:"signatures"`
}

MegolmAuthData is the auth_data when the key backup is created with the id.KeyBackupAlgorithmMegolmBackupV1 algorithm as defined in Section 11.12.3.2.2 of the Spec.

type MegolmBackupKey

type MegolmBackupKey struct {
	*ecdh.PrivateKey
}

MegolmBackupKey is a wrapper around an ECDH X25519 private key that is used to decrypt a megolm key backup.

func MegolmBackupKeyFromBytes

func MegolmBackupKeyFromBytes(bytes []byte) (*MegolmBackupKey, error)

func NewMegolmBackupKey

func NewMegolmBackupKey() (*MegolmBackupKey, error)

type MegolmSessionData

type MegolmSessionData struct {
	Algorithm          id.Algorithm      `json:"algorithm"`
	ForwardingKeyChain []string          `json:"forwarding_curve25519_key_chain"`
	SenderClaimedKeys  SenderClaimedKeys `json:"sender_claimed_keys"`
	SenderKey          id.SenderKey      `json:"sender_key"`
	SessionKey         string            `json:"session_key"`
}

MegolmSessionData is the decrypted session_data when the key backup is created with the id.KeyBackupAlgorithmMegolmBackupV1 algorithm as defined in Section 11.12.3.2.2 of the Spec.

type SenderClaimedKeys

type SenderClaimedKeys struct {
	Ed25519 id.Ed25519 `json:"ed25519"`
}

Jump to

Keyboard shortcuts

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