diff --git a/CASA/gui/MiCasa.cs b/CASA/gui/MiCasa.cs index 9abb3b36..79a6f95e 100644 --- a/CASA/gui/MiCasa.cs +++ b/CASA/gui/MiCasa.cs @@ -1435,6 +1435,8 @@ public class MiCasa : Store SecretStore ss = GetMiCasaStore(); Secret secret = ss.GetSecret(entrySecretID.Text); value = secret.GetKeyValue(selected); + + // strip of header data byte[] baValue = System.Text.Encoding.ASCII.GetBytes(value); @@ -1458,8 +1460,19 @@ public class MiCasa : Store Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogDecode", null); gxmlTemp.Autoconnect(this); - // display values - textviewClear.Buffer.Text = value; + // display decoded value + //textviewClear.Buffer.Text = value; + char[] array = value.ToCharArray(); + + try + { + byte[] bytes = Convert.FromBase64CharArray(array, 0, array.Length); + textviewClear.Buffer.Text = System.Text.Encoding.ASCII.GetString(bytes); + } + catch (Exception e) + { + textviewClear.Buffer.Text = e.ToString(); + } // hook up button handlers bttnDecode.Clicked += new EventHandler(bttnDecode_Clicked); diff --git a/CASA/micasad/cache/KeyValue.cs b/CASA/micasad/cache/KeyValue.cs index ac860a9a..9476ffc2 100644 --- a/CASA/micasad/cache/KeyValue.cs +++ b/CASA/micasad/cache/KeyValue.cs @@ -78,7 +78,7 @@ namespace sscs.cache // this sets binary values public void SetValue(byte[] baValue) { - m_iValueType = VALUE_TYPE_BINARY; + m_iValueType = VALUE_TYPE_BINARY; m_value = EncryptValue(baValue); m_modified = DateTime.Now; } @@ -192,8 +192,9 @@ namespace sscs.cache private string DecryptValue() { - byte[] baValueClear = DecyptValueAsBytes(); + byte[] baValueClear = DecyptValueAsBytes(); return Encoding.Default.GetString(baValueClear); + //return Encoding.Default.GetString(baValueClear); } private byte[] DecyptValueAsBytes() @@ -215,7 +216,12 @@ namespace sscs.cache public int GetValueType() { return m_iValueType; - } + } + + internal void SetValueType(int iValueType) + { + m_iValueType = iValueType; + } public string ToXML() { diff --git a/CASA/micasad/cache/Secret.cs b/CASA/micasad/cache/Secret.cs index 3ceb48e3..9ab66451 100644 --- a/CASA/micasad/cache/Secret.cs +++ b/CASA/micasad/cache/Secret.cs @@ -169,10 +169,10 @@ namespace sscs.cache sb.Append(kv.Key); sb.Append("="); - if (kv.GetValueType() ==(KeyValue.VALUE_TYPE_BINARY)) - sb.Append("BINARY - Do not change"); - else - sb.Append(kv.GetValue()); + //if (kv.GetValueType() ==(KeyValue.VALUE_TYPE_BINARY)) + // sb.Append("BINARY - Do not change"); + //else + sb.Append(kv.GetValue()); sb.Append('\n'); } //sb.Append('\0'); diff --git a/CASA/micasad/common/Constants.cs b/CASA/micasad/common/Constants.cs index 6cc73a03..405cb271 100644 --- a/CASA/micasad/common/Constants.cs +++ b/CASA/micasad/common/Constants.cs @@ -155,7 +155,8 @@ namespace sscs.constants internal static string miCASANode = "miCASA"; internal static string versionAttr = "version"; internal static string keyChainNode = "KeyChain"; - internal static string idAttr = "id"; + internal static string idAttr = "id"; + internal static string binaryAttr = "binary"; internal static string secretNode = "Secret"; internal static string valueNode = "Value"; internal static string timeNode = "Time"; diff --git a/CASA/micasad/lss/LocalStorage.cs b/CASA/micasad/lss/LocalStorage.cs index 81da6d2e..326614d1 100644 --- a/CASA/micasad/lss/LocalStorage.cs +++ b/CASA/micasad/lss/LocalStorage.cs @@ -478,19 +478,39 @@ namespace sscs.lss { attrColl = keyNode.Attributes; string key; + string sIsBinary = ""; try { key = (attrColl[XmlConsts.idAttr]).Value; + } catch (Exception) { // LinkedKey node, continue continue; } + + // get binary attribute, if set + try + { + sIsBinary = attrColl.GetNamedItem(XmlConsts.binaryAttr).Value; + } + catch + { + sIsBinary = "false"; + } + xpath = "descendant::" + XmlConsts.keyValueNode; XmlNode keyValNode = keyNode.SelectSingleNode(xpath); string keyValue = keyValNode.InnerText; - secret.SetKeyValue(key, keyValue, false); + secret.SetKeyValue(key, keyValue, false); + + // set binary type if set + if ((sIsBinary != null) && (sIsBinary.Equals("true"))) + { + KeyValue kv = secret.GetKeyValue(key); + kv.SetValueType(KeyValue.VALUE_TYPE_BINARY); + } // get time attributes on this key/value XmlNode timeNodeKey = keyNode.SelectSingleNode("descendant::" + XmlConsts.timeNode); @@ -766,9 +786,16 @@ namespace sscs.lss while (etor.MoveNext()) { string sKey = (string)etor.Key; - string value = secret.GetKeyValue(sKey).GetValue(); + KeyValue kv = secret.GetKeyValue(sKey); + + string value = kv.GetValue(); writer.WriteStartElement(XmlConsts.keyNode); writer.WriteAttributeString(XmlConsts.idAttr, sKey); + if (kv.GetValueType() == KeyValue.VALUE_TYPE_BINARY) + { + writer.WriteAttributeString(XmlConsts.binaryAttr, "true"); + } + writer.WriteStartElement(XmlConsts.keyValueNode); if (bSaveValues)