Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET 4.0 DsaKeyValue required/optional parameter query for DSACryptoServiceProvider
    primarykey
    data
    text
    <p>Im kinda confused about the required/optional requirement for loading XML for a <code>DSACryptoServiceProvider</code>. </p> <p>From the <a href="http://www.w3.org/TR/xmldsig-core/" rel="nofollow">this</a> website, the following is the schema: Schema Definition:</p> <pre><code> &lt;element name="DSAKeyValue" type="ds:DSAKeyValueType"/&gt; &lt;complexType name="DSAKeyValueType"&gt; &lt;sequence&gt; &lt;sequence minOccurs="0"&gt; &lt;element name="P" type="ds:CryptoBinary"/&gt; &lt;element name="Q" type="ds:CryptoBinary"/&gt; &lt;/sequence&gt; &lt;element name="G" type="ds:CryptoBinary" minOccurs="0"/&gt; &lt;element name="Y" type="ds:CryptoBinary"/&gt; &lt;element name="J" type="ds:CryptoBinary" minOccurs="0"/&gt; &lt;sequence minOccurs="0"&gt; &lt;element name="Seed" type="ds:CryptoBinary"/&gt; &lt;element name="PgenCounter" type="ds:CryptoBinary"/&gt; &lt;/sequence&gt; &lt;/sequence&gt; &lt;/complexType&gt; </code></pre> <p>However, according to <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh868316.aspx" rel="nofollow">MSDN</a>, the DsaKeyValue XML is defined as below:</p> <pre><code>&lt;DSAKeyValue&gt; &lt;!-- Child elements --&gt; P, Q, G?, Y, J?, Seed, PgenCounter &lt;/DSAKeyValue&gt; </code></pre> <p>Im getting a Bad data when importing from XML. Following is my code:</p> <pre><code>JsonDictionary privateKeyDictionary = (JsonDictionary) JsonReader.Parse(privateKey); //FYI: this private signing key was generated using Keyczar. var dsaParameterArray = privateKeyDictionary["publicKey"] as JsonDictionary; DSACryptoServiceProvider signer = new DSACryptoServiceProvider(1024); var pArray = Encoding.UTF8.GetBytes(dsaParameterArray["p"].ToString()); string p = Convert.ToBase64String(pArray); var qArray = Encoding.UTF8.GetBytes(dsaParameterArray["q"].ToString()); string q = Convert.ToBase64String(qArray); var gArray = Encoding.UTF8.GetBytes(dsaParameterArray["g"].ToString()); string g = Convert.ToBase64String(gArray); var yArray = Encoding.UTF8.GetBytes(dsaParameterArray["y"].ToString()); string y = Convert.ToBase64String(yArray); xml = String.Format("&lt;DSAKeyValue&gt;&lt;P&gt;{0}&lt;/P&gt;&lt;Q&gt;{1}&lt;/Q&gt;&lt;G&gt;{2}&lt;/G&gt;&lt;Y&gt;{3}&lt;/Y&gt;&lt;J/&gt;&lt;Seed/&gt;&lt;PgenCounter/&gt;&lt;/DSAKeyValue&gt;", p, q, g, y); doc = new XmlDocument(); doc.LoadXml(xml); signer.FromXmlString(doc.InnerXml); </code></pre> <p>All that said, my problem is that I dont have "J", "Seed" and "PgenCounter" in my key hence I didnt supply them. According to the W3C, thats optional. However, I do have a "x" in my key but wasnt sure what that was. </p> <p>According to the W3C the Seed and PgenCounter tags are optional. However, the MSDN defines it as required. </p> <p>Ive tried removing the J, Seed and PgenCounter tags and that didnt seem to help.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload