Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -22,7 +22,7 @@ namespace MonoTests.Mono.Math {
protected void Expect (BigInteger actual, BigInteger expected)
{
Assertion.AssertEquals (Name, expected, actual);
Assert.AreEqual (expected, actual, Name);
}
}
}

View File

@@ -81,12 +81,12 @@ namespace MonoTests.Mono.Math {
private void ExpectComposite (BigInteger bi)
{
Assertion.AssertEquals (false, bi.IsProbablePrime ());
Assert.AreEqual (false, bi.IsProbablePrime ());
}
private void ExpectPrime (BigInteger bi)
{
Assertion.AssertEquals (true, bi.IsProbablePrime ());
Assert.AreEqual (true, bi.IsProbablePrime ());
}
}
@@ -195,7 +195,7 @@ namespace MonoTests.Mono.Math {
// Adapted from http://lists.ximian.com/archives/public/mono-devel-list/2003-November/003026.html
// Note: these primes are taken from RFC 2412 [http://www.faqs.org/rfcs/rfc2412.html]
[TestFixture]
public class Rfc2412WellTestedPrimes : Assertion {
public class Rfc2412WellTestedPrimes {
// E.1. Well-Known Group 1: A 768 bit prime
[Test]
@@ -203,8 +203,8 @@ namespace MonoTests.Mono.Math {
{
string prime = "1552518092300708935130918131258481755631334049434514313202351194902966239949102107258669453876591642442910007680288864229150803718918046342632727613031282983744380820890196288509170691316593175367469551763119843371637221007210577919";
BigInteger bi = BigInteger.Parse (prime);
Assert ("isProbablePrime-768", bi.IsProbablePrime ());
AssertEquals ("ToString()", prime, bi.ToString ());
Assert.IsTrue (bi.IsProbablePrime (), "isProbablePrime-768");
Assert.AreEqual (prime, bi.ToString (), "ToString()");
}
// E.2. Well-Known Group 2: A 1024 bit prime
@@ -213,8 +213,8 @@ namespace MonoTests.Mono.Math {
{
string prime = "179769313486231590770839156793787453197860296048756011706444423684197180216158519368947833795864925541502180565485980503646440548199239100050792877003355816639229553136239076508735759914822574862575007425302077447712589550957937778424442426617334727629299387668709205606050270810842907692932019128194467627007";
BigInteger bi = BigInteger.Parse (prime);
Assert ("isProbablePrime-1024", bi.IsProbablePrime ());
AssertEquals ("ToString()", prime, bi.ToString ());
Assert.IsTrue (bi.IsProbablePrime (), "isProbablePrime-1024");
Assert.AreEqual (prime, bi.ToString (), "ToString()");
}
// Note: E.3 and E.4 are for Elliptic Curve Groups
@@ -225,8 +225,8 @@ namespace MonoTests.Mono.Math {
{
string prime = "2410312426921032588552076022197566074856950548502459942654116941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919";
BigInteger bi = BigInteger.Parse (prime);
Assert ("isProbablePrime-1536", bi.IsProbablePrime ());
AssertEquals ("ToString()", prime, bi.ToString ());
Assert.IsTrue (bi.IsProbablePrime (), "isProbablePrime-1536");
Assert.AreEqual (prime, bi.ToString (), "ToString()");
}
}

View File

@@ -34,7 +34,7 @@ namespace MonoTests.Mono.Math {
ContextData ctx = (ContextData)Context;
Assertion.AssertEquals (ctx.bits, bits);
Assert.AreEqual (ctx.bits, bits);
uint d = ctx.testData;
for (uint i = (uint)bits - 2; d > 0; i--, d >>= 1)
@@ -65,7 +65,7 @@ namespace MonoTests.Mono.Math {
Assert.IsTrue (p.TestBit (1));
uint d = ctx.testData;
for (uint j = 128 - 2; d > 0; j--, d >>= 1)
Assertion.AssertEquals ((d&1) == 1, p.TestBit (j));
Assert.AreEqual ((d&1) == 1, p.TestBit (j));
}
}
}

View File

@@ -68,7 +68,7 @@ namespace MonoTests.Mono.Security.Authenticode {
// makecert -n "CN=PVK1" -sv 1.pvk 1.cer
[TestFixture]
public class PrivateKeyTest : Assertion {
public class PrivateKeyTest {
// because most crypto stuff works with byte[] buffers
static public void AssertEquals (string msg, byte[] array1, byte[] array2)
@@ -76,9 +76,9 @@ public class PrivateKeyTest : Assertion {
if ((array1 == null) && (array2 == null))
return;
if (array1 == null)
Fail (msg + " -> First array is NULL");
Assert.Fail (msg + " -> First array is NULL");
if (array2 == null)
Fail (msg + " -> Second array is NULL");
Assert.Fail (msg + " -> Second array is NULL");
bool a = (array1.Length == array2.Length);
if (a) {
@@ -93,7 +93,7 @@ public class PrivateKeyTest : Assertion {
msg += " -> Expected " + BitConverter.ToString (array1, 0);
msg += " is different than " + BitConverter.ToString (array2, 0);
}
Assert (msg, a);
Assert.IsTrue (a, msg);
}
string testfile;
@@ -152,10 +152,10 @@ public class PrivateKeyTest : Assertion {
{
WriteBuffer (nopwd);
PrivateKey pvk = PrivateKey.CreateFromFile (testfile);
AssertNotNull ("msnopwd.RSA", pvk.RSA);
Assert ("msnopwd.Encrypted", !pvk.Encrypted);
Assert ("msnopwd.Weak", pvk.Weak);
AssertEquals ("msnopwd.KeyType", 2, pvk.KeyType);
Assert.IsNotNull (pvk.RSA, "msnopwd.RSA");
Assert.IsTrue (!pvk.Encrypted, "msnopwd.Encrypted");
Assert.IsTrue (pvk.Weak, "msnopwd.Weak");
Assert.AreEqual (2, pvk.KeyType, "msnopwd.KeyType");
}
// this will convert a PVK file without a password to a PVK file
@@ -168,11 +168,11 @@ public class PrivateKeyTest : Assertion {
string rsa1 = pvk.RSA.ToXmlString (true);
pvk.Save (testfile, "password");
pvk = PrivateKey.CreateFromFile (testfile, "password");
AssertNotNull ("topwd.RSA", pvk.RSA);
Assert.IsNotNull (pvk.RSA, "topwd.RSA");
string rsa2 = pvk.RSA.ToXmlString (true);
AssertEquals ("topwd.RSA identical", rsa1, rsa2);
Assert ("topwd.Encrypted", pvk.Encrypted);
Assert ("topwd.Weak", pvk.Weak);
Assert.AreEqual (rsa1, rsa2, "topwd.RSA identical");
Assert.IsTrue (pvk.Encrypted, "topwd.Encrypted");
Assert.IsTrue (pvk.Weak, "topwd.Weak");
}
// this will convert a PVK file without a password to a PVK file
@@ -186,11 +186,11 @@ public class PrivateKeyTest : Assertion {
pvk.Weak = false; // we want strong crypto
pvk.Save (testfile, "password");
pvk = PrivateKey.CreateFromFile (testfile, "password");
AssertNotNull ("topwd.RSA", pvk.RSA);
Assert.IsNotNull (pvk.RSA, "topwd.RSA");
string rsa2 = pvk.RSA.ToXmlString (true);
AssertEquals ("topwd.RSA identical", rsa1, rsa2);
Assert ("topwd.Encrypted", pvk.Encrypted);
Assert ("topwd.Weak", !pvk.Weak);
Assert.AreEqual (rsa1, rsa2, "topwd.RSA identical");
Assert.IsTrue (pvk.Encrypted, "topwd.Encrypted");
Assert.IsTrue (!pvk.Weak, "topwd.Weak");
}
static byte[] pwd = {
@@ -229,9 +229,9 @@ public class PrivateKeyTest : Assertion {
{
WriteBuffer (pwd);
PrivateKey pvk = PrivateKey.CreateFromFile (testfile, "password");
AssertNotNull ("mspwd.RSA", pvk.RSA);
Assert ("mspwd.Encrypted", pvk.Encrypted);
Assert ("mspwd.Weak", pvk.Weak);
Assert.IsNotNull (pvk.RSA, "mspwd.RSA");
Assert.IsTrue (pvk.Encrypted, "mspwd.Encrypted");
Assert.IsTrue (pvk.Weak, "mspwd.Weak");
}
// this will convert a PVK file with a password to a PVK file
@@ -244,11 +244,11 @@ public class PrivateKeyTest : Assertion {
string rsa1 = pvk.RSA.ToXmlString (true);
pvk.Save (testfile);
pvk = PrivateKey.CreateFromFile (testfile);
AssertNotNull ("nomorepwd.RSA", pvk.RSA);
Assert.IsNotNull (pvk.RSA, "nomorepwd.RSA");
string rsa2 = pvk.RSA.ToXmlString (true);
AssertEquals ("nomorepwd.RSA identical", rsa1, rsa2);
Assert ("nomorepwd.Encrypted", !pvk.Encrypted);
Assert ("nomorepwd.Weak", pvk.Weak);
Assert.AreEqual (rsa1, rsa2, "nomorepwd.RSA identical");
Assert.IsTrue (!pvk.Encrypted, "nomorepwd.Encrypted");
Assert.IsTrue (pvk.Weak, "nomorepwd.Weak");
}
[Test]
@@ -261,11 +261,11 @@ public class PrivateKeyTest : Assertion {
pvk.Save (testfile, "mono");
pvk = PrivateKey.CreateFromFile (testfile, "mono");
AssertNotNull ("new.RSA", pvk.RSA);
Assert.IsNotNull (pvk.RSA, "new.RSA");
string rsa2 = pvk.RSA.ToXmlString (true);
AssertEquals ("new.RSA identical", rsa1, rsa2);
Assert ("new.Encrypted", pvk.Encrypted);
Assert ("new.Weak", !pvk.Weak);
Assert.AreEqual (rsa1, rsa2, "new.RSA identical");
Assert.IsTrue (pvk.Encrypted, "new.Encrypted");
Assert.IsTrue (!pvk.Weak, "new.Weak");
}
[Test]

View File

@@ -15,7 +15,7 @@ using Mono.Security.Cryptography;
namespace MonoTests.Mono.Security.Cryptography {
[TestFixture]
public class CryptoConvertTest : Assertion {
public class CryptoConvertTest {
// because most crypto stuff works with byte[] buffers
static public void AssertEquals (string msg, byte[] array1, byte[] array2)
@@ -23,9 +23,9 @@ namespace MonoTests.Mono.Security.Cryptography {
if ((array1 == null) && (array2 == null))
return;
if (array1 == null)
Fail (msg + " -> First array is NULL");
Assert.Fail (msg + " -> First array is NULL");
if (array2 == null)
Fail (msg + " -> Second array is NULL");
Assert.Fail (msg + " -> Second array is NULL");
bool a = (array1.Length == array2.Length);
if (a) {
@@ -38,7 +38,7 @@ namespace MonoTests.Mono.Security.Cryptography {
}
msg += " -> Expected " + BitConverter.ToString (array1, 0);
msg += " is different than " + BitConverter.ToString (array2, 0);
Assert (msg, a);
Assert.IsTrue (a, msg);
}
// strongname generated using "sn -k unit.snk"
@@ -163,16 +163,16 @@ namespace MonoTests.Mono.Security.Cryptography {
{
// keypair
RSA rsa = CryptoConvert.FromCapiKeyBlob (strongName, 0);
AssertEquals ("KeyPair", strongNameString, rsa.ToXmlString (true));
AssertEquals ("PublicKey-1", strongNamePublicKeyString, rsa.ToXmlString (false));
Assert.AreEqual (strongNameString, rsa.ToXmlString (true), "KeyPair");
Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey-1");
// public key (direct)
rsa = CryptoConvert.FromCapiKeyBlob (strongNamePublicKey, 12);
AssertEquals ("PublicKey-2", strongNamePublicKeyString, rsa.ToXmlString (false));
Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey-2");
// public key (indirect - inside header)
rsa = CryptoConvert.FromCapiKeyBlob (strongNamePublicKey, 0);
AssertEquals ("PublicKey-3", strongNamePublicKeyString, rsa.ToXmlString (false));
Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey-3");
}
[Test]
@@ -201,7 +201,7 @@ namespace MonoTests.Mono.Security.Cryptography {
public void FromCapiPrivateKeyBlob ()
{
RSA rsa = CryptoConvert.FromCapiPrivateKeyBlob (strongName, 0);
AssertEquals ("KeyPair", strongNameString, rsa.ToXmlString (true));
Assert.AreEqual (strongNameString, rsa.ToXmlString (true), "KeyPair");
}
[Test]
@@ -229,7 +229,7 @@ namespace MonoTests.Mono.Security.Cryptography {
public void FromCapiPublicKeyBlob ()
{
RSA rsa = CryptoConvert.FromCapiPublicKeyBlob (strongNamePublicKey, 12);
AssertEquals ("PublicKey", strongNamePublicKeyString, rsa.ToXmlString (false));
Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey");
}
[Test]
@@ -262,12 +262,12 @@ namespace MonoTests.Mono.Security.Cryptography {
AssertEquals ("RSA-KeyPair", strongName, keypair);
byte[] publicKey = CryptoConvert.ToCapiKeyBlob (rsa, false);
AssertEquals ("RSA-PublicKey", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey));
Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "RSA-PublicKey");
AsymmetricAlgorithm dsa = DSA.Create ();
dsa.FromXmlString (dsaKeyPairString);
AssertEquals ("DSA-KeyPair", dsaPrivBlob, CryptoConvert.ToCapiKeyBlob (dsa, true));
AssertEquals ("DSA-PublicKey", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (CryptoConvert.ToCapiKeyBlob (dsa, false)));
Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (CryptoConvert.ToCapiKeyBlob (dsa, false)), "DSA-PublicKey");
}
[Test]
@@ -279,7 +279,7 @@ namespace MonoTests.Mono.Security.Cryptography {
AssertEquals ("KeyPair", strongName, keypair);
byte[] publicKey = CryptoConvert.ToCapiKeyBlob (rsa, false);
AssertEquals ("PublicKey", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey));
Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "PublicKey");
}
[Test]
@@ -323,11 +323,11 @@ namespace MonoTests.Mono.Security.Cryptography {
// full keypair
rsa.FromXmlString (strongNameString);
byte[] publicKey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
AssertEquals ("PublicKey-1", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey));
Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "PublicKey-1");
// public key only
rsa.FromXmlString (strongNamePublicKeyString);
publicKey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
AssertEquals ("PublicKey-2", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey));
Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "PublicKey-2");
}
/* DSA key tests */
@@ -419,8 +419,8 @@ namespace MonoTests.Mono.Security.Cryptography {
public void FromCapiKeyBlobDSA ()
{
DSA dsa = CryptoConvert.FromCapiKeyBlobDSA (dsaPrivBlob);
AssertEquals ("KeyPair", dsaKeyPairString, dsa.ToXmlString (true));
AssertEquals ("PublicKey", dsaPubKeyString, dsa.ToXmlString (false));
Assert.AreEqual (dsaKeyPairString, dsa.ToXmlString (true), "KeyPair");
Assert.AreEqual (dsaPubKeyString, dsa.ToXmlString (false), "PublicKey");
}
[Test]
@@ -449,7 +449,7 @@ namespace MonoTests.Mono.Security.Cryptography {
public void FromCapiPrivateKeyBlobDSA ()
{
DSA dsa = CryptoConvert.FromCapiPrivateKeyBlobDSA (dsaPrivBlob, 0);
AssertEquals ("KeyPair", dsaKeyPairString, dsa.ToXmlString (true));
Assert.AreEqual (dsaKeyPairString, dsa.ToXmlString (true), "KeyPair");
}
[Test]
@@ -478,7 +478,7 @@ namespace MonoTests.Mono.Security.Cryptography {
public void FromCapiPublicKeyBlobDSA ()
{
DSA dsa = CryptoConvert.FromCapiPublicKeyBlobDSA (dsaPubBlob, 0);
AssertEquals ("PublicKey", dsaPubKeyString, dsa.ToXmlString (false));
Assert.AreEqual (dsaPubKeyString, dsa.ToXmlString (false), "PublicKey");
}
[Test]
@@ -512,7 +512,7 @@ namespace MonoTests.Mono.Security.Cryptography {
AssertEquals ("KeyPair", dsaPrivBlob, keypair);
byte[] pubkey = CryptoConvert.ToCapiKeyBlob (dsa, false);
AssertEquals ("PublicKey", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey));
Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey), "PublicKey");
}
[Test]
@@ -548,20 +548,20 @@ namespace MonoTests.Mono.Security.Cryptography {
// full keypair
dsa.FromXmlString (dsaKeyPairString);
byte[] pubkey = CryptoConvert.ToCapiPublicKeyBlob (dsa);
AssertEquals ("PublicKey-1", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey));
Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey), "PublicKey-1");
// public key only
dsa.FromXmlString (dsaPubKeyString);
pubkey = CryptoConvert.ToCapiPublicKeyBlob (dsa);
AssertEquals ("PublicKey-2", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey));
Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey), "PublicKey-2");
}
[Test]
public void FromHex ()
{
AssertNull ("FromHex(null)", CryptoConvert.FromHex (null));
Assert.IsNull (CryptoConvert.FromHex (null), "FromHex(null)");
string result = BitConverter.ToString (CryptoConvert.FromHex ("0123456789aBcDeF"));
AssertEquals ("0123456789abcdef", "01-23-45-67-89-AB-CD-EF", result);
Assert.AreEqual ("01-23-45-67-89-AB-CD-EF", result, "0123456789abcdef");
}
[Test]
@@ -581,9 +581,9 @@ namespace MonoTests.Mono.Security.Cryptography {
[Test]
public void ToHex ()
{
AssertNull ("FromHex(null)", CryptoConvert.FromHex (null));
Assert.IsNull (CryptoConvert.FromHex (null), "FromHex(null)");
byte[] data = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
AssertEquals ("0123456789abcdef", "0123456789ABCDEF", CryptoConvert.ToHex (data));
Assert.AreEqual ("0123456789ABCDEF", CryptoConvert.ToHex (data), "0123456789abcdef");
}
[Test]
@@ -595,8 +595,8 @@ namespace MonoTests.Mono.Security.Cryptography {
RSA rsa = CryptoConvert.FromCapiKeyBlob (strongNameNUnit, 0);
// note the bad D parameters !!!
// this only works because CRT is being used
AssertEquals ("KeyPair", "<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent><P>2d4pGForvc792ztFxhNuzxIihDnXp+qK9F8t/NduhRBdu+JXK4d8a9EGwzpMxLUPlHjCZfXRraZiSQszkH+nzQ==</P><Q>yj9BeGmOrucOUCNZYTtXI0ykzz+1g+cVMSxi+6xzoLEOqmdE4gjcWaxak4MF1+pIR6UycnNa/jg1LBl7MKxpCw==</Q><DP>cMkAjznG4Sjx4/dIRKU0vP/PXJIxIR1bN+y5+uVvsnTpgWVH6SHneE0qahCZQ0/UM/Fb+bqLBJFY2iVxWUGslQ==</DP><DQ>gz6TXPGbLzMv3Z9i5C8e+ABHv1pHj6ZI4VU9kraxfmkH7FsBn3FClUq8qJdRFnGpoBy65Pyo4upUzx5mDAsGSw==</DQ><InverseQ>x+UShV+0d9cicoiB9fkSLqpLDyF4dYzVu0uqX0eCcoGJpk19jtSaMI3Eo8VN6MJAW1zrRy+MA1Fqb9qeThLqZQ==</InverseQ><D>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</D></RSAKeyValue>", rsa.ToXmlString (true));
AssertEquals ("PublicKey", "<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", rsa.ToXmlString (false));
Assert.AreEqual ("<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent><P>2d4pGForvc792ztFxhNuzxIihDnXp+qK9F8t/NduhRBdu+JXK4d8a9EGwzpMxLUPlHjCZfXRraZiSQszkH+nzQ==</P><Q>yj9BeGmOrucOUCNZYTtXI0ykzz+1g+cVMSxi+6xzoLEOqmdE4gjcWaxak4MF1+pIR6UycnNa/jg1LBl7MKxpCw==</Q><DP>cMkAjznG4Sjx4/dIRKU0vP/PXJIxIR1bN+y5+uVvsnTpgWVH6SHneE0qahCZQ0/UM/Fb+bqLBJFY2iVxWUGslQ==</DP><DQ>gz6TXPGbLzMv3Z9i5C8e+ABHv1pHj6ZI4VU9kraxfmkH7FsBn3FClUq8qJdRFnGpoBy65Pyo4upUzx5mDAsGSw==</DQ><InverseQ>x+UShV+0d9cicoiB9fkSLqpLDyF4dYzVu0uqX0eCcoGJpk19jtSaMI3Eo8VN6MJAW1zrRy+MA1Fqb9qeThLqZQ==</InverseQ><D>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</D></RSAKeyValue>", rsa.ToXmlString (true), "KeyPair");
Assert.AreEqual ("<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", rsa.ToXmlString (false), "PublicKey");
}
}
}

View File

@@ -24,7 +24,7 @@ namespace MonoTests.Mono.Security.Cryptography {
// http://www.ietf.org/rfc/rfc2631.txt
[TestFixture]
public class DiffieHellmanManagedTest : Assertion {
public class DiffieHellmanManagedTest {
// because most crypto stuff works with byte[] buffers
static public void AssertEquals (string msg, byte[] array1, byte[] array2)
@@ -32,9 +32,9 @@ namespace MonoTests.Mono.Security.Cryptography {
if ((array1 == null) && (array2 == null))
return;
if (array1 == null)
Assertion.Fail (msg + " -> First array is NULL");
Assert.Fail (msg + " -> First array is NULL");
if (array2 == null)
Assertion.Fail (msg + " -> Second array is NULL");
Assert.Fail (msg + " -> Second array is NULL");
bool a = (array1.Length == array2.Length);
if (a) {
@@ -49,7 +49,7 @@ namespace MonoTests.Mono.Security.Cryptography {
msg += " -> Expected " + BitConverter.ToString (array1, 0);
msg += " is different than " + BitConverter.ToString (array2, 0);
}
Assertion.Assert (msg, a);
Assert.IsTrue (a, msg);
}
[Test]
@@ -70,7 +70,7 @@ namespace MonoTests.Mono.Security.Cryptography {
// let the second DH instance compute the shared secret using the first DH public key
byte[] dh2k = dh2.DecryptKeyExchange (ke1);
// both shared secrets are the same
AssertEquals ("Shared Secret", dh1k, dh2k);
Assert.AreEqual (dh1k, dh2k, "Shared Secret");
}
// TODO: More is needed !

File diff suppressed because one or more lines are too long

View File

@@ -17,7 +17,7 @@ using NUnit.Framework;
namespace MonoTests.Mono.Security.Protocol.Ntlm {
[TestFixture]
public class ChallengeResponseTest : Assertion {
public class ChallengeResponseTest {
[Test]
// Example from http://www.innovation.ch/java/ntlm.html
@@ -25,8 +25,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] SrvNonce = Encoding.ASCII.GetBytes ("SrvNonce");
using (ChallengeResponse ntlm = new ChallengeResponse ("Beeblebrox", SrvNonce)) {
AssertEquals ("NT", "E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (ntlm.NT));
AssertEquals ("LM", "AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (ntlm.LM));
Assert.AreEqual ("E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (ntlm.NT), "NT");
Assert.AreEqual ("AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (ntlm.LM), "LM");
}
}
@@ -36,8 +36,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
using (ChallengeResponse ntlm = new ChallengeResponse ("WELCOME", SrvNonce)) {
AssertEquals ("NT", "7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (ntlm.NT));
AssertEquals ("LM", "CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM));
Assert.AreEqual ("7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (ntlm.NT), "NT");
Assert.AreEqual ("CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM), "LM");
}
}
@@ -46,9 +46,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
using (ChallengeResponse ntlm = new ChallengeResponse (null, SrvNonce)) {
AssertEquals ("NT", "4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT));
Assert.AreEqual ("4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT), "NT");
// note the last 8 bytes... they are the same as the previous unit test ;-)
AssertEquals ("LM", "0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM));
Assert.AreEqual ("0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM), "LM");
}
}
@@ -58,8 +58,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
using (ChallengeResponse ntlm = new ChallengeResponse (String.Empty, SrvNonce)) {
// same as the previous one as this is the same (null/empty) password expressed diffently
AssertEquals ("NT", "4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT));
AssertEquals ("LM", "0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM));
Assert.AreEqual ("4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT), "NT");
Assert.AreEqual ("0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM), "LM");
}
}
@@ -68,8 +68,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
// no out!
AssertNull ("Password", ntlm.Password);
AssertNull ("Challenge", ntlm.Challenge);
Assert.IsNull (ntlm.Password, "Password");
Assert.IsNull (ntlm.Challenge, "Challenge");
}
[Test]
@@ -104,7 +104,7 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
ntlm.Dispose ();
AssertNotNull ("NT", ntlm.NT);
Assert.IsNotNull (ntlm.NT, "NT");
}
[Test]
@@ -113,7 +113,7 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
ntlm.Dispose ();
AssertNotNull ("LM", ntlm.LM);
Assert.IsNotNull (ntlm.LM, "LM");
}
}
}

View File

@@ -15,7 +15,7 @@ using NUnit.Framework;
namespace MonoTests.Mono.Security.Protocol.Ntlm {
[TestFixture]
public class MessageBaseTest : Assertion {
public class MessageBaseTest {
//
@@ -42,4 +42,4 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
}
}
}
}

View File

@@ -16,17 +16,17 @@ using NUnit.Framework;
namespace MonoTests.Mono.Security.Protocol.Ntlm {
[TestFixture]
public class Type1MessageTest : Assertion {
public class Type1MessageTest {
[Test]
// Example from http://www.innovation.ch/java/ntlm.html
public void Encode1 ()
{
Type1Message msg = new Type1Message ();
AssertEquals ("Type", 1, msg.Type);
Assert.AreEqual (1, msg.Type, "Type");
msg.Domain = "Ursa-Minor";
msg.Host = "LightCity";
AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-01-00-00-00-07-B2-00-00-0A-00-0A-00-29-00-00-00-09-00-09-00-20-00-00-00-4C-49-47-48-54-43-49-54-59-55-52-53-41-2D-4D-49-4E-4F-52", BitConverter.ToString (msg.GetBytes ()));
Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-01-00-00-00-07-B2-00-00-0A-00-0A-00-29-00-00-00-09-00-09-00-20-00-00-00-4C-49-47-48-54-43-49-54-59-55-52-53-41-2D-4D-49-4E-4F-52", BitConverter.ToString (msg.GetBytes ()), "GetBytes");
}
[Test]
@@ -35,10 +35,10 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0xb2, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x29, 0x00, 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x20, 0x00, 0x00, 0x00, 0x4c, 0x49, 0x47, 0x48, 0x54, 0x43, 0x49, 0x54, 0x59, 0x55, 0x52, 0x53, 0x41, 0x2d, 0x4d, 0x49, 0x4e, 0x4f, 0x52 };
Type1Message msg = new Type1Message (data);
AssertEquals ("Domain", "URSA-MINOR", msg.Domain);
AssertEquals ("Flags", (NtlmFlags)0xb203, msg.Flags);
AssertEquals ("Host", "LIGHTCITY", msg.Host);
AssertEquals ("Type", 1, msg.Type);
Assert.AreEqual ("URSA-MINOR", msg.Domain, "Domain");
Assert.AreEqual ((NtlmFlags)0xb203, msg.Flags, "Flags");
Assert.AreEqual ("LIGHTCITY", msg.Host, "Host");
Assert.AreEqual (1, msg.Type, "Type");
}
[Test]
@@ -47,10 +47,10 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x20, 0x00, 0x00, 0x00, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x54, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x44, 0x4f, 0x4d, 0x41, 0x49, 0x4e };
Type1Message msg = new Type1Message (data);
AssertEquals ("Domain", "DOMAIN", msg.Domain);
AssertEquals ("Flags", (NtlmFlags)0x3207, msg.Flags);
AssertEquals ("Host", "WORKSTATION", msg.Host);
AssertEquals ("Type", 1, msg.Type);
Assert.AreEqual ("DOMAIN", msg.Domain, "Domain");
Assert.AreEqual ((NtlmFlags)0x3207, msg.Flags, "Flags");
Assert.AreEqual ("WORKSTATION", msg.Host, "Host");
Assert.AreEqual (1, msg.Type, "Type");
}
}
}

View File

@@ -17,7 +17,7 @@ using NUnit.Framework;
namespace MonoTests.Mono.Security.Protocol.Ntlm {
[TestFixture]
public class Type2MessageTest : Assertion {
public class Type2MessageTest {
static byte[] nonce = { 0x53, 0x72, 0x76, 0x4e, 0x6f, 0x6e, 0x63, 0x65 };
@@ -26,9 +26,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
public void Encode1 ()
{
Type2Message msg = new Type2Message ();
AssertEquals ("Type", 2, msg.Type);
Assert.AreEqual (2, msg.Type, "Type");
msg.Nonce = nonce;
AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-02-00-00-00-00-00-00-00-28-00-00-00-01-82-00-00-53-72-76-4E-6F-6E-63-65-00-00-00-00-00-00-00-00", BitConverter.ToString (msg.GetBytes ()));
Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-02-00-00-00-00-00-00-00-28-00-00-00-01-82-00-00-53-72-76-4E-6F-6E-63-65-00-00-00-00-00-00-00-00", BitConverter.ToString (msg.GetBytes ()), "GetBytes");
}
[Test]
@@ -37,9 +37,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x82, 0x00, 0x00, 0x53, 0x72, 0x76, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Type2Message msg = new Type2Message (data);
AssertEquals ("Flags", (NtlmFlags)0x8201, msg.Flags);
AssertEquals ("Nonce", BitConverter.ToString (nonce), BitConverter.ToString (msg.Nonce));
AssertEquals ("Type", 2, msg.Type);
Assert.AreEqual ((NtlmFlags)0x8201, msg.Flags, "Flags");
Assert.AreEqual (BitConverter.ToString (nonce), BitConverter.ToString (msg.Nonce), "Nonce");
Assert.AreEqual (2, msg.Type, "Type");
}
[Test]
@@ -48,9 +48,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
{
byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x02, 0x81, 0x00, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x62, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x41, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x44, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x41, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45, 0x00, 0x52, 0x00, 0x04, 0x00, 0x14, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x03, 0x00, 0x22, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x2e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00 };
Type2Message msg = new Type2Message (data);
AssertEquals ("Flags", (NtlmFlags)0x00810201, msg.Flags);
AssertEquals ("Nonce", "01-23-45-67-89-AB-CD-EF", BitConverter.ToString (msg.Nonce));
AssertEquals ("Type", 2, msg.Type);
Assert.AreEqual ((NtlmFlags)0x00810201, msg.Flags, "Flags");
Assert.AreEqual ("01-23-45-67-89-AB-CD-EF", BitConverter.ToString (msg.Nonce), "Nonce");
Assert.AreEqual (2, msg.Type, "Type");
}
[Test]

View File

@@ -17,7 +17,7 @@ using NUnit.Framework;
namespace MonoTests.Mono.Security.Protocol.Ntlm {
[TestFixture]
public class Type3MessageTest : Assertion {
public class Type3MessageTest {
static byte[] nonce = { 0x53, 0x72, 0x76, 0x4e, 0x6f, 0x6e, 0x63, 0x65 };
@@ -40,8 +40,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
msg.Host = "HOST";
msg.Password = "WELCOME";
msg.Username = "username";
AssertEquals ("Type", 3, msg.Type);
AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-64-00-00-00-18-00-18-00-7C-00-00-00-0C-00-0C-00-40-00-00-00-10-00-10-00-4C-00-00-00-08-00-08-00-5C-00-00-00-00-00-00-00-94-00-00-00-01-B2-00-00-44-00-4F-00-4D-00-41-00-49-00-4E-00-75-00-73-00-65-00-72-00-6E-00-61-00-6D-00-65-00-48-00-4F-00-53-00-54-00-CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8-7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (msg.GetBytes ()));
Assert.AreEqual (3, msg.Type, "Type");
Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-64-00-00-00-18-00-18-00-7C-00-00-00-0C-00-0C-00-40-00-00-00-10-00-10-00-4C-00-00-00-08-00-08-00-5C-00-00-00-00-00-00-00-94-00-00-00-01-B2-00-00-44-00-4F-00-4D-00-41-00-49-00-4E-00-75-00-73-00-65-00-72-00-6E-00-61-00-6D-00-65-00-48-00-4F-00-53-00-54-00-CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8-7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (msg.GetBytes ()), "GetBytes");
}
[Test]
@@ -55,8 +55,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
msg.Host = "LIGHTCITY";
msg.Password = "Beeblebrox";
msg.Username = "Zaphod";
AssertEquals ("Type", 3, msg.Type);
AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-72-00-00-00-18-00-18-00-8A-00-00-00-14-00-14-00-40-00-00-00-0C-00-0C-00-54-00-00-00-12-00-12-00-60-00-00-00-00-00-00-00-A2-00-00-00-01-B2-00-00-55-00-52-00-53-00-41-00-2D-00-4D-00-49-00-4E-00-4F-00-52-00-5A-00-61-00-70-00-68-00-6F-00-64-00-4C-00-49-00-47-00-48-00-54-00-43-00-49-00-54-00-59-00-AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97-E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.GetBytes ()));
Assert.AreEqual (3, msg.Type, "Type");
Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-72-00-00-00-18-00-18-00-8A-00-00-00-14-00-14-00-40-00-00-00-0C-00-0C-00-54-00-00-00-12-00-12-00-60-00-00-00-00-00-00-00-A2-00-00-00-01-B2-00-00-55-00-52-00-53-00-41-00-2D-00-4D-00-49-00-4E-00-4F-00-52-00-5A-00-61-00-70-00-68-00-6F-00-64-00-4C-00-49-00-47-00-48-00-54-00-43-00-49-00-54-00-59-00-AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97-E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.GetBytes ()), "GetBytes");
}
[Test]
@@ -64,14 +64,14 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
public void Decode1 ()
{
Type3Message msg = new Type3Message (data1);
AssertEquals ("Domain", "URSA-MINOR", msg.Domain);
AssertEquals ("Host", "LIGHTCITY", msg.Host);
AssertEquals ("Username", "Zaphod", msg.Username);
AssertEquals ("Flags", (NtlmFlags)0x8201, msg.Flags);
AssertEquals ("Type", 3, msg.Type);
AssertNull ("Password", msg.Password);
AssertEquals ("LM", "AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (msg.LM));
AssertEquals ("NT", "E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.NT));
Assert.AreEqual ("URSA-MINOR", msg.Domain, "Domain");
Assert.AreEqual ("LIGHTCITY", msg.Host, "Host");
Assert.AreEqual ("Zaphod", msg.Username, "Username");
Assert.AreEqual ((NtlmFlags)0x8201, msg.Flags, "Flags");
Assert.AreEqual (3, msg.Type, "Type");
Assert.IsNull (msg.Password, "Password");
Assert.AreEqual ("AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (msg.LM), "LM");
Assert.AreEqual ("E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.NT), "NT");
}
[Test]
@@ -79,28 +79,28 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm {
public void Decode2 ()
{
Type3Message msg = new Type3Message (data2);
AssertEquals ("Domain", "DOMAIN", msg.Domain);
AssertEquals ("Host", "WORKSTATION", msg.Host);
AssertEquals ("Username", "user", msg.Username);
AssertEquals ("Flags", (NtlmFlags)0x201, msg.Flags);
AssertEquals ("Type", 3, msg.Type);
AssertNull ("Password", msg.Password);
AssertEquals ("LM", "C3-37-CD-5C-BD-44-FC-97-82-A6-67-AF-6D-42-7C-6D-E6-7C-20-C2-D3-E7-7C-56", BitConverter.ToString (msg.LM));
AssertEquals ("NT", "25-A9-8C-1C-31-E8-18-47-46-6B-29-B2-DF-46-80-F3-99-58-FB-8C-21-3A-9C-C6", BitConverter.ToString (msg.NT));
Assert.AreEqual ("DOMAIN", msg.Domain, "Domain");
Assert.AreEqual ("WORKSTATION", msg.Host, "Host");
Assert.AreEqual ("user", msg.Username, "Username");
Assert.AreEqual ((NtlmFlags)0x201, msg.Flags, "Flags");
Assert.AreEqual (3, msg.Type, "Type");
Assert.IsNull (msg.Password, "Password");
Assert.AreEqual ("C3-37-CD-5C-BD-44-FC-97-82-A6-67-AF-6D-42-7C-6D-E6-7C-20-C2-D3-E7-7C-56", BitConverter.ToString (msg.LM), "LM");
Assert.AreEqual ("25-A9-8C-1C-31-E8-18-47-46-6B-29-B2-DF-46-80-F3-99-58-FB-8C-21-3A-9C-C6", BitConverter.ToString (msg.NT), "NT");
}
[Test]
public void Challenge ()
{
Type3Message msg = new Type3Message ();
AssertNull ("Challenge", msg.Challenge);
Assert.IsNull (msg.Challenge, "Challenge");
byte[] c = new byte [8];
msg.Challenge = c;
AssertEquals ("Challenge.Length", 8, msg.Challenge.Length);
Assert.AreEqual (8, msg.Challenge.Length, "Challenge.Length");
c [0] = 1;
AssertEquals ("Challenge not directly accessible", 0, msg.Challenge [0]);
Assert.AreEqual (0, msg.Challenge [0], "Challenge not directly accessible");
}
[Test]

View File

@@ -22,7 +22,7 @@ namespace MonoTests.Mono.Security {
// sn -k test.snk
[TestFixture]
public class StrongNameTest : Assertion {
public class StrongNameTest {
// because most crypto stuff works with byte[] buffers
static public void AssertEquals (string msg, byte[] array1, byte[] array2)
@@ -30,9 +30,9 @@ namespace MonoTests.Mono.Security {
if ((array1 == null) && (array2 == null))
return;
if (array1 == null)
Fail (msg + " -> First array is NULL");
Assert.Fail (msg + " -> First array is NULL");
if (array2 == null)
Fail (msg + " -> Second array is NULL");
Assert.Fail (msg + " -> Second array is NULL");
bool a = (array1.Length == array2.Length);
if (a) {
@@ -47,7 +47,7 @@ namespace MonoTests.Mono.Security {
msg += " -> Expected " + BitConverter.ToString (array1, 0);
msg += " is different than " + BitConverter.ToString (array2, 0);
}
Assert (msg, a);
Assert.IsTrue (a, msg);
}
static byte[] test = {
@@ -112,9 +112,9 @@ namespace MonoTests.Mono.Security {
public void FromBuffer ()
{
StrongName sn = new StrongName (test);
AssertEquals ("buffer.RSA", "<RSAKeyValue><Modulus>y6T/+EoARJMHW0ilpCdn+VbTffWxb1xu187/9Q+S2DwPyZ9LTNKrZgwaYmG4FPWEEH1HJxrxwh8AlD6oTz8CCcnPGKxKVFkubpIbEyvQCSTr22gUjVXXKHc2pfcCeOuNXS9kAOjv2tqpsiDbIsu9mnxfYysHWMDBqA4rxghyvT0=</Modulus><Exponent>AQAB</Exponent><P>6qYUEleRY+Wzyk7xN05UwWRna37U2aQnq2Y2VVyJeceDZPU1u1GYdQmFQw5XgvxKwWx9DAfNh1iSyLe0YmrAcw==</P><Q>3iy1IDIkPrRWBFrCAUhpUNn4/ICiVXTT7KjuEXkGr0+1Cx/V+o3eoVIo/9x2Q3IaxMbQDSa8hisIFunz/iuPjw==</Q><DP>2BouIBpfvzX8mBSOGNZePmG+0YRUeUCyfCs9XO5Fek9h1mfynVpvY1JqVbBuria2nl7Q53SEN+M+A/cT/RO9uw==</DP><DQ>pjma1ljNh2CTTrS8nAsaSJSc1gZD7l33RQRrAgWju7yN/qG2DbzhSZ9X7355uSKA5qK8/Gnz+QnvBn3JwGvE/w==</DQ><InverseQ>3U67bp3lPExfGoiTRvRyHhNtyJs6hAq/Uj7wSHKLHNoLG20kwZux8BwZKpPBBA0bQjkLUiRv9PYs18El/45/wA==</InverseQ><D>bPVOg5FMjWRBhmTbQ3ZWGkGLjRR9KEFDiTJXHs6DWjDgnZceWe9KB6KoJ0Vzkbs/Ovdcr56qBZxC2g6gTS5ALvogBYH2PrUftr4flh/z4qgOrAYCQkTecfHAGIGEldEeF1FItMbqmQa6WzVPVp4tn/+q3PAVmZqrs6/X9EARH10=</D></RSAKeyValue>", sn.RSA.ToXmlString (true));
AssertEquals ("buffer.PublicKey", testPublicKey, sn.PublicKey);
AssertEquals ("buffer.PublicKeyToken", testPublicKeyToken, sn.PublicKeyToken);
Assert.AreEqual ("<RSAKeyValue><Modulus>y6T/+EoARJMHW0ilpCdn+VbTffWxb1xu187/9Q+S2DwPyZ9LTNKrZgwaYmG4FPWEEH1HJxrxwh8AlD6oTz8CCcnPGKxKVFkubpIbEyvQCSTr22gUjVXXKHc2pfcCeOuNXS9kAOjv2tqpsiDbIsu9mnxfYysHWMDBqA4rxghyvT0=</Modulus><Exponent>AQAB</Exponent><P>6qYUEleRY+Wzyk7xN05UwWRna37U2aQnq2Y2VVyJeceDZPU1u1GYdQmFQw5XgvxKwWx9DAfNh1iSyLe0YmrAcw==</P><Q>3iy1IDIkPrRWBFrCAUhpUNn4/ICiVXTT7KjuEXkGr0+1Cx/V+o3eoVIo/9x2Q3IaxMbQDSa8hisIFunz/iuPjw==</Q><DP>2BouIBpfvzX8mBSOGNZePmG+0YRUeUCyfCs9XO5Fek9h1mfynVpvY1JqVbBuria2nl7Q53SEN+M+A/cT/RO9uw==</DP><DQ>pjma1ljNh2CTTrS8nAsaSJSc1gZD7l33RQRrAgWju7yN/qG2DbzhSZ9X7355uSKA5qK8/Gnz+QnvBn3JwGvE/w==</DQ><InverseQ>3U67bp3lPExfGoiTRvRyHhNtyJs6hAq/Uj7wSHKLHNoLG20kwZux8BwZKpPBBA0bQjkLUiRv9PYs18El/45/wA==</InverseQ><D>bPVOg5FMjWRBhmTbQ3ZWGkGLjRR9KEFDiTJXHs6DWjDgnZceWe9KB6KoJ0Vzkbs/Ovdcr56qBZxC2g6gTS5ALvogBYH2PrUftr4flh/z4qgOrAYCQkTecfHAGIGEldEeF1FItMbqmQa6WzVPVp4tn/+q3PAVmZqrs6/X9EARH10=</D></RSAKeyValue>", sn.RSA.ToXmlString (true), "buffer.RSA");
Assert.AreEqual (testPublicKey, sn.PublicKey, "buffer.PublicKey");
Assert.AreEqual (testPublicKeyToken, sn.PublicKeyToken, "buffer.PublicKeyToken");
}
[Test]
@@ -122,9 +122,9 @@ namespace MonoTests.Mono.Security {
{
StrongName sn1 = new StrongName (test);
StrongName sn2 = new StrongName (sn1.RSA);
AssertEquals ("key.RSA", sn1.RSA.ToXmlString (true), sn2.RSA.ToXmlString (true));
AssertEquals ("key.PublicKey", sn1.PublicKey, sn2.PublicKey);
AssertEquals ("key.PublicKeyToken", sn1.PublicKeyToken, sn2.PublicKeyToken);
Assert.AreEqual (sn1.RSA.ToXmlString (true), sn2.RSA.ToXmlString (true), "key.RSA");
Assert.AreEqual (sn1.PublicKey, sn2.PublicKey, "key.PublicKey");
Assert.AreEqual (sn1.PublicKeyToken, sn2.PublicKeyToken, "key.PublicKeyToken");
}
string Signed;
@@ -820,28 +820,28 @@ namespace MonoTests.Mono.Security {
{
// compare that both hellosigned and hellodelay are the same file expect for signature
byte[] s = sn.Hash (Signed);
AssertNotNull ("Hash/Signed", s);
Assert.IsNotNull (s, "Hash/Signed");
byte[] d = sn.Hash (Delay);
AssertNotNull ("Hash/Delay", d);
Assert.IsNotNull (d, "Hash/Delay");
// are they the same
AssertEquals ("Hash/Compare", s, d);
Assert.AreEqual (s, d, "Hash/Compare");
// are they the same as GetHashFromAssemblyFile
byte[] knownHash = { 0x7D, 0xF7, 0x1D, 0xD4, 0x24, 0x22, 0xEA, 0xAB, 0xD2, 0x91, 0xCD, 0xAB, 0x1A, 0x55, 0x6A, 0x42, 0x05, 0xBA, 0x6E, 0x7B };
AssertEquals ("Hash/GetHashFromAssemblyFile", knownHash, s);
Assert.AreEqual (knownHash, s, "Hash/GetHashFromAssemblyFile");
}
[Test]
public void VerifyValid ()
{
// verify that hellosigned.exe is valid
Assert ("Verify/Valid", sn.Verify (Signed));
Assert.IsTrue (sn.Verify (Signed), "Verify/Valid");
}
[Test]
public void VerifyInvalid ()
{
// verify that hellodelay.exe isn't valid
Assert ("Verify/Invalid", !sn.Verify (Delay));
Assert.IsTrue (!sn.Verify (Delay), "Verify/Invalid");
}
[Test]
@@ -849,7 +849,7 @@ namespace MonoTests.Mono.Security {
{
Stream signed = new MemoryStream (signedData);
// verify that hellosigned.exe is valid
Assert ("Verify/Valid", sn.Verify (signed));
Assert.IsTrue (sn.Verify (signed), "Verify/Valid");
}
[Test]
@@ -857,25 +857,25 @@ namespace MonoTests.Mono.Security {
{
Stream delay = new MemoryStream (delayData);
// verify that hellodelay.exe isn't valid
Assert ("Verify/Invalid", !sn.Verify (delay));
Assert.IsTrue (!sn.Verify (delay), "Verify/Invalid");
}
[Test]
public void Sign ()
{
// sign the (invalid) hellodelay.exe
Assert ("Sign", sn.Sign (Delay));
Assert.IsTrue (sn.Sign (Delay), "Sign");
// and verify it's now valid
Assert ("Sign/Verify", sn.Verify (Delay));
Assert.IsTrue (sn.Verify (Delay), "Sign/Verify");
}
[Test]
public void ReSign ()
{
// resign the (already valid) hellosigned.exe
Assert ("ReSign", sn.Sign (Signed));
Assert.IsTrue (sn.Sign (Signed), "ReSign");
// and verify it's still valid
Assert ("ReSign/Verify", sn.Verify (Signed));
Assert.IsTrue (sn.Verify (Signed), "ReSign/Verify");
}
[Test]
@@ -907,7 +907,7 @@ namespace MonoTests.Mono.Security {
{
byte[] ecma = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
sn = new StrongName (ecma);
Assert ("CanSign", !sn.CanSign);
Assert.IsTrue (!sn.CanSign, "CanSign");
}
[Test]