Assert.AreEqual (0, cs.Read (buffer, 0, 8), "Read from disposed");
}
}
-
+
+#if !NET_2_1
[Test]
// MS BUG [ExpectedException (typeof (ObjectDisposedException))]
#if NET_2_0
len = cs.Read (buffer, 3, 4);
}
}
+#endif
[Test]
[ExpectedException (typeof (NotSupportedException))]
cs = new CryptoStream (readStream, encryptor, CryptoStreamMode.Read);
cs.Read (buffer, Int32.MaxValue, 4);
}
-
+
+#if !NET_2_1
[Test]
// MS BUG [ExpectedException (typeof (ObjectDisposedException))]
#if NET_2_0
cs.Write (buffer, 0, 8);
}
}
-
+#endif
+
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void Write_ReadStream ()
private bool machineKeyStore;
- [TestFixtureSetUp]
- public void FixtureSetUp ()
+ public DSACryptoServiceProviderTest ()
{
disposed = new DSACryptoServiceProvider (minKeySize);
// FX 2.0 beta 1 bug - we must use the key before clearing it
// verify a signature based on a new just generated keypair
Assert.IsFalse (emptyDSA.VerifySignature (hash, sign));
}
-
+
+#if !NET_2_1
[Test]
[Category ("NotWorking")]
public void ImportDisposed ()
import.ImportParameters (AllTests.GetKey (false));
// no exception from Fx 2.0 +
}
+#endif
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
catch (UnauthorizedAccessException) {
}
}
-
+
+#if !NET_2_1
[Test]
[Category ("NotWorking")]
public void CspKeyContainerInfo_NewKeypair ()
Assert.IsFalse (info.Removable, "Removable");
// info.UniqueKeyContainerName throws a CryptographicException at this stage
}
+#endif
[Test]
public void ExportCspBlob_Full ()
static byte[] sign = { 0x50, 0xd2, 0xb0, 0x8b, 0xcd, 0x5e, 0xb2, 0xc2, 0x35, 0x82, 0xd3, 0x76, 0x07, 0x79, 0xbb, 0x55, 0x98, 0x72, 0x43, 0xe8,
0x74, 0xc9, 0x35, 0xf8, 0xc9, 0xbd, 0x69, 0x2f, 0x08, 0x34, 0xfa, 0x5a, 0x59, 0x23, 0x2a, 0x85, 0x7b, 0xa3, 0xb3, 0x82 };
- [TestFixtureSetUp]
- public void FixtureSetUp ()
+ public DSASignatureDeformatterTest ()
{
// key generation is VERY long so one time is enough
dsa = DSA.Create ();
protected static DSA dsa;
protected static RSA rsa;
- [TestFixtureSetUp]
- public void FixtureSetUp ()
+ public DSASignatureFormatterTest ()
{
// key generation is VERY long so one time is enough
dsa = DSA.Create ();
protected HMACMD5 algo;
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
algo = new HMACMD5 ();
algo.Key = new byte [8];
protected HMACRIPEMD160 hmac;
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hmac = new HMACRIPEMD160 ();
hmac.Key = new byte [8];
protected HMACSHA1 algo;
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = HMACSHA1.Create ();
(hash as KeyedHashAlgorithm).Key = new byte [8];
protected HMACSHA256 algo;
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
algo = new HMACSHA256 ();
algo.Key = new byte [8];
private bool legacy;
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
algo = new HMACSHA384 ();
algo.Key = new byte [8];
private bool legacy;
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
algo = new HMACSHA512 ();
algo.Key = new byte [8];
protected HashAlgorithm hash;
[SetUp]
- protected virtual void SetUp ()
+ public virtual void SetUp ()
{
hash = HashAlgorithm.Create ();
}
public virtual bool ManagedHashImplementation {
get { return false; }
}
-
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // Mono nevers throws an exception (and we're all managed ;-)
public void TransformFinalBlock_Twice ()
if (!ManagedHashImplementation && !exception)
Assert.Fail ("Expected CryptographicException from non *Managed classes");
}
-
+#endif
[Test]
public void TransformFinalBlock_Twice_Initialize ()
{
{
Assert.AreEqual (HashBuffer (false), HashBuffer (true), "Intersect");
}
-
+#if !NET_2_1
[Test]
[ExpectedException (typeof (NullReferenceException))]
[Category ("NotWorking")] // initialization problem ? fx2.0 only ?
// getting the property throws
Assert.IsNull (hash.Hash);
}
-
+#endif
[Test]
[ExpectedException (typeof (CryptographicUnexpectedOperationException))]
public void Hash_AfterInitialize_SecondTime ()
public class KeyedHashAlgorithmTest : HashAlgorithmTest {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = KeyedHashAlgorithm.Create ();
(hash as KeyedHashAlgorithm).Key = new byte [8];
PasswordDeriveBytes pdb = new PasswordDeriveBytes (pwd, salt, new CspParameters ());
}
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // CspParameters aren't supported by Mono (requires CryptoAPI)
public void Ctor_PasswordSaltNullCspParameters ()
Assert.AreEqual (100, pdb.IterationCount, "IterationCount");
Assert.IsNull (pdb.Salt, "Salt");
}
+#endif
[Test]
public void Ctor_PasswordSaltCspParametersNull ()
Assert.AreEqual (ssalt, BitConverter.ToString (pdb.Salt), "Salt");
}
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // CspParameters aren't supported by Mono (requires CryptoAPI)
public void Ctor_PasswordSaltCspParameters ()
Assert.AreEqual (100, pdb.IterationCount, "IterationCount");
Assert.AreEqual (ssalt, BitConverter.ToString (pdb.Salt), "Salt");
}
+#endif
[Test]
#if NET_2_0
PasswordDeriveBytes pdb = new PasswordDeriveBytes (pwd, salt, "SHA1", 1, new CspParameters ());
}
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // CspParameters aren't supported by Mono (requires CryptoAPI)
public void Ctor_PasswordSaltNullHashIterationCspParameters ()
Assert.AreEqual (1, pdb.IterationCount, "IterationCount");
Assert.IsNull (pdb.Salt, "Salt");
}
+#endif
[Test]
[ExpectedException (typeof (ArgumentNullException))]
{
PasswordDeriveBytes pdb = new PasswordDeriveBytes ("s3kr3t", salt, "SHA1", 0, new CspParameters ());
}
-
+
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // CspParameters aren't supported by Mono (requires CryptoAPI)
public void Ctor_PasswordSaltHashIterationMaxValueCspParameters ()
Assert.AreEqual (Int32.MaxValue, pdb.IterationCount, "IterationCount");
Assert.AreEqual (ssalt, BitConverter.ToString (pdb.Salt), "Salt");
}
+#endif
[Test]
public void Ctor_PasswordSaltHashIterationCspParametersNull ()
Assert.AreEqual (ssalt, BitConverter.ToString (pdb.Salt), "Salt");
}
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // CspParameters aren't supported by Mono (requires CryptoAPI)
public void Ctor_PasswordSaltHashIterationCspParameters ()
Assert.AreEqual (1, pdb.IterationCount, "IterationCount");
Assert.AreEqual (ssalt, BitConverter.ToString (pdb.Salt), "Salt");
}
-
+#endif
+
// Properties
[Test]
PasswordDeriveBytes pd = new PasswordDeriveBytes ("password", null, "MD5", 1000);
pd.CryptDeriveKey ("AlgName", "MD5", 256, new byte [8]);
}
-
+
+#if !NET_2_1
[Test]
[Category ("NotWorking")] // bug #79499
public void LongMultipleGetBytes ()
// bytes from 32-40 are different from calling GetBytes separately
Assert.AreEqual (key + "-F6-55-6C-3E-54-8B-F3-73-4D-3F-9B-F8-EE-AA-95-ED", BitConverter.ToString (pd.GetBytes (48)), "same");
}
+#endif
}
}
{
_algo = new RNGCryptoServiceProvider ();
}
-
+#if !NET_2_1
[Test]
public void ConstructorByteArray ()
{
string s = null;
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (s);
}
-
+#endif
[Test]
public void GetBytes ()
{
private bool machineKeyStore;
- [TestFixtureSetUp]
- public void FixtureSetUp ()
+ public RSACryptoServiceProviderTest ()
{
sha1OID = CryptoConfig.MapNameToOID ("SHA1");
disposed = new RSACryptoServiceProvider (minKeySize);
rsa.VerifyHash (hash, "1.3.14.3.2.26", null);
}
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
[Test]
[Category ("NotWorking")]
public void ImportDisposed ()
}
#if NET_2_0
+#if !NET_2_1
[Test]
[Category ("NotWorking")]
public void CspKeyContainerInfo_NewKeypair ()
Assert ("Removable", !info.Removable);
// info.UniqueKeyContainerName throws a CryptographicException at this stage
}
-
+#endif
[Test]
public void ExportCspBlob_Full ()
{
public class SHA1CryptoServiceProviderTest : SHA1Test {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = new SHA1CryptoServiceProvider ();
}
public class SHA1Test : HashAlgorithmTest {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = SHA1.Create ();
}
public class SHA256ManagedTest : SHA256Test {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = new SHA256Managed ();
}
public class SHA256Test : HashAlgorithmTest {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = SHA256.Create ();
}
public class SHA384ManagedTest : SHA384Test {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = new SHA384Managed ();
}
public class SHA384Test : HashAlgorithmTest {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = SHA384.Create ();
}
public class SHA512ManagedTest : SHA512Test {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = new SHA512Managed ();
}
public class SHA512Test : HashAlgorithmTest {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = SHA512.Create ();
}