Exemplo n.º 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (string.IsNullOrEmpty(masterPassword))
            {
                return(null);
            }

            JObject profileObject = JObject.Load(reader);

            byte[] masterPasswordBytes = Encoding.UTF8.GetBytes(this.masterPassword);
            byte[] salt       = Convert.FromBase64String((string)profileObject["salt"]);
            int    iterations = (int)profileObject["iterations"];

            if (salt == null || salt.Length == 0)
            {
                return(null);
            }

            OPVault.KeyPair derivedKeys = OPVault.Crypto.DeriveKey(masterPasswordBytes, salt, iterations);

            foreach (JsonConverter converter in serializer.Converters)
            {
                if (converter is HashedKeyPairConverter)
                {
                    (converter as HashedKeyPairConverter).KeyPair = derivedKeys;
                }
            }

            Records.Profile profile = new Records.Profile();
            serializer.Populate(profileObject.CreateReader(), profile);

            return(profile);
        }
Exemplo n.º 2
0
 public OverviewOPDataConverter(OPVault.KeyPair keyPair)
 {
     this.keyPair = keyPair;
 }
Exemplo n.º 3
0
 public EncryptedKeyPairConverter(OPVault.KeyPair keyPair)
 {
     this.keyPair = keyPair;
 }