π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove direct dependency on Sodium to make reviews easier
vishnukvmd4ecf4bcf8787
diff --git a/lib/services/entity_service.dart b/lib/services/entity_service.dartindex a89b44f582..8558593034 100644--- a/lib/services/entity_service.dart+++ b/lib/services/entity_service.dart@@ -3,7 +3,6 @@ import 'dart:convert';import 'dart:math';import 'package:flutter/foundation.dart';-import 'package:flutter_sodium/flutter_sodium.dart';import 'package:logging/logging.dart';import "package:photos/core/configuration.dart";import "package:photos/core/network/network.dart";@@ -62,8 +61,8 @@ class EntityService {key,);final String encryptedData =- Sodium.bin2base64(encryptedKeyData.encryptedData!);- final String header = Sodium.bin2base64(encryptedKeyData.header!);+ CryptoUtil.bin2base64(encryptedKeyData.encryptedData!);+ final String header = CryptoUtil.bin2base64(encryptedKeyData.header!);debugPrint("Adding entity of type: " + type.typeToString());final EntityData data = id == null? await _gateway.createEntity(type, encryptedData, header)@@ -121,9 +120,9 @@ class EntityService {for (EntityData e in result) {try {final decryptedValue = await CryptoUtil.decryptChaCha(- Sodium.base642bin(e.encryptedData!),+ CryptoUtil.base642bin(e.encryptedData!),entityKey,- Sodium.base642bin(e.header!),+ CryptoUtil.base642bin(e.header!),);final String plainText = utf8.decode(decryptedValue);entities.add(@@ -166,17 +165,17 @@ class EntityService {_prefs.setString(_getEntityHeaderPrefix(type), header);}final entityKey = CryptoUtil.decryptSync(- Sodium.base642bin(encryptedKey),+ CryptoUtil.base642bin(encryptedKey),_config.getKey()!,- Sodium.base642bin(header),+ CryptoUtil.base642bin(header),);return entityKey;} on EntityKeyNotFound {_logger.info("EntityKeyNotFound generating key for type $type");final key = CryptoUtil.generateKey();final encryptedKeyData = CryptoUtil.encryptSync(key, _config.getKey()!);- encryptedKey = Sodium.bin2base64(encryptedKeyData.encryptedData!);- header = Sodium.bin2base64(encryptedKeyData.nonce!);+ encryptedKey = CryptoUtil.bin2base64(encryptedKeyData.encryptedData!);+ header = CryptoUtil.bin2base64(encryptedKeyData.nonce!);await _gateway.createKey(type, encryptedKey, header);await _prefs.setString(_getEntityKeyPrefix(type), encryptedKey);await _prefs.setString(_getEntityHeaderPrefix(type), header);diff --git a/lib/ui/account/request_pwd_verification_page.dart b/lib/ui/account/request_pwd_verification_page.dartindex 0c6a6cec66..b8d490a2d9 100644--- a/lib/ui/account/request_pwd_verification_page.dart+++ b/lib/ui/account/request_pwd_verification_page.dart@@ -2,7 +2,6 @@ import "dart:convert";import "dart:typed_data";import 'package:flutter/material.dart';-import "package:flutter_sodium/flutter_sodium.dart";import "package:logging/logging.dart";import 'package:photos/core/configuration.dart';import "package:photos/l10n/l10n.dart";@@ -90,14 +89,14 @@ class _RequestPasswordVerificationPageStatefinal attributes = Configuration.instance.getKeyAttributes()!;final Uint8List keyEncryptionKey = await CryptoUtil.deriveKey(utf8.encode(_passwordController.text) as Uint8List,- Sodium.base642bin(attributes.kekSalt),+ CryptoUtil.base642bin(attributes.kekSalt),attributes.memLimit!,attributes.opsLimit!,);CryptoUtil.decryptSync(- Sodium.base642bin(attributes.encryptedKey),+ CryptoUtil.base642bin(attributes.encryptedKey),keyEncryptionKey,- Sodium.base642bin(attributes.keyDecryptionNonce),+ CryptoUtil.base642bin(attributes.keyDecryptionNonce),);dialog.show();// pop