omemo_dart/lib/src/errors.dart

62 lines
2.7 KiB
Dart
Raw Normal View History

abstract class OmemoException {}
2022-08-03 14:41:33 +00:00
/// Triggered during X3DH if the signature if the SPK does verify to the actual SPK.
class InvalidSignatureException extends OmemoException implements Exception {
2023-06-12 17:20:43 +00:00
String errMsg() =>
'The signature of the SPK does not match the provided signature';
2022-08-02 13:40:26 +00:00
}
2023-06-12 17:20:43 +00:00
2022-08-04 12:01:50 +00:00
/// Triggered by the Double Ratchet if the computed HMAC does not match the attached HMAC.
/// Triggered by the Session Manager if the computed HMAC does not match the attached HMAC.
class InvalidMessageHMACException extends OmemoException implements Exception {
2022-08-03 14:41:33 +00:00
String errMsg() => 'The computed HMAC does not match the provided HMAC';
}
2022-08-03 14:44:18 +00:00
/// Triggered by the Double Ratchet if skipping messages would cause skipping more than
/// MAXSKIP messages
2023-06-12 17:20:43 +00:00
class SkippingTooManyMessagesException extends OmemoException
implements Exception {
2022-08-03 14:44:18 +00:00
String errMsg() => 'Skipping messages would cause a skip bigger than MAXSKIP';
}
2022-08-04 12:01:50 +00:00
/// Triggered by the Session Manager if the message key is not encrypted for the device.
2023-06-12 17:20:43 +00:00
class NotEncryptedForDeviceException extends OmemoException
implements Exception {
2022-08-04 12:01:50 +00:00
String errMsg() => 'Not encrypted for this device';
}
/// Triggered by the Session Manager when there is no key for decrypting the message.
class NoDecryptionKeyException extends OmemoException implements Exception {
2022-08-04 12:01:50 +00:00
String errMsg() => 'No key available for decrypting the message';
}
/// Triggered by the Session Manager when the identifier of the used Signed Prekey
/// is neither the current SPK's identifier nor the old one's.
class UnknownSignedPrekeyException extends OmemoException implements Exception {
String errMsg() => 'Unknown Signed Prekey used.';
}
/// Triggered by the Session Manager when the received Key Exchange message does not meet
/// the requirement that a key exchange, given that the ratchet already exists, must be
/// sent after its creation.
class InvalidKeyExchangeException extends OmemoException implements Exception {
String errMsg() => 'The key exchange was sent before the last kex finished';
}
/// Triggered by the Session Manager when a message's sequence number is smaller than we
/// expect it to be.
2023-06-12 17:20:43 +00:00
class MessageAlreadyDecryptedException extends OmemoException
implements Exception {
String errMsg() => 'The message has already been decrypted';
}
/// Triggered by the OmemoManager when we could not encrypt a message as we have
/// no key material available. That happens, for example, when we want to create a
/// ratchet session with a JID we had no session with but fetching the device bundle
/// failed.
2023-06-12 17:20:43 +00:00
class NoKeyMaterialAvailableException extends OmemoException
implements Exception {
String errMsg() =>
'No key material available to create a ratchet session with';
}