diff --git a/lib/src/double_ratchet.dart b/lib/src/double_ratchet.dart index 8a0c3e3..bb86e32 100644 --- a/lib/src/double_ratchet.dart +++ b/lib/src/double_ratchet.dart @@ -3,6 +3,7 @@ import 'package:meta/meta.dart'; import 'package:omemo_dart/protobuf/schema.pb.dart'; import 'package:omemo_dart/src/double_ratchet/crypto.dart'; import 'package:omemo_dart/src/double_ratchet/kdf.dart'; +import 'package:omemo_dart/src/errors.dart'; import 'package:omemo_dart/src/helpers.dart'; import 'package:omemo_dart/src/key.dart'; import 'package:omemo_dart/src/x3dh.dart'; @@ -142,8 +143,7 @@ class OmemoDoubleRatchet { Future skipMessageKeys(int until) async { if (nr + maxSkip < until) { - // TODO(PapaTutuWawa): Custom exception - throw Exception(); + throw SkippingTooManyMessagesException(); } if (ckr != null) { diff --git a/lib/src/errors.dart b/lib/src/errors.dart index 328cbe4..801f264 100644 --- a/lib/src/errors.dart +++ b/lib/src/errors.dart @@ -7,3 +7,9 @@ class InvalidSignatureException implements Exception { class InvalidMessageHMACException implements Exception { String errMsg() => 'The computed HMAC does not match the provided HMAC'; } + +/// Triggered by the Double Ratchet if skipping messages would cause skipping more than +/// MAXSKIP messages +class SkippingTooManyMessagesException implements Exception { + String errMsg() => 'Skipping messages would cause a skip bigger than MAXSKIP'; +}