Example #1
0
        public void TransformBlock_OutputBuffer_Null()
        {
            byte[]      input = new byte [1];
            ARC4Managed rc4   = new ARC4Managed();

            rc4.TransformBlock(input, 0, 1, null, 0);
        }
Example #2
0
        public void TransformBlock_OutputOffset_Overflow()
        {
            byte[]      input  = new byte [1];
            byte[]      output = new byte [1];
            ARC4Managed rc4    = new ARC4Managed();

            rc4.TransformBlock(input, 0, 1, output, Int32.MaxValue);
        }
Example #3
0
        public void TransformBlock_OutputOffset_Negative()
        {
            byte[]      input  = new byte [1];
            byte[]      output = new byte [1];
            ARC4Managed rc4    = new ARC4Managed();

            rc4.TransformBlock(input, 0, 1, output, -1);
        }
Example #4
0
        public void TransformBlock_InputCount_Overflow()
        {
            byte[]      input  = new byte [1];
            byte[]      output = new byte [1];
            ARC4Managed rc4    = new ARC4Managed();

            rc4.TransformBlock(input, 1, Int32.MaxValue, output, 0);
        }
Example #5
0
        public void TransformBlock_InputCount_Negative()
        {
            byte[]      input  = new byte [1];
            byte[]      output = new byte [1];
            ARC4Managed rc4    = new ARC4Managed();

            rc4.TransformBlock(input, 0, -1, output, 0);
        }
Example #6
0
        public void SSLServer()
        {
            byte[]      encryptedData = { 0x54, 0x3c, 0xe1, 0xe7, 0x4d, 0x77, 0x76, 0x62, 0x86, 0xfa, 0x4e, 0x0a, 0x6f, 0x5f, 0x6a, 0x3d, 0x43, 0x26, 0xf4, 0xad, 0x8d, 0x3e, 0x09, 0x0b, 0x2b, 0xf7, 0x9f, 0x49, 0x44, 0x92, 0xfb, 0xa9, 0xa4, 0xb0, 0x5a, 0xd8, 0x72, 0x77, 0x6e, 0x8b, 0xb3, 0x78, 0xfb, 0xda, 0xe0, 0x25, 0xef, 0xb3, 0xf5, 0xa7, 0x90, 0x08, 0x6d, 0x60, 0xd5, 0x4e };
            ARC4Managed rc4           = new ARC4Managed();

            rc4.Key = serverWriteKey;
            // decrypt inplace (in same buffer)
            rc4.TransformBlock(encryptedData, 0, encryptedData.Length, encryptedData, 0);
            byte[] expectedData = { 0x14, 0x00, 0x00, 0x24, 0xb7, 0xcc, 0xd6, 0x05, 0x6b, 0xfc, 0xfa, 0x6d, 0xfa, 0xdd, 0x76, 0x81, 0x45, 0x36, 0xe4, 0xf4, 0x26, 0x35, 0x72, 0x2c, 0xec, 0x87, 0x62, 0x1f, 0x55, 0x08, 0x05, 0x4f, 0xc8, 0xf5, 0x7c, 0x49, 0xe2, 0xee, 0xc5, 0xba, 0xbd, 0x69, 0x27, 0x3b, 0xd0, 0x13, 0x23, 0x52, 0xed, 0xec, 0x11, 0x55, 0xd8, 0xb9, 0x90, 0x8c };
            AssertEquals("RC4 - Server's Finished Handshake", expectedData, encryptedData);
        }
Example #7
0
        public void SSLClient()
        {
            byte[]      data = { 0x14, 0x00, 0x00, 0x24, 0xf2, 0x40, 0x10, 0x3f, 0x74, 0x63, 0xea, 0xe8, 0x7a, 0x27, 0x23, 0x56, 0x5f, 0x59, 0x07, 0xd2, 0xa3, 0x79, 0x5d, 0xb7, 0x8b, 0x94, 0xdb, 0xcf, 0xfa, 0xf5, 0x18, 0x22, 0x15, 0x7b, 0xf2, 0x4a, 0x96, 0x52, 0x9a, 0x0e, 0xd3, 0x09, 0xde, 0x28, 0x84, 0xa7, 0x07, 0x5c, 0x7c, 0x0c, 0x08, 0x85, 0x6b, 0x4f, 0x63, 0x04 };
            ARC4Managed rc4  = new ARC4Managed();

            rc4.Key = clientWriteKey;
            // encrypt inplace (in same buffer)
            rc4.TransformBlock(data, 0, data.Length, data, 0);
            byte[] expectedData = { 0xed, 0x37, 0x7f, 0x16, 0xd3, 0x11, 0xe8, 0xa3, 0xe1, 0x2a, 0x20, 0xb7, 0x88, 0xf6, 0x11, 0xf3, 0xa6, 0x7d, 0x37, 0xf7, 0x17, 0xac, 0x67, 0x20, 0xb8, 0x0e, 0x88, 0xd1, 0xa0, 0xc6, 0x83, 0xe4, 0x80, 0xe8, 0xc7, 0xe3, 0x0b, 0x91, 0x29, 0x30, 0x29, 0xe4, 0x28, 0x47, 0xb7, 0x40, 0xa4, 0xd1, 0x3c, 0xda, 0x82, 0xb7, 0xb3, 0x9f, 0x67, 0x10 };
            AssertEquals("RC4 - Client's Finished Handshake", expectedData, data);
        }
Example #8
0
 public int Decrypt(byte[] buffer, int start, int count)
 {
     // Use TransformBlock instead of TransformFinalBlock to avoid too many array allocations.
     return(_decrypt.TransformBlock(buffer, start, count, buffer, start));
 }