AddKeyBag() public method

public AddKeyBag ( AsymmetricAlgorithm aa ) : void
aa System.Security.Cryptography.AsymmetricAlgorithm
return void
Exemplo n.º 1
0
		public void GetAsymmetricAlgorithm_Test ()
		{
			PKCS12 p12 = new PKCS12 ();

			IDictionary attrs = new Hashtable ();
			ArrayList attrValues = new ArrayList ();
			attrValues.Add (Encoding.BigEndianUnicode.GetBytes ("Friendly name"));
			attrs.Add (PKCS9.friendlyName, attrValues);

			p12.AddKeyBag (RSA.Create (), attrs);

			AssertEquals ("GA.1", p12.Keys.Count, 1);

			AsymmetricAlgorithm aa = p12.GetAsymmetricAlgorithm (attrs);

			AssertNotNull ("GA.2", aa);
		}
Exemplo n.º 2
0
		public void GetAttributes_Test1 ()
		{
			PKCS12 p12 = new PKCS12 ();

			IDictionary attrs = new Hashtable ();
			ArrayList attrValues = new ArrayList ();
			attrValues.Add (Encoding.BigEndianUnicode.GetBytes ("Friendly name"));
			attrs.Add (PKCS9.friendlyName, attrValues);

			AsymmetricAlgorithm aa = RSA.Create ();
			p12.AddKeyBag (aa, attrs);

			AssertEquals ("GA1.1", p12.Keys.Count, 1);

			IDictionary pattrs = p12.GetAttributes (aa);

			Assert ("GA1.2", pattrs.Contains (PKCS9.friendlyName));
		}
Exemplo n.º 3
0
		public void RemoveKeyBag_Test ()
		{
			PKCS12 p12 = new PKCS12 ();

			p12.AddKeyBag (RSA.Create ());

			AssertEquals ("RK.1", p12.Keys.Count, 1);

			p12.RemoveKeyBag (RSA.Create ());

			AssertEquals ("RK.2", p12.Keys.Count, 0);
		}
Exemplo n.º 4
0
		public void AddKeyBag_Test2 ()
		{
			PKCS12 p12 = new PKCS12 ();

			IDictionary attrs = new Hashtable ();
			ArrayList attrValues = new ArrayList ();
			attrValues.Add (Encoding.BigEndianUnicode.GetBytes ("Friendly name"));
			attrs.Add (PKCS9.friendlyName, attrValues);

			p12.AddKeyBag (RSA.Create (), attrs);

			AssertEquals ("AK2", p12.Keys.Count, 1);
		}
Exemplo n.º 5
0
		public void AddKeyBag_Test1 ()
		{
			PKCS12 p12 = new PKCS12 ();

			p12.AddKeyBag (RSA.Create ());

			AssertEquals ("AK1", p12.Keys.Count, 1);
		}
Exemplo n.º 6
0
		public void RemoveKeyBag_Test ()
		{
			PKCS12 p12 = new PKCS12 ();
			RSAManaged rsa = new RSAManaged (384);
			p12.AddKeyBag (rsa);
			Assert.AreEqual (1, p12.Keys.Count, "RK.1");

			RSAManaged rsa2 = new RSAManaged (384);
			p12.RemoveKeyBag (rsa2);
			Assert.AreEqual (1, p12.Keys.Count, "RK.2");

			p12.RemoveKeyBag (rsa);
			Assert.AreEqual (0, p12.Keys.Count, "RK.3");
		}
Exemplo n.º 7
0
		public void AddKeyBag_Test1 ()
		{
			PKCS12 p12 = new PKCS12 ();

			p12.AddKeyBag (RSA.Create ());

			Assert.AreEqual (1, p12.Keys.Count, "AK1");
		}