π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob]Generate randomkey using crypto library
Neeraj Gupta944ef2e564c1
diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dartindex f4e9022efb..b870aa6472 100644--- a/auth/lib/services/user_service.dart+++ b/auth/lib/services/user_service.dart@@ -867,14 +867,11 @@ class UserService {return;}try {- final secretValue = type == TwoFactorType.passkey- ? utf8.decode(base64.decode(secret))- : secret;final response = await _dio.post(_config.getHttpEndpoint() + "/users/two-factor/remove",data: {"sessionID": sessionID,- "secret": secretValue,+ "secret": secret,"twoFactorType": twoFactorTypeToString(type),},);diff --git a/auth/lib/ui/settings/security_section_widget.dart b/auth/lib/ui/settings/security_section_widget.dartindex 5a4e6c464d..622c777236 100644--- a/auth/lib/ui/settings/security_section_widget.dart+++ b/auth/lib/ui/settings/security_section_widget.dart@@ -169,15 +169,14 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {await PasskeyService.instance.isPasskeyRecoveryEnabled();if (!isPassKeyResetEnabled) {final Uint8List recoveryKey = Configuration.instance.getRecoveryKey();- final resetSecret = const Uuid().v4().toString();- final bytes = utf8.encode(resetSecret);- final base64Str = base64.encode(bytes);+ final resetKey = CryptoUtil.generateKey();+ final resetKeyBase64 = CryptoUtil.bin2base64(resetKey);final encryptionResult = CryptoUtil.encryptSync(- CryptoUtil.base642bin(base64Str),+ resetKey,recoveryKey,);await PasskeyService.instance.configurePasskeyRecovery(- resetSecret,+ resetKeyBase64,CryptoUtil.bin2base64(encryptionResult.encryptedData!),CryptoUtil.bin2base64(encryptionResult.nonce!),);diff --git a/mobile/lib/services/user_service.dart b/mobile/lib/services/user_service.dartindex 3ad3e1b0f3..44e098567c 100644--- a/mobile/lib/services/user_service.dart+++ b/mobile/lib/services/user_service.dart@@ -912,14 +912,11 @@ class UserService {return;}try {- final secretValue = type == TwoFactorType.passkey- ? utf8.decode(base64.decode(secret))- : secret;final response = await _dio.post(_config.getHttpEndpoint() + "/users/two-factor/remove",data: {"sessionID": sessionID,- "secret": secretValue,+ "secret": secret,"twoFactorType": twoFactorTypeToString(type),},);diff --git a/mobile/lib/ui/settings/security_section_widget.dart b/mobile/lib/ui/settings/security_section_widget.dartindex 5099bc5d3c..88a198f4e1 100644--- a/mobile/lib/ui/settings/security_section_widget.dart+++ b/mobile/lib/ui/settings/security_section_widget.dart@@ -243,15 +243,14 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {if (!isPassKeyResetEnabled) {final Uint8List recoveryKey =await UserService.instance.getOrCreateRecoveryKey(context);- final resetSecret = const Uuid().v4().toString();- final bytes = utf8.encode(resetSecret);- final base64Str = base64.encode(bytes);+ final resetKey = CryptoUtil.generateKey();+ final resetKeyBase64 = CryptoUtil.bin2base64(resetKey);final encryptionResult = CryptoUtil.encryptSync(- CryptoUtil.base642bin(base64Str),+ resetKey,recoveryKey,);await PasskeyService.instance.configurePasskeyRecovery(- resetSecret,+ resetKeyBase64,CryptoUtil.bin2base64(encryptionResult.encryptedData!),CryptoUtil.bin2base64(encryptionResult.nonce!),);