فهرست منبع

Encrypt secretKey with the masterKey

Vishnu Mohandas 4 سال پیش
والد
کامیت
c698fd68fa
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      lib/core/configuration.dart

+ 2 - 2
lib/core/configuration.dart

@@ -66,7 +66,7 @@ class Configuration {
 
 
     // Generate a public-private keypair and encrypt the latter
     // Generate a public-private keypair and encrypt the latter
     final keyPair = await CryptoUtil.generateKeyPair();
     final keyPair = await CryptoUtil.generateKeyPair();
-    final encryptedSecretKeyData = CryptoUtil.encryptSync(keyPair.sk, kek);
+    final encryptedSecretKeyData = CryptoUtil.encryptSync(keyPair.sk, key);
 
 
     final attributes = KeyAttributes(
     final attributes = KeyAttributes(
       Sodium.bin2base64(kekSalt),
       Sodium.bin2base64(kekSalt),
@@ -97,7 +97,7 @@ class Configuration {
         Sodium.base642bin(attributes.keyDecryptionNonce));
         Sodium.base642bin(attributes.keyDecryptionNonce));
     final secretKey = CryptoUtil.decryptSync(
     final secretKey = CryptoUtil.decryptSync(
         Sodium.base642bin(attributes.encryptedSecretKey),
         Sodium.base642bin(attributes.encryptedSecretKey),
-        kek,
+        key,
         Sodium.base642bin(attributes.secretKeyDecryptionNonce));
         Sodium.base642bin(attributes.secretKeyDecryptionNonce));
     await setKey(Sodium.bin2base64(key));
     await setKey(Sodium.bin2base64(key));
     await setSecretKey(Sodium.bin2base64(secretKey));
     await setSecretKey(Sodium.bin2base64(secretKey));