internal void ReadProtectedBinaryEx(XmlNode xmlNode, ProtectedBinaryDictionary dictStorage) { ProcessNode(xmlNode); string strKey = string.Empty; XorredBuffer xbValue = null; byte[] pbValue = null; foreach (XmlNode xmlChild in xmlNode.ChildNodes) { if (xmlChild.Name == ElemKey) { ProcessNode(xmlChild); strKey = xmlChild.InnerText; } else if (xmlChild.Name == ElemValue) { xbValue = ProcessNode(xmlChild); if (xbValue == null) { string strInner = xmlChild.InnerText; if (strInner.Length > 0) { pbValue = Convert.FromBase64String(strInner); } else { pbValue = new byte[0]; } } } else { ReadUnknown(xmlChild); } } if (xbValue != null) { Debug.Assert(pbValue == null); dictStorage.Set(strKey, new ProtectedBinary(true, xbValue)); } else { Debug.Assert(pbValue != null); dictStorage.Set(strKey, new ProtectedBinary(false, pbValue)); } }
public void Save(ProtectedBinaryDictionary dict) { using (var sw = new StringWriter()) using (JsonWriter writer = new JsonTextWriter(sw)) { Serializer.Serialize(writer, this); var data = new ProtectedBinary(false, Encoding.Unicode.GetBytes(sw.ToString())); dict.Set(Namespace, data); } }
public static void SetKeeAgentSettings(this ProtectedBinaryDictionary binaries, EntrySettings settings) { // only save if there is an existing entry or AllowUseOfSshKey is checked // this way we don't pollute entries that don't have SSH keys if (binaries.Get(settingsBinaryId) != null || settings.AllowUseOfSshKey) { using (var writer = new StringWriter()) { EntrySettingsSerializer.Serialize(writer, settings); // string is protected just to make UI look cleaner binaries.Set(settingsBinaryId, new ProtectedBinary(false, Encoding.Unicode.GetBytes(writer.ToString()))); } } }
private void ReadProtectedBinaryEx(XmlNode xmlNode, ProtectedBinaryDictionary dictStorage) { ProcessNode(xmlNode); string strKey = string.Empty; XorredBuffer xbValue = null; byte[] pbValue = null; foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name == ElemKey) { ProcessNode(xmlChild); strKey = xmlChild.InnerText; } else if(xmlChild.Name == ElemValue) { xbValue = ProcessNode(xmlChild); if(xbValue == null) { string strInner = xmlChild.InnerText; if(strInner.Length > 0) pbValue = Convert.FromBase64String(strInner); else pbValue = new byte[0]; } } else ReadUnknown(xmlChild); } if(xbValue != null) { Debug.Assert(pbValue == null); dictStorage.Set(strKey, new ProtectedBinary(true, xbValue)); } else { Debug.Assert(pbValue != null); dictStorage.Set(strKey, new ProtectedBinary(false, pbValue)); } }
public void Add(NamedProtectedBinaryBuffer item) { mBinaryDictionary.Set(item.Name, item.ProtectedBinary); }