コード例 #1
0
ファイル: SecureStorage.cs プロジェクト: llenroc/Chiota
        public static void ValidatePassword(string password)
        {
            var passwordHash = UserDataEncryption.Hash(password);

            if (passwordHash != CrossSecureStorage.Current.GetValue(PasswordHash))
            {
                throw new InvalidUserInputException(new ExcInfo(), Details.AuthInvalidUserInputPassword);
            }
        }
コード例 #2
0
ファイル: SecureStorage.cs プロジェクト: llenroc/Chiota
        public static void UpdateUser(string password)
        {
            ValidatePassword(password);

            var encryptionSalt = CrossSecureStorage.Current.GetValue(EncryptionSalt);
            var serializedUser = JsonConvert.SerializeObject(UserService.CurrentUser);
            var encryptedUser  = UserDataEncryption.Encrypt(serializedUser, password, encryptionSalt);

            CrossSecureStorage.Current.SetValue(CurrentUser, encryptedUser);
        }
コード例 #3
0
ファイル: SecureStorage.cs プロジェクト: llenroc/Chiota
        public static async Task LoginUser(string password)
        {
            ValidatePassword(password);

            var encryptionSalt = CrossSecureStorage.Current.GetValue(EncryptionSalt);
            var encryptedUser  = CrossSecureStorage.Current.GetValue(CurrentUser);

            var decryptedUser = JsonConvert.DeserializeObject <User>(UserDataEncryption.Decrypt(encryptedUser, password, encryptionSalt));

            decryptedUser.TangleMessenger = new TangleMessenger(new Seed(decryptedUser.Seed));
            decryptedUser.NtruKeyPair     = new NtruKex(true).CreateAsymmetricKeyPair(decryptedUser.Seed.ToLower(), decryptedUser.PublicKeyAddress);

            UserService.SetCurrentUser(decryptedUser);

            await GetUser();
        }
コード例 #4
0
ファイル: SecureStorage.cs プロジェクト: llenroc/Chiota
        public static void StoreUser(User user, string password)
        {
            if (!user.StoreSeed)
            {
                return;
            }

            var passwordHash   = UserDataEncryption.Hash(password);
            var encryptionSalt = Seed.Random().Value;

            CrossSecureStorage.Current.SetValue(PasswordHash, passwordHash);
            CrossSecureStorage.Current.SetValue(EncryptionSalt, encryptionSalt);

            var serializedUser = JsonConvert.SerializeObject(user);
            var encryptedUser  = UserDataEncryption.Encrypt(serializedUser, password, encryptionSalt);

            CrossSecureStorage.Current.SetValue(CurrentUser, encryptedUser);
        }