Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.