示例#1
0
        public void Test_11_Invalid_Example3_C3()
        {
            // §C.3
            using (AesCcm AesCcm = new AesCcm(128, 64 / 8, 96 / 8))
            {
                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0xe4, 0xb2, 0x01, 0xa9, 0xf5, 0xb7, 0x1a, 0x7a, 0x9b, 0x1c, 0xea, 0xec, 0xcd, 0x97, 0xe7, 0x0b, 0x61, 0x76, 0xaa, 0xd9, 0xa4, 0x42, 0x8a, 0xa5, 0x48, 0x43, 0x92, 0xfb, 0xc1, 0xb0, 0x99, 0x51 }, // C
                    new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 },                                                                         // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b },                                                                                                                         // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                                                                                                // K

                Assert.IsNull(Plainttext);
            }
        }
示例#2
0
        public void Test_10_Invalid_Example2_C2()
        {
            // §C.2
            using (AesCcm AesCcm = new AesCcm(128, 48 / 8, 64 / 8))
            {
                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0xd3, 0xa1, 0xf0, 0xe0, 0x51, 0xea, 0x5f, 0x62, 0x08, 0x1a, 0x77, 0x92, 0x07, 0x3d, 0x59, 0x3d, 0x1f, 0xc6, 0x4f, 0xbf, 0xac, 0xcd }, // C
                    new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },                                     // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },                                                                                     // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                                    // K

                Assert.IsNull(Plainttext);
            }
        }
示例#3
0
        public void Test_09_Invalid_Example1_C1()
        {
            // §C.1
            using (AesCcm AesCcm = new AesCcm(128, 32 / 8, 56 / 8))
            {
                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0x72, 0x62, 0x01, 0x5b, 0x4d, 0xac, 0x25, 0x5d },                                                                      // C
                    new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },                                                                      // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 },                                                                            // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                     // K

                Assert.IsNull(Plainttext);
            }
        }
示例#4
0
        public void Test_07_Decrypt_Example3_C3()
        {
            // §C.3
            using (AesCcm AesCcm = new AesCcm(128, 64 / 8, 96 / 8))
            {
                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0xe3, 0xb2, 0x01, 0xa9, 0xf5, 0xb7, 0x1a, 0x7a, 0x9b, 0x1c, 0xea, 0xec, 0xcd, 0x97, 0xe7, 0x0b, 0x61, 0x76, 0xaa, 0xd9, 0xa4, 0x42, 0x8a, 0xa5, 0x48, 0x43, 0x92, 0xfb, 0xc1, 0xb0, 0x99, 0x51 }, // C
                    new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 },                                                                         // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b },                                                                                                                         // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                                                                                                // K

                AssertEqual(new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 }, Plainttext);
            }
        }
示例#5
0
        public void Test_06_Decrypt_Example2_C2()
        {
            // §C.2
            using (AesCcm AesCcm = new AesCcm(128, 48 / 8, 64 / 8))
            {
                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0xd2, 0xa1, 0xf0, 0xe0, 0x51, 0xea, 0x5f, 0x62, 0x08, 0x1a, 0x77, 0x92, 0x07, 0x3d, 0x59, 0x3d, 0x1f, 0xc6, 0x4f, 0xbf, 0xac, 0xcd }, // C
                    new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },                                     // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },                                                                                     // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                                    // K

                AssertEqual(new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f }, Plainttext);
            }
        }
示例#6
0
        public void Test_12_Invalid_Example4_C4()
        {
            // §C.4
            using (AesCcm AesCcm = new AesCcm(128, 112 / 8, 104 / 8))
            {
                byte[] AD = new byte[65536];
                int    i;

                for (i = 0; i < 65536; i++)
                {
                    AD[i] = (byte)i;
                }

                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0x6a, 0x91, 0x5d, 0xad, 0x1e, 0x84, 0xc6, 0x37, 0x6a, 0x68, 0xc2, 0x96, 0x7e, 0x4d, 0xab, 0x61, 0x5a, 0xe0, 0xfd, 0x1f, 0xae, 0xc4, 0x4c, 0xc4, 0x84, 0x82, 0x85, 0x29, 0x46, 0x3c, 0xcf, 0x72, 0xb4, 0xac, 0x6b, 0xec, 0x93, 0xe8, 0x59, 0x8e, 0x7f, 0x0d, 0xad, 0xbc, 0xea, 0x5b }, // C
                    AD,                                                                                                                                                                                                                                                                                                // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c },                                                                                                                                                                                                       // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                                                                                                                                                                                    // K

                Assert.IsNull(Plainttext);
            }
        }
示例#7
0
        public void Test_08_Decrypt_Example4_C4()
        {
            // §C.4
            using (AesCcm AesCcm = new AesCcm(128, 112 / 8, 104 / 8))
            {
                byte[] AD = new byte[65536];
                int    i;

                for (i = 0; i < 65536; i++)
                {
                    AD[i] = (byte)i;
                }

                byte[] Plainttext = AesCcm.AuthenticateAndDecrypt(
                    new byte[] { 0x69, 0x91, 0x5d, 0xad, 0x1e, 0x84, 0xc6, 0x37, 0x6a, 0x68, 0xc2, 0x96, 0x7e, 0x4d, 0xab, 0x61, 0x5a, 0xe0, 0xfd, 0x1f, 0xae, 0xc4, 0x4c, 0xc4, 0x84, 0x82, 0x85, 0x29, 0x46, 0x3c, 0xcf, 0x72, 0xb4, 0xac, 0x6b, 0xec, 0x93, 0xe8, 0x59, 0x8e, 0x7f, 0x0d, 0xad, 0xbc, 0xea, 0x5b }, // C
                    AD,                                                                                                                                                                                                                                                                                                // A
                    new byte[] { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c },                                                                                                                                                                                                       // N
                    new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f });                                                                                                                                                                                    // K

                AssertEqual(new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f }, Plainttext);
            }
        }