From 3829c6c11ba05623ec099ae7f1195b44411793ec Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sat, 17 Jun 2023 21:05:26 +0200 Subject: [PATCH] feat: Move all constants into their own file --- lib/src/common/constants.dart | 11 +++++++++++ lib/src/double_ratchet/double_ratchet.dart | 7 +------ lib/src/omemo/constants.dart | 2 -- lib/src/omemo/omemo.dart | 2 +- lib/src/x3dh/x3dh.dart | 4 +--- 5 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 lib/src/common/constants.dart delete mode 100644 lib/src/omemo/constants.dart diff --git a/lib/src/common/constants.dart b/lib/src/common/constants.dart new file mode 100644 index 0000000..8b0fcbd --- /dev/null +++ b/lib/src/common/constants.dart @@ -0,0 +1,11 @@ +/// The overarching assumption is that we use Ed25519 keys for the identity keys +const omemoX3DHInfoString = 'OMEMO X3DH'; + +/// The info used for when encrypting the AES key for the actual payload. +const omemoPayloadInfoString = 'OMEMO Payload'; + +/// Info string for ENCRYPT +const encryptHkdfInfoString = 'OMEMO Message Key Material'; + +/// Amount of messages we may skip per session +const maxSkip = 1000; diff --git a/lib/src/double_ratchet/double_ratchet.dart b/lib/src/double_ratchet/double_ratchet.dart index 9f33a1f..51a3954 100644 --- a/lib/src/double_ratchet/double_ratchet.dart +++ b/lib/src/double_ratchet/double_ratchet.dart @@ -1,6 +1,7 @@ import 'package:cryptography/cryptography.dart'; import 'package:hex/hex.dart'; import 'package:meta/meta.dart'; +import 'package:omemo_dart/src/common/constants.dart'; import 'package:omemo_dart/src/common/result.dart'; import 'package:omemo_dart/src/crypto.dart'; import 'package:omemo_dart/src/double_ratchet/kdf.dart'; @@ -9,12 +10,6 @@ import 'package:omemo_dart/src/helpers.dart'; import 'package:omemo_dart/src/keys.dart'; import 'package:omemo_dart/src/protobuf/schema.pb.dart'; -/// Amount of messages we may skip per session -const maxSkip = 1000; - -/// Info string for ENCRYPT -const encryptHkdfInfoString = 'OMEMO Message Key Material'; - @immutable class SkippedKey { const SkippedKey(this.dh, this.n); diff --git a/lib/src/omemo/constants.dart b/lib/src/omemo/constants.dart deleted file mode 100644 index 31e2fe6..0000000 --- a/lib/src/omemo/constants.dart +++ /dev/null @@ -1,2 +0,0 @@ -/// The info used for when encrypting the AES key for the actual payload. -const omemoPayloadInfoString = 'OMEMO Payload'; diff --git a/lib/src/omemo/omemo.dart b/lib/src/omemo/omemo.dart index 6e31cb8..627c0bb 100644 --- a/lib/src/omemo/omemo.dart +++ b/lib/src/omemo/omemo.dart @@ -4,6 +4,7 @@ import 'package:collection/collection.dart'; import 'package:cryptography/cryptography.dart'; import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; +import 'package:omemo_dart/src/common/constants.dart'; import 'package:omemo_dart/src/common/result.dart'; import 'package:omemo_dart/src/crypto.dart'; import 'package:omemo_dart/src/double_ratchet/double_ratchet.dart'; @@ -11,7 +12,6 @@ import 'package:omemo_dart/src/errors.dart'; import 'package:omemo_dart/src/helpers.dart'; import 'package:omemo_dart/src/keys.dart'; import 'package:omemo_dart/src/omemo/bundle.dart'; -import 'package:omemo_dart/src/omemo/constants.dart'; import 'package:omemo_dart/src/omemo/decryption_result.dart'; import 'package:omemo_dart/src/omemo/device.dart'; import 'package:omemo_dart/src/omemo/encrypted_key.dart'; diff --git a/lib/src/x3dh/x3dh.dart b/lib/src/x3dh/x3dh.dart index 1e82d01..f8b0d15 100644 --- a/lib/src/x3dh/x3dh.dart +++ b/lib/src/x3dh/x3dh.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:math'; import 'package:cryptography/cryptography.dart'; +import 'package:omemo_dart/src/common/constants.dart'; import 'package:omemo_dart/src/common/result.dart'; import 'package:omemo_dart/src/crypto.dart'; import 'package:omemo_dart/src/errors.dart'; @@ -8,9 +9,6 @@ import 'package:omemo_dart/src/helpers.dart'; import 'package:omemo_dart/src/keys.dart'; import 'package:omemo_dart/src/omemo/bundle.dart'; -/// The overarching assumption is that we use Ed25519 keys for the identity keys -const omemoX3DHInfoString = 'OMEMO X3DH'; - /// Performed by Alice class X3DHAliceResult { const X3DHAliceResult(this.ek, this.sk, this.opkId, this.ad);