refactor: algorithm types
This commit is contained in:
parent
2e3a2d38c0
commit
323b203718
|
|
@ -135,7 +135,7 @@ class Encryption {
|
|||
Map<String, dynamic> decryptedPayload;
|
||||
var canRequestSession = false;
|
||||
try {
|
||||
if (event.content['algorithm'] != 'm.megolm.v1.aes-sha2') {
|
||||
if (event.content['algorithm'] != AlgorithmTypes.megolmV1AesSha2) {
|
||||
throw (DecryptError.UNKNOWN_ALGORITHM);
|
||||
}
|
||||
final String sessionId = event.content['session_id'];
|
||||
|
|
@ -277,7 +277,7 @@ class Encryption {
|
|||
if (room == null || !room.encrypted || !enabled) {
|
||||
return payload;
|
||||
}
|
||||
if (room.encryptionAlgorithm != 'm.megolm.v1.aes-sha2') {
|
||||
if (room.encryptionAlgorithm != AlgorithmTypes.megolmV1AesSha2) {
|
||||
throw ('Unknown encryption algorithm');
|
||||
}
|
||||
if (keyManager.getOutboundGroupSession(roomId) == null) {
|
||||
|
|
@ -301,7 +301,7 @@ class Encryption {
|
|||
'room_id': roomId,
|
||||
};
|
||||
var encryptedPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'ciphertext':
|
||||
sess.outboundGroupSession.encrypt(json.encode(payloadContent)),
|
||||
'device_id': client.deviceID,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class KeyManager {
|
|||
}
|
||||
final oldSession =
|
||||
getInboundGroupSession(roomId, sessionId, senderKey, otherRooms: false);
|
||||
if (content['algorithm'] != 'm.megolm.v1.aes-sha2') {
|
||||
if (content['algorithm'] != AlgorithmTypes.megolmV1AesSha2) {
|
||||
return;
|
||||
}
|
||||
olm.InboundGroupSession inboundGroupSession;
|
||||
|
|
@ -344,7 +344,7 @@ class KeyManager {
|
|||
sess.sentMessages++;
|
||||
sess.devices = newDeviceKeyIds;
|
||||
final rawSession = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': room.id,
|
||||
'session_id': sess.outboundGroupSession.session_id(),
|
||||
'session_key': sess.outboundGroupSession.session_key(),
|
||||
|
|
@ -403,7 +403,7 @@ class KeyManager {
|
|||
return null;
|
||||
}
|
||||
final rawSession = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': room.id,
|
||||
'session_id': outboundGroupSession.session_id(),
|
||||
'session_key': outboundGroupSession.session_key(),
|
||||
|
|
@ -607,7 +607,7 @@ class KeyManager {
|
|||
{
|
||||
'action': 'request',
|
||||
'body': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': room.id,
|
||||
'sender_key': senderKey,
|
||||
'session_id': sessionId,
|
||||
|
|
@ -949,7 +949,7 @@ RoomKeys _generateUploadKeys(_GenerateUploadKeysArgs args) {
|
|||
}
|
||||
// generate the encrypted content
|
||||
final payload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'forwarding_curve25519_key_chain': sess.forwardingCurve25519KeyChain,
|
||||
'sender_key': sess.senderKey,
|
||||
'sender_clencaimed_keys': sess.senderClaimedKeys,
|
||||
|
|
|
|||
|
|
@ -177,8 +177,8 @@ class OlmManager {
|
|||
'user_id': client.userID,
|
||||
'device_id': client.deviceID,
|
||||
'algorithms': [
|
||||
'm.olm.v1.curve25519-aes-sha2',
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': <String, dynamic>{},
|
||||
},
|
||||
|
|
@ -251,7 +251,7 @@ class OlmManager {
|
|||
if (event.type != EventTypes.Encrypted) {
|
||||
return event;
|
||||
}
|
||||
if (event.content['algorithm'] != 'm.olm.v1.curve25519-aes-sha2') {
|
||||
if (event.content['algorithm'] != AlgorithmTypes.olmV1Curve25519AesSha2) {
|
||||
throw ('Unknown algorithm: ${event.content['algorithm']}');
|
||||
}
|
||||
if (!event.content['ciphertext'].containsKey(identityKey)) {
|
||||
|
|
@ -476,7 +476,7 @@ class OlmManager {
|
|||
final encryptResult = sess.first.session.encrypt(json.encode(fullPayload));
|
||||
storeOlmSession(sess.first);
|
||||
final encryptedBody = <String, dynamic>{
|
||||
'algorithm': 'm.olm.v1.curve25519-aes-sha2',
|
||||
'algorithm': AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
'sender_key': identityKey,
|
||||
'ciphertext': <String, dynamic>{},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class SSSS {
|
|||
|
||||
bool checkKey(Uint8List key, BasicEvent keyData) {
|
||||
final info = keyData.content;
|
||||
if (info['algorithm'] == 'm.secret_storage.v1.aes-hmac-sha2') {
|
||||
if (info['algorithm'] == AlgorithmTypes.secretStorageV1AesHmcSha2) {
|
||||
if ((info['mac'] is String) && (info['iv'] is String)) {
|
||||
final encrypted = encryptAes(ZERO_STR, key, '', info['iv']);
|
||||
return info['mac'].replaceAll(RegExp(r'=+$'), '') ==
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
library matrix_api;
|
||||
|
||||
export 'matrix_api/matrix_api.dart';
|
||||
export 'matrix_api/model/algorithm_types.dart';
|
||||
export 'matrix_api/model/basic_event.dart';
|
||||
export 'matrix_api/model/basic_event_with_sender.dart';
|
||||
export 'matrix_api/model/basic_room_event.dart';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class AlgorithmTypes {
|
||||
static const String olmV1Curve25519AesSha2 = 'm.olm.v1.curve25519-aes-sha2';
|
||||
static const String megolmV1AesSha2 = 'm.megolm.v1.aes-sha2';
|
||||
static const String secretStorageV1AesHmcSha2 =
|
||||
'm.secret_storage.v1.aes-hmac-sha2';
|
||||
static const String megolmBackupV1Curve25519AesSha2 =
|
||||
'm.megolm_backup.v1.curve25519-aes-sha2';
|
||||
}
|
||||
|
|
@ -16,13 +16,15 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../../matrix_api.dart';
|
||||
|
||||
enum RoomKeysAlgorithmType { v1Curve25519AesSha2 }
|
||||
|
||||
extension RoomKeysAlgorithmTypeExtension on RoomKeysAlgorithmType {
|
||||
String get algorithmString {
|
||||
switch (this) {
|
||||
case RoomKeysAlgorithmType.v1Curve25519AesSha2:
|
||||
return 'm.megolm_backup.v1.curve25519-aes-sha2';
|
||||
return AlgorithmTypes.megolmBackupV1Curve25519AesSha2;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
@ -30,7 +32,7 @@ extension RoomKeysAlgorithmTypeExtension on RoomKeysAlgorithmType {
|
|||
|
||||
static RoomKeysAlgorithmType fromAlgorithmString(String s) {
|
||||
switch (s) {
|
||||
case 'm.megolm_backup.v1.curve25519-aes-sha2':
|
||||
case AlgorithmTypes.megolmBackupV1Curve25519AesSha2:
|
||||
return RoomKeysAlgorithmType.v1Curve25519AesSha2;
|
||||
default:
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -523,10 +523,10 @@ class Client extends MatrixApi {
|
|||
'{"room":{"state":{"lazy_load_members":true}}}';
|
||||
static const String messagesFilters = '{"lazy_load_members":true}';
|
||||
static const List<String> supportedDirectEncryptionAlgorithms = [
|
||||
'm.olm.v1.curve25519-aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2
|
||||
];
|
||||
static const List<String> supportedGroupEncryptionAlgorithms = [
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
];
|
||||
static const int defaultThumbnailSize = 256;
|
||||
|
||||
|
|
|
|||
|
|
@ -357,7 +357,10 @@ void main() {
|
|||
var deviceKeys = DeviceKeys.fromJson({
|
||||
'user_id': '@alice:example.com',
|
||||
'device_id': 'JLAFKJWSCS',
|
||||
'algorithms': ['m.olm.v1.curve25519-aes-sha2', 'm.megolm.v1.aes-sha2'],
|
||||
'algorithms': [
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:JLAFKJWSCS': '3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI',
|
||||
'ed25519:JLAFKJWSCS': 'lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI'
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ void main() {
|
|||
var rawJson = <String, dynamic>{
|
||||
'user_id': '@alice:example.com',
|
||||
'device_id': 'JLAFKJWSCS',
|
||||
'algorithms': ['m.olm.v1.curve25519-aes-sha2', 'm.megolm.v1.aes-sha2'],
|
||||
'algorithms': [
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:JLAFKJWSCS':
|
||||
'3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI',
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void main() {
|
|||
'msgtype': 'm.text',
|
||||
'text': 'Hello foxies!',
|
||||
});
|
||||
expect(payload['algorithm'], 'm.megolm.v1.aes-sha2');
|
||||
expect(payload['algorithm'], AlgorithmTypes.megolmV1AesSha2);
|
||||
expect(payload['ciphertext'] is String, true);
|
||||
expect(payload['device_id'], client.deviceID);
|
||||
expect(payload['sender_key'], client.identityKey);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,10 @@ void main() {
|
|||
device = DeviceKeys.fromJson({
|
||||
'user_id': client.userID,
|
||||
'device_id': client.deviceID,
|
||||
'algorithms': ['m.olm.v1.curve25519-aes-sha2', 'm.megolm.v1.aes-sha2'],
|
||||
'algorithms': [
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:${client.deviceID}': client.identityKey,
|
||||
'ed25519:${client.deviceID}': client.fingerprintKey,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void main() {
|
|||
sender: '@alice:example.com',
|
||||
type: 'm.room_key',
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': validSessionId,
|
||||
'session_key': sessionKey,
|
||||
|
|
@ -79,7 +79,7 @@ void main() {
|
|||
sender: '@alice:example.com',
|
||||
type: 'm.room_key',
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': validSessionId,
|
||||
'session_key': sessionKey,
|
||||
|
|
@ -161,7 +161,10 @@ void main() {
|
|||
DeviceKeys.fromJson({
|
||||
'user_id': '@alice:example.com',
|
||||
'device_id': 'NEWDEVICE',
|
||||
'algorithms': ['m.olm.v1.curve25519-aes-sha2', 'm.megolm.v1.aes-sha2'],
|
||||
'algorithms': [
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:JLAFKJWSCS':
|
||||
'3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI',
|
||||
|
|
@ -212,7 +215,7 @@ void main() {
|
|||
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
|
||||
final sessionContent = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU',
|
||||
'session_key':
|
||||
|
|
@ -307,7 +310,7 @@ void main() {
|
|||
eventId: '12345',
|
||||
originServerTs: DateTime.now(),
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'ciphertext': session.encrypt(json.encode({
|
||||
'type': 'm.room.message',
|
||||
'content': {'msgtype': 'm.text', 'body': 'foxies'},
|
||||
|
|
@ -322,7 +325,7 @@ void main() {
|
|||
expect(room.lastEvent.type, 'm.room.encrypted');
|
||||
// set a payload...
|
||||
var sessionPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': roomId,
|
||||
'forwarding_curve25519_key_chain': [client.identityKey],
|
||||
'session_id': sessionId,
|
||||
|
|
@ -348,7 +351,7 @@ void main() {
|
|||
|
||||
// not set one with a higher first known index
|
||||
sessionPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': roomId,
|
||||
'forwarding_curve25519_key_chain': [client.identityKey],
|
||||
'session_id': sessionId,
|
||||
|
|
@ -374,7 +377,7 @@ void main() {
|
|||
|
||||
// set one with a lower first known index
|
||||
sessionPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': roomId,
|
||||
'forwarding_curve25519_key_chain': [client.identityKey],
|
||||
'session_id': sessionId,
|
||||
|
|
@ -400,7 +403,7 @@ void main() {
|
|||
|
||||
// not set one with a longer forwarding chain
|
||||
sessionPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': roomId,
|
||||
'forwarding_curve25519_key_chain': [client.identityKey, 'beep'],
|
||||
'session_id': sessionId,
|
||||
|
|
@ -426,7 +429,7 @@ void main() {
|
|||
|
||||
// set one with a shorter forwarding chain
|
||||
sessionPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': roomId,
|
||||
'forwarding_curve25519_key_chain': [],
|
||||
'session_id': sessionId,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void main() {
|
|||
content: {
|
||||
'action': 'request',
|
||||
'body': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'sender_key': validSenderKey,
|
||||
'session_id': validSessionId,
|
||||
|
|
@ -139,7 +139,7 @@ void main() {
|
|||
content: {
|
||||
'action': 'request',
|
||||
'body': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'sender_key': validSenderKey,
|
||||
'session_id': validSessionId,
|
||||
|
|
@ -161,7 +161,7 @@ void main() {
|
|||
content: {
|
||||
'action': 'request',
|
||||
'body': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'sender_key': validSenderKey,
|
||||
'session_id': validSessionId,
|
||||
|
|
@ -183,7 +183,7 @@ void main() {
|
|||
content: {
|
||||
'action': 'request',
|
||||
'body': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!invalid:example.com',
|
||||
'sender_key': validSenderKey,
|
||||
'session_id': validSessionId,
|
||||
|
|
@ -205,7 +205,7 @@ void main() {
|
|||
content: {
|
||||
'action': 'request',
|
||||
'body': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'sender_key': validSenderKey,
|
||||
'session_id': 'invalid',
|
||||
|
|
@ -239,7 +239,7 @@ void main() {
|
|||
sender: '@alice:example.com',
|
||||
type: 'm.forwarded_room_key',
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': validSessionId,
|
||||
'session_key': sessionKey,
|
||||
|
|
@ -264,7 +264,7 @@ void main() {
|
|||
sender: '@alice:example.com',
|
||||
type: 'm.forwarded_room_key',
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': validSessionId,
|
||||
'session_key': sessionKey,
|
||||
|
|
@ -290,7 +290,7 @@ void main() {
|
|||
sender: '@alice:example.com',
|
||||
type: 'm.forwarded_room_key',
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': validSessionId,
|
||||
'session_key': sessionKey,
|
||||
|
|
@ -316,7 +316,7 @@ void main() {
|
|||
sender: '@alice:example.com',
|
||||
type: 'm.forwarded_room_key',
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': '!726s6s6q:example.com',
|
||||
'session_id': validSessionId,
|
||||
'session_key': sessionKey,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ void main() {
|
|||
final sessionId = inbound.session_id();
|
||||
// set a payload...
|
||||
var sessionPayload = <String, dynamic>{
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'room_id': roomId,
|
||||
'forwarding_curve25519_key_chain': [client.identityKey],
|
||||
'session_id': sessionId,
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ void main() {
|
|||
'msgtype': 'm.bad.encrypted',
|
||||
'body': DecryptError.UNKNOWN_SESSION,
|
||||
'can_request_session': true,
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'ciphertext': 'AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...',
|
||||
'device_id': 'RJYKSTBOIE',
|
||||
'sender_key': 'IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA',
|
||||
|
|
@ -691,7 +691,7 @@ void main() {
|
|||
|
||||
event = Event.fromJson({
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'rotation_period_ms': 604800000,
|
||||
'rotation_period_msgs': 100
|
||||
},
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import 'dart:convert';
|
|||
import 'dart:core';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/testing.dart';
|
||||
|
||||
|
|
@ -198,7 +199,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'sender': '@alice:example.com',
|
||||
'type': 'm.room.encryption',
|
||||
'state_key': '',
|
||||
'content': {'algorithm': 'm.megolm.v1.aes-sha2'},
|
||||
'content': {'algorithm': AlgorithmTypes.megolmV1AesSha2},
|
||||
'origin_server_ts': 1417731086795,
|
||||
'event_id': '666972737430353:example.com'
|
||||
},
|
||||
|
|
@ -543,7 +544,7 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
'type': 'm.secret_storage.key.0FajDWYaM6wQ4O60OZnLvwZfsBNu4Bu3',
|
||||
'content': {
|
||||
'algorithm': 'm.secret_storage.v1.aes-hmac-sha2',
|
||||
'algorithm': AlgorithmTypes.secretStorageV1AesHmcSha2,
|
||||
'passphrase': {
|
||||
'algorithm': 'm.pbkdf2',
|
||||
'iterations': 500000,
|
||||
|
|
@ -620,7 +621,7 @@ class FakeMatrixApi extends MockClient {
|
|||
// {
|
||||
// 'sender': '@othertest:fakeServer.notExisting',
|
||||
// 'content': {
|
||||
// 'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
// 'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
// 'room_id': '!726s6s6q:example.com',
|
||||
// 'session_id': 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU',
|
||||
// 'session_key':
|
||||
|
|
@ -632,7 +633,7 @@ class FakeMatrixApi extends MockClient {
|
|||
// this is the commented out m.room_key event - only encrypted
|
||||
'sender': '@othertest:fakeServer.notExisting',
|
||||
'content': {
|
||||
'algorithm': 'm.olm.v1.curve25519-aes-sha2',
|
||||
'algorithm': AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
'sender_key': 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg',
|
||||
'ciphertext': {
|
||||
'7rvl3jORJkBiK4XX1e5TnGnqz068XfYJ0W++Ml63rgk': {
|
||||
|
|
@ -1551,7 +1552,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'event_fields': ['type', 'content', 'sender']
|
||||
},
|
||||
'/client/unstable/room_keys/version': (var req) => {
|
||||
'algorithm': 'm.megolm_backup.v1.curve25519-aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmBackupV1Curve25519AesSha2,
|
||||
'auth_data': {
|
||||
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
|
||||
'signatures': {},
|
||||
|
|
@ -1774,8 +1775,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'user_id': '@alice:example.com',
|
||||
'device_id': 'JLAFKJWSCS',
|
||||
'algorithms': [
|
||||
'm.olm.v1.curve25519-aes-sha2',
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:JLAFKJWSCS':
|
||||
|
|
@ -1795,8 +1796,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'user_id': '@alice:example.com',
|
||||
'device_id': 'OTHERDEVICE',
|
||||
'algorithms': [
|
||||
'm.olm.v1.curve25519-aes-sha2',
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:OTHERDEVICE': 'blah',
|
||||
|
|
@ -1810,8 +1811,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'user_id': '@test:fakeServer.notExisting',
|
||||
'device_id': 'GHTYAJCE',
|
||||
'algorithms': [
|
||||
'm.olm.v1.curve25519-aes-sha2',
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:GHTYAJCE':
|
||||
|
|
@ -1830,8 +1831,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'user_id': '@test:fakeServer.notExisting',
|
||||
'device_id': 'OTHERDEVICE',
|
||||
'algorithms': [
|
||||
'm.olm.v1.curve25519-aes-sha2',
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:OTHERDEVICE': 'blah',
|
||||
|
|
@ -1850,8 +1851,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'user_id': '@othertest:fakeServer.notExisting',
|
||||
'device_id': 'FOXDEVICE',
|
||||
'algorithms': [
|
||||
'm.olm.v1.curve25519-aes-sha2',
|
||||
'm.megolm.v1.aes-sha2'
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:FOXDEVICE':
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,10 @@ void main() {
|
|||
final key1 = MatrixDeviceKeys.fromJson({
|
||||
'user_id': '@alice:example.com',
|
||||
'device_id': 'JLAFKJWSCS',
|
||||
'algorithms': ['m.olm.v1.curve25519-aes-sha2', 'm.megolm.v1.aes-sha2'],
|
||||
'algorithms': [
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:JLAFKJWSCS':
|
||||
'3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI',
|
||||
|
|
@ -1175,7 +1178,10 @@ void main() {
|
|||
final key2 = MatrixDeviceKeys.fromJson({
|
||||
'user_id': '@alice:example.com',
|
||||
'device_id': 'JLAFKJWSCS',
|
||||
'algorithms': ['m.olm.v1.curve25519-aes-sha2', 'm.megolm.v1.aes-sha2'],
|
||||
'algorithms': [
|
||||
AlgorithmTypes.olmV1Curve25519AesSha2,
|
||||
AlgorithmTypes.megolmV1AesSha2
|
||||
],
|
||||
'keys': {
|
||||
'curve25519:JLAFKJWSCS':
|
||||
'3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI',
|
||||
|
|
|
|||
|
|
@ -516,14 +516,14 @@ void main() {
|
|||
eventId: '12345',
|
||||
originServerTs: DateTime.now(),
|
||||
content: {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||
'rotation_period_ms': 604800000,
|
||||
'rotation_period_msgs': 100
|
||||
},
|
||||
stateKey: ''),
|
||||
);
|
||||
expect(room.encrypted, true);
|
||||
expect(room.encryptionAlgorithm, 'm.megolm.v1.aes-sha2');
|
||||
expect(room.encryptionAlgorithm, AlgorithmTypes.megolmV1AesSha2);
|
||||
});
|
||||
|
||||
test('setPushRuleState', () async {
|
||||
|
|
|
|||
Loading…
Reference in New Issue