Esempio n. 1
0
		public Task Destroy (TestContext ctx, CancellationToken cancellationToken)
		{
			return Task.Run (() => {
				if (crypto != null) {
					crypto.Dispose ();
					crypto = null;
				}
			});
		}
Esempio n. 2
0
		public Task Initialize (TestContext ctx, CancellationToken cancellationToken)
		{
			return Task.Run (() => {
				if (Parameters == null)
					return;

				cipher = CipherSuiteFactory.CreateCipherSuite (Parameters.Protocol, Parameters.Code);

				if (Parameters.IsGCM) {
					crypto = new MyGaloisCounterCipher (Parameters, cipher);

					crypto.ServerWriteKey = SecureBuffer.CreateCopy (Parameters.Key);
					crypto.ClientWriteKey = SecureBuffer.CreateCopy (Parameters.Key);
					crypto.ServerWriteIV = SecureBuffer.CreateCopy (Parameters.ImplicitNonce);
					crypto.ClientWriteIV = SecureBuffer.CreateCopy (Parameters.ImplicitNonce);

					crypto.InitializeCipher ();
				} else {
					crypto = new MyCbcBlockCipher (Parameters, cipher);

					crypto.ServerWriteKey = SecureBuffer.CreateCopy (Parameters.Key);
					crypto.ClientWriteKey = SecureBuffer.CreateCopy (Parameters.Key);
					crypto.ServerWriteMac = SecureBuffer.CreateCopy (Parameters.MAC);
					crypto.ClientWriteMac = SecureBuffer.CreateCopy (Parameters.MAC);

					crypto.InitializeCipher ();
				}
			});
		}