Documentation ¶
Overview ¶
Package verificationhelper provides a helper for the interactive verification process according to Section 11.12.2 of the Spec.
Index ¶
- Variables
- func BrokenB64Encode(input []byte) stringdeprecated
- type QRCode
- type QRCodeMode
- type RequiredCallbacks
- type VerificationHelper
- func (vh *VerificationHelper) AcceptVerification(ctx context.Context, txnID id.VerificationTransactionID) error
- func (vh *VerificationHelper) CancelVerification(ctx context.Context, txnID id.VerificationTransactionID, ...) error
- func (vh *VerificationHelper) ConfirmQRCodeScanned(ctx context.Context, txnID id.VerificationTransactionID) error
- func (vh *VerificationHelper) ConfirmSAS(ctx context.Context, txnID id.VerificationTransactionID) error
- func (vh *VerificationHelper) HandleScannedQRData(ctx context.Context, data []byte) error
- func (vh *VerificationHelper) Init(ctx context.Context) error
- func (vh *VerificationHelper) StartInRoomVerification(ctx context.Context, roomID id.RoomID, to id.UserID) (id.VerificationTransactionID, error)
- func (vh *VerificationHelper) StartSAS(ctx context.Context, txnID id.VerificationTransactionID) error
- func (vh *VerificationHelper) StartVerification(ctx context.Context, to id.UserID) (id.VerificationTransactionID, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BrokenB64Encode
deprecated
BrokenB64Encode implements the incorrect base64 serialization in libolm for the hkdf-hmac-sha256 MAC method. The bug is caused by the input and output buffers being equal to one another during the base64 encoding.
This function is narrowly scoped to this specific bug, and does not work generally (it only supports if the input is 32-bytes).
See https://github.com/matrix-org/matrix-spec-proposals/pull/3783 and https://gitlab.matrix.org/matrix-org/olm/-/merge_requests/16 for details.
Deprecated: never use this. It is only here for compatibility with the broken libolm implementation.
Types ¶
type QRCode ¶
type QRCode struct { Mode QRCodeMode TransactionID id.VerificationTransactionID Key1, Key2 [32]byte }
func NewQRCode ¶
func NewQRCode(mode QRCodeMode, txnID id.VerificationTransactionID, key1, key2 [32]byte) *QRCode
func NewQRCodeFromBytes ¶
NewQRCodeFromBytes parses the bytes from a QR code scan as defined in Section 11.12.2.4.1 of the Spec.
func (*QRCode) Bytes ¶
Bytes returns the bytes that need to be encoded in the QR code as defined in Section 11.12.2.4.1 of the Spec.
type QRCodeMode ¶
type QRCodeMode byte
const ( QRCodeModeCrossSigning QRCodeMode = 0x00 QRCodeModeSelfVerifyingMasterKeyTrusted QRCodeMode = 0x01 QRCodeModeSelfVerifyingMasterKeyUntrusted QRCodeMode = 0x02 )
type RequiredCallbacks ¶
type RequiredCallbacks interface { // VerificationRequested is called when a verification request is received // from another device. VerificationRequested(ctx context.Context, txnID id.VerificationTransactionID, from id.UserID) // VerificationCancelled is called when the verification is cancelled. VerificationCancelled(ctx context.Context, txnID id.VerificationTransactionID, code event.VerificationCancelCode, reason string) // VerificationDone is called when the verification is done. VerificationDone(ctx context.Context, txnID id.VerificationTransactionID) }
RequiredCallbacks is an interface representing the callbacks required for the VerificationHelper.
type VerificationHelper ¶
type VerificationHelper struct {
// contains filtered or unexported fields
}
func NewVerificationHelper ¶
func NewVerificationHelper(client *mautrix.Client, mach *crypto.OlmMachine, callbacks any, supportsScan bool) *VerificationHelper
func (*VerificationHelper) AcceptVerification ¶
func (vh *VerificationHelper) AcceptVerification(ctx context.Context, txnID id.VerificationTransactionID) error
AcceptVerification accepts a verification request. The transaction ID should be the transaction ID of a verification request that was received via the VerificationRequested callback in RequiredCallbacks.
func (*VerificationHelper) CancelVerification ¶
func (vh *VerificationHelper) CancelVerification(ctx context.Context, txnID id.VerificationTransactionID, code event.VerificationCancelCode, reason string) error
CancelVerification cancels a verification request. The transaction ID should be the transaction ID of a verification request that was received via the VerificationRequested callback in RequiredCallbacks.
func (*VerificationHelper) ConfirmQRCodeScanned ¶
func (vh *VerificationHelper) ConfirmQRCodeScanned(ctx context.Context, txnID id.VerificationTransactionID) error
ConfirmQRCodeScanned confirms that our QR code has been scanned and sends the m.key.verification.done event to the other device.
func (*VerificationHelper) ConfirmSAS ¶
func (vh *VerificationHelper) ConfirmSAS(ctx context.Context, txnID id.VerificationTransactionID) error
ConfirmSAS indicates that the user has confirmed that the SAS matches SAS shown on the other user's device.
func (*VerificationHelper) HandleScannedQRData ¶
func (vh *VerificationHelper) HandleScannedQRData(ctx context.Context, data []byte) error
HandleScannedQRData verifies the keys from a scanned QR code and if successful, sends the m.key.verification.start event and m.key.verification.done event.
func (*VerificationHelper) Init ¶
func (vh *VerificationHelper) Init(ctx context.Context) error
Init initializes the verification helper by adding the necessary event handlers to the syncer.
func (*VerificationHelper) StartInRoomVerification ¶
func (vh *VerificationHelper) StartInRoomVerification(ctx context.Context, roomID id.RoomID, to id.UserID) (id.VerificationTransactionID, error)
StartVerification starts an interactive verification flow with the given user in the given room.
func (*VerificationHelper) StartSAS ¶
func (vh *VerificationHelper) StartSAS(ctx context.Context, txnID id.VerificationTransactionID) error
StartSAS starts a SAS verification flow. The transaction ID should be the transaction ID of a verification request that was received via the VerificationRequested callback in RequiredCallbacks.
func (*VerificationHelper) StartVerification ¶
func (vh *VerificationHelper) StartVerification(ctx context.Context, to id.UserID) (id.VerificationTransactionID, error)
StartVerification starts an interactive verification flow with the given user via a to-device event.