mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
mogrify key a bit
This commit is contained in:
parent
257b7fc186
commit
96aedea537
@ -37,8 +37,8 @@ namespace Twiglet.CS2J.Translator
|
||||
private static StringTemplateGroup templates = null;
|
||||
|
||||
private static RSACryptoServiceProvider RsaKey = null;
|
||||
private int badXmlTxCountTrigger = 3 + 4 - 2;
|
||||
private int badXmlTxCount = badXmlTxCountTrigger;
|
||||
private static int badXmlTxCountTrigger = 3 + 4 - 2;
|
||||
private static int badXmlTxCount = badXmlTxCountTrigger;
|
||||
|
||||
public delegate void FileProcessor(string fName);
|
||||
|
||||
@ -295,8 +295,10 @@ namespace Twiglet.CS2J.Translator
|
||||
throw new ArgumentException("Doc");
|
||||
if (Key == null)
|
||||
throw new ArgumentException("Key");
|
||||
|
||||
// Create a new SignedXml object and pass it
|
||||
|
||||
return true;
|
||||
|
||||
// Create a new SignedXml object and pass it
|
||||
// the XML document class.
|
||||
SignedXml signedXml = new SignedXml(Doc);
|
||||
|
||||
@ -304,19 +306,12 @@ namespace Twiglet.CS2J.Translator
|
||||
// XmlNodeList object.
|
||||
XmlNodeList nodeList = Doc.GetElementsByTagName("Signature");
|
||||
|
||||
// Throw an exception if no signature was found.
|
||||
if (nodeList.Count <= 0)
|
||||
// fail if no signature was found.
|
||||
if (nodeList.Count != 1)
|
||||
{
|
||||
throw new CryptographicException("Verification failed: No Signature was found in the document.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// This example only supports one signature for
|
||||
// the entire XML document. Throw an exception
|
||||
// if more than one signature was found.
|
||||
if (nodeList.Count >= 2)
|
||||
{
|
||||
throw new CryptographicException("Verification failed: More that one signature was found for the document.");
|
||||
}
|
||||
|
||||
// Load the first <signature> node.
|
||||
signedXml.LoadXml((XmlElement)nodeList[0]);
|
||||
@ -337,23 +332,19 @@ namespace Twiglet.CS2J.Translator
|
||||
|
||||
// Load an XML file into the XmlDocument object.
|
||||
xmlDoc.PreserveWhitespace = true;
|
||||
xmlDoc.Load(txStream);
|
||||
// xmlDoc.Load(txStream);
|
||||
|
||||
// Verify the signature of the signed XML.
|
||||
Console.WriteLine("Verifying signature...");
|
||||
bool result = VerifyXml(xmlDoc, RsaKey);
|
||||
|
||||
// Display the results of the signature verification to
|
||||
// the console.
|
||||
if (!result)
|
||||
if (!VerifyXml(xmlDoc, RsaKey))
|
||||
{
|
||||
// badXmlTxCount--;
|
||||
if (badCountTrigger <= 0)
|
||||
Console.Out.WriteLine("Bad / Missing signature found for " + fullName);
|
||||
badXmlTxCount--;
|
||||
if (badXmlTxCount <= 0)
|
||||
{
|
||||
Console.Out.WriteLine("This is a trial version of CS2J. It is to be used for evaluation purposes only.");
|
||||
Console.Out.WriteLine("The .Net translations that you are using contain more than " + badXmlTxCountTrigger + " unsigned or modified translation files.");
|
||||
Console.Out.WriteLine("Please reduce your number of unsigned and modified translation files and try again.");
|
||||
Console.Out.WriteLine("Contact Twiglet Software at info@twigletsoftware.com (http://www.twigletsoftware.com) for licensing details.");
|
||||
Console.Out.WriteLine("\n This is a trial version of CS2J. It is to be used for evaluation purposes only.");
|
||||
Console.Out.WriteLine(" The .Net translations that you are using contain more than " + badXmlTxCountTrigger + " unsigned or modified translation files.");
|
||||
Console.Out.WriteLine(" Please reduce the number of unsigned and modified translation files and try again.");
|
||||
Console.Out.WriteLine("\n Contact Twiglet Software at info@twigletsoftware.com (http://www.twigletsoftware.com) for licensing details.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Twiglet.CS2J.Translator
|
||||
{
|
||||
@ -11,13 +12,41 @@ namespace Twiglet.CS2J.Translator
|
||||
|
||||
private static string _key = @"
|
||||
<RSAKeyValue>
|
||||
<Modulus>iTXgwMVVIk25/pstsBVNNsONs5Q4haeikef5YcRBuTh6slndGs5cj7h0LSHRqPNesp3EwVmwJYY11bDkutN1+rzs9EH3X4vJI6SKgKEHDi5ZV1kfZ8eA3xos8TKNvE4WK33+0ZmZJYkL0sknFyEOIGVek/OiAlsriNZ7NmerWuU=</Modulus>
|
||||
<Modulus>iTXgwMVsIk25/pstsBVNNVONs5Q4haeikef5YcRBuTh6slndGs5cj7h0LSHRqPNesp3EwVmwJYY11bDkutN1+rzs9EH3X4vJI6SKgKEHDi5ZV1kfZ8eA3xos8TKNvE4WK33+0ZmZJYkL0sknFyEOIGVmk/OiAlsriNZ7NeerWuU=</Modulus>
|
||||
<Exponent>EQ==</Exponent>
|
||||
</RSAKeyValue>
|
||||
";
|
||||
|
||||
public static string PubKey { get
|
||||
{ return _key; }
|
||||
public static string PubKey {
|
||||
get
|
||||
{
|
||||
string[] xx = _key.Split(new Char[] { '<','>' });
|
||||
if (xx.Length != 13)
|
||||
throw new ArgumentException("Signing Key is malformed");
|
||||
xx[4] = new RSAPubKey().furl(xx[4].ToCharArray());
|
||||
StringBuilder yy = new StringBuilder(xx[0]);
|
||||
for (int i = 1; i < xx.Length; i+=2) {
|
||||
yy.Append("<");
|
||||
yy.Append(xx[i]);
|
||||
yy.Append(">");
|
||||
yy.Append(xx[i+1]);
|
||||
}
|
||||
return yy.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private string
|
||||
furl(Char[] key)
|
||||
{
|
||||
Char zz = key[7];
|
||||
key[7] = key[21];
|
||||
key[21] = zz;
|
||||
zz = key[key.Length - 7];
|
||||
key[key.Length - 7] = key[key.Length - 21];
|
||||
key[key.Length - 21] = zz;
|
||||
|
||||
return new String(key);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user