예제 #1
0
        SecurityStatus _EncryptMessage(ref TlsBuffer incoming)
        {
            var buffer = EncodeRecord(ContentType.ApplicationData, incoming.GetRemaining());

            incoming = new TlsBuffer(buffer);
            return(SecurityStatus.OK);
        }
예제 #2
0
        bool DecryptRecordFragment(ContentType contentType, ref TlsBuffer buffer)
        {
            var read = Session.Read;

            if (read == null || read.Cipher == null)
            {
                return(false);
            }

            var output = read.Decrypt(contentType, buffer.GetRemaining());

            buffer = new TlsBuffer(output);
            return(true);
        }
예제 #3
0
        SecurityStatus _EncryptMessage(ref TlsBuffer incoming)
        {
                        #if DEBUG_FULL
            if (EnableDebugging)
            {
                DebugHelper.WriteRemaining("EncryptMessage", incoming);
            }
                        #endif

            var buffer = EncodeRecord(ContentType.ApplicationData, incoming.GetRemaining());

                        #if DEBUG_FULL
            if (EnableDebugging)
            {
                DebugHelper.WriteBuffer("EncryptMessage done", buffer);
            }
                        #endif

            incoming = new TlsBuffer(buffer);
            return(SecurityStatus.OK);
        }
예제 #4
0
		public void TestDecrypt (TestContext ctx, [TestHost] IEncryptionTestHost host)
		{
			var input = GetBuffer (HelloWorldResult);
			var output = new TlsBuffer (input.Size);

			var hello = GetField (HelloWorldName);

			var length = host.Decrypt (input, output.GetRemaining ());
			ctx.Assert (length, Is.EqualTo (hello.Length), "#1");

			output.Position = 0;
			var decrypted = output.ReadBytes (length);
			ctx.Assert (decrypted, Is.EqualTo (hello), "#4");
		}
예제 #5
0
		public void TestOutputOffset (TestContext ctx, [TestHost] IEncryptionTestHost host)
		{
			var input =  GetBuffer (HelloWorldName);

			var output = new TlsBuffer (input.Size + host.MaxExtraEncryptedBytes + MagicDataSize);
			output.Write (GetBuffer (MagicDataName));

			var startOffset = output.Offset;
			var startPos = output.Position;
			var startSize = output.Size;

			var length = host.Encrypt (input, output.GetRemaining ());

			ctx.Assert (length, Is.GreaterThanOrEqualTo (0), "#1");
			ctx.Assert (length, Is.GreaterThanOrEqualTo (input.Size + host.MinExtraEncryptedBytes), "#2a");
			ctx.Assert (length, Is.LessThanOrEqualTo (input.Size + host.MaxExtraEncryptedBytes), "#2a");
			ctx.Assert (output.Offset, Is.EqualTo (startOffset), "#2b");
			ctx.Assert (output.Size, Is.EqualTo (startSize), "#2c");

			output.Position = 0;
			var magic = output.ReadBytes (MagicDataSize);
			ctx.Assert (magic, Is.EqualTo (GetField (MagicDataName)), "#3");

			var encrypted = output.ReadBytes (length);
			CheckOutput (ctx, HelloWorldResult, new BufferOffsetSize (encrypted));
		}