Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: net/quic/crypto/aes_128_gcm_12_encrypter_test.cc

Issue 1541263002: Landing Recent QUIC changes until 12/18/2015 13:57 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: replace -1 with 0xff for InvalidPathId Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 5 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
6 6
7 #include "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 8
9 using base::StringPiece; 9 using base::StringPiece;
10 using std::string; 10 using std::string;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // length, plaintext length, AAD length, and tag length. 46 // length, plaintext length, AAD length, and tag length.
47 struct TestGroupInfo { 47 struct TestGroupInfo {
48 size_t key_len; 48 size_t key_len;
49 size_t iv_len; 49 size_t iv_len;
50 size_t pt_len; 50 size_t pt_len;
51 size_t aad_len; 51 size_t aad_len;
52 size_t tag_len; 52 size_t tag_len;
53 }; 53 };
54 54
55 // Each test vector consists of six strings of lowercase hexadecimal digits. 55 // Each test vector consists of six strings of lowercase hexadecimal digits.
56 // The strings may be empty (zero length). A test vector with a NULL |key| 56 // The strings may be empty (zero length). A test vector with a nullptr |key|
57 // marks the end of an array of test vectors. 57 // marks the end of an array of test vectors.
58 struct TestVector { 58 struct TestVector {
59 const char* key; 59 const char* key;
60 const char* iv; 60 const char* iv;
61 const char* pt; 61 const char* pt;
62 const char* aad; 62 const char* aad;
63 const char* ct; 63 const char* ct;
64 const char* tag; 64 const char* tag;
65 }; 65 };
66 66
67 const TestGroupInfo test_group_info[] = { 67 const TestGroupInfo test_group_info[] = {
68 {128, 96, 0, 0, 128}, {128, 96, 0, 128, 128}, {128, 96, 128, 0, 128}, 68 {128, 96, 0, 0, 128}, {128, 96, 0, 128, 128}, {128, 96, 128, 0, 128},
69 {128, 96, 408, 160, 128}, {128, 96, 408, 720, 128}, {128, 96, 104, 0, 128}, 69 {128, 96, 408, 160, 128}, {128, 96, 408, 720, 128}, {128, 96, 104, 0, 128},
70 }; 70 };
71 71
72 const TestVector test_group_0[] = { 72 const TestVector test_group_0[] = {
73 {"11754cd72aec309bf52f7687212e8957", "3c819d9a9bed087615030b65", "", "", "", 73 {"11754cd72aec309bf52f7687212e8957", "3c819d9a9bed087615030b65", "", "", "",
74 "250327c674aaf477aef2675748cf6971"}, 74 "250327c674aaf477aef2675748cf6971"},
75 {"ca47248ac0b6f8372a97ac43508308ed", "ffd2b598feabc9019262d2be", "", "", "", 75 {"ca47248ac0b6f8372a97ac43508308ed", "ffd2b598feabc9019262d2be", "", "", "",
76 "60d20404af527d248d893ae495707d1a"}, 76 "60d20404af527d248d893ae495707d1a"},
77 {NULL}}; 77 {nullptr}};
78 78
79 const TestVector test_group_1[] = { 79 const TestVector test_group_1[] = {
80 {"77be63708971c4e240d1cb79e8d77feb", "e0e00f19fed7ba0136a797f3", "", 80 {"77be63708971c4e240d1cb79e8d77feb", "e0e00f19fed7ba0136a797f3", "",
81 "7a43ec1d9c0a5a78a0b16533a6213cab", "", 81 "7a43ec1d9c0a5a78a0b16533a6213cab", "",
82 "209fcc8d3675ed938e9c7166709dd946"}, 82 "209fcc8d3675ed938e9c7166709dd946"},
83 {"7680c5d3ca6154758e510f4d25b98820", "f8f105f9c3df4965780321f8", "", 83 {"7680c5d3ca6154758e510f4d25b98820", "f8f105f9c3df4965780321f8", "",
84 "c94c410194c765e3dcc7964379758ed3", "", 84 "c94c410194c765e3dcc7964379758ed3", "",
85 "94dca8edfcf90bb74b153c8d48a17930"}, 85 "94dca8edfcf90bb74b153c8d48a17930"},
86 {NULL}}; 86 {nullptr}};
87 87
88 const TestVector test_group_2[] = { 88 const TestVector test_group_2[] = {
89 {"7fddb57453c241d03efbed3ac44e371c", "ee283a3fc75575e33efd4887", 89 {"7fddb57453c241d03efbed3ac44e371c", "ee283a3fc75575e33efd4887",
90 "d5de42b461646c255c87bd2962d3b9a2", "", "2ccda4a5415cb91e135c2a0f78c9b2fd", 90 "d5de42b461646c255c87bd2962d3b9a2", "", "2ccda4a5415cb91e135c2a0f78c9b2fd",
91 "b36d1df9b9d5e596f83e8b7f52971cb3"}, 91 "b36d1df9b9d5e596f83e8b7f52971cb3"},
92 {"ab72c77b97cb5fe9a382d9fe81ffdbed", "54cc7dc2c37ec006bcc6d1da", 92 {"ab72c77b97cb5fe9a382d9fe81ffdbed", "54cc7dc2c37ec006bcc6d1da",
93 "007c5e5b3e59df24a7c355584fc1518d", "", "0e1bde206a07a9c2c1b65300f8c64997", 93 "007c5e5b3e59df24a7c355584fc1518d", "", "0e1bde206a07a9c2c1b65300f8c64997",
94 "2b4401346697138c7a4891ee59867d0c"}, 94 "2b4401346697138c7a4891ee59867d0c"},
95 {NULL}}; 95 {nullptr}};
96 96
97 const TestVector test_group_3[] = { 97 const TestVector test_group_3[] = {
98 {"fe47fcce5fc32665d2ae399e4eec72ba", "5adb9609dbaeb58cbd6e7275", 98 {"fe47fcce5fc32665d2ae399e4eec72ba", "5adb9609dbaeb58cbd6e7275",
99 "7c0e88c88899a779228465074797cd4c2e1498d259b54390b85e3eef1c02df60e743f1" 99 "7c0e88c88899a779228465074797cd4c2e1498d259b54390b85e3eef1c02df60e743f1"
100 "b840382c4bccaf3bafb4ca8429bea063", 100 "b840382c4bccaf3bafb4ca8429bea063",
101 "88319d6e1d3ffa5f987199166c8a9b56c2aeba5a", 101 "88319d6e1d3ffa5f987199166c8a9b56c2aeba5a",
102 "98f4826f05a265e6dd2be82db241c0fbbbf9ffb1c173aa83964b7cf539304373636525" 102 "98f4826f05a265e6dd2be82db241c0fbbbf9ffb1c173aa83964b7cf539304373636525"
103 "3ddbc5db8778371495da76d269e5db3e", 103 "3ddbc5db8778371495da76d269e5db3e",
104 "291ef1982e4defedaa2249f898556b47"}, 104 "291ef1982e4defedaa2249f898556b47"},
105 {"ec0c2ba17aa95cd6afffe949da9cc3a8", "296bce5b50b7d66096d627ef", 105 {"ec0c2ba17aa95cd6afffe949da9cc3a8", "296bce5b50b7d66096d627ef",
106 "b85b3753535b825cbe5f632c0b843c741351f18aa484281aebec2f45bb9eea2d79d987" 106 "b85b3753535b825cbe5f632c0b843c741351f18aa484281aebec2f45bb9eea2d79d987"
107 "b764b9611f6c0f8641843d5d58f3a242", 107 "b764b9611f6c0f8641843d5d58f3a242",
108 "f8d00f05d22bf68599bcdeb131292ad6e2df5d14", 108 "f8d00f05d22bf68599bcdeb131292ad6e2df5d14",
109 "a7443d31c26bdf2a1c945e29ee4bd344a99cfaf3aa71f8b3f191f83c2adfc7a0716299" 109 "a7443d31c26bdf2a1c945e29ee4bd344a99cfaf3aa71f8b3f191f83c2adfc7a0716299"
110 "5506fde6309ffc19e716eddf1a828c5a", 110 "5506fde6309ffc19e716eddf1a828c5a",
111 "890147971946b627c40016da1ecf3e77"}, 111 "890147971946b627c40016da1ecf3e77"},
112 {NULL}}; 112 {nullptr}};
113 113
114 const TestVector test_group_4[] = { 114 const TestVector test_group_4[] = {
115 {"2c1f21cf0f6fb3661943155c3e3d8492", "23cb5ff362e22426984d1907", 115 {"2c1f21cf0f6fb3661943155c3e3d8492", "23cb5ff362e22426984d1907",
116 "42f758836986954db44bf37c6ef5e4ac0adaf38f27252a1b82d02ea949c8a1a2dbc0d6" 116 "42f758836986954db44bf37c6ef5e4ac0adaf38f27252a1b82d02ea949c8a1a2dbc0d6"
117 "8b5615ba7c1220ff6510e259f06655d8", 117 "8b5615ba7c1220ff6510e259f06655d8",
118 "5d3624879d35e46849953e45a32a624d6a6c536ed9857c613b572b0333e701557a713e" 118 "5d3624879d35e46849953e45a32a624d6a6c536ed9857c613b572b0333e701557a713e"
119 "3f010ecdf9a6bd6c9e3e44b065208645aff4aabee611b391528514170084ccf587177f" 119 "3f010ecdf9a6bd6c9e3e44b065208645aff4aabee611b391528514170084ccf587177f"
120 "4488f33cfb5e979e42b6e1cfc0a60238982a7aec", 120 "4488f33cfb5e979e42b6e1cfc0a60238982a7aec",
121 "81824f0e0d523db30d3da369fdc0d60894c7a0a20646dd015073ad2732bd989b14a222" 121 "81824f0e0d523db30d3da369fdc0d60894c7a0a20646dd015073ad2732bd989b14a222"
122 "b6ad57af43e1895df9dca2a5344a62cc", 122 "b6ad57af43e1895df9dca2a5344a62cc",
123 "57a3ee28136e94c74838997ae9823f3a"}, 123 "57a3ee28136e94c74838997ae9823f3a"},
124 {"d9f7d2411091f947b4d6f1e2d1f0fb2e", "e1934f5db57cc983e6b180e7", 124 {"d9f7d2411091f947b4d6f1e2d1f0fb2e", "e1934f5db57cc983e6b180e7",
125 "73ed042327f70fe9c572a61545eda8b2a0c6e1d6c291ef19248e973aee6c312012f490" 125 "73ed042327f70fe9c572a61545eda8b2a0c6e1d6c291ef19248e973aee6c312012f490"
126 "c2c6f6166f4a59431e182663fcaea05a", 126 "c2c6f6166f4a59431e182663fcaea05a",
127 "0a8a18a7150e940c3d87b38e73baee9a5c049ee21795663e264b694a949822b639092d" 127 "0a8a18a7150e940c3d87b38e73baee9a5c049ee21795663e264b694a949822b639092d"
128 "0e67015e86363583fcf0ca645af9f43375f05fdb4ce84f411dcbca73c2220dea03a201" 128 "0e67015e86363583fcf0ca645af9f43375f05fdb4ce84f411dcbca73c2220dea03a201"
129 "15d2e51398344b16bee1ed7c499b353d6c597af8", 129 "15d2e51398344b16bee1ed7c499b353d6c597af8",
130 "aaadbd5c92e9151ce3db7210b8714126b73e43436d242677afa50384f2149b831f1d57" 130 "aaadbd5c92e9151ce3db7210b8714126b73e43436d242677afa50384f2149b831f1d57"
131 "3c7891c2a91fbc48db29967ec9542b23", 131 "3c7891c2a91fbc48db29967ec9542b23",
132 "21b51ca862cb637cdd03b99a0f93b134"}, 132 "21b51ca862cb637cdd03b99a0f93b134"},
133 {NULL}}; 133 {nullptr}};
134 134
135 const TestVector test_group_5[] = { 135 const TestVector test_group_5[] = {
136 {"fe9bb47deb3a61e423c2231841cfd1fb", "4d328eb776f500a2f7fb47aa", 136 {"fe9bb47deb3a61e423c2231841cfd1fb", "4d328eb776f500a2f7fb47aa",
137 "f1cc3818e421876bb6b8bbd6c9", "", "b88c5c1977b35b517b0aeae967", 137 "f1cc3818e421876bb6b8bbd6c9", "", "b88c5c1977b35b517b0aeae967",
138 "43fd4727fe5cdb4b5b42818dea7ef8c9"}, 138 "43fd4727fe5cdb4b5b42818dea7ef8c9"},
139 {"6703df3701a7f54911ca72e24dca046a", "12823ab601c350ea4bc2488c", 139 {"6703df3701a7f54911ca72e24dca046a", "12823ab601c350ea4bc2488c",
140 "793cd125b0b84a043e3ac67717", "", "b2051c80014f42f08735a7b0cd", 140 "793cd125b0b84a043e3ac67717", "", "b2051c80014f42f08735a7b0cd",
141 "38e6bcd29962e5f2c13626b85a877101"}, 141 "38e6bcd29962e5f2c13626b85a877101"},
142 {NULL}}; 142 {nullptr}};
143 143
144 const TestVector* const test_group_array[] = { 144 const TestVector* const test_group_array[] = {
145 test_group_0, test_group_1, test_group_2, 145 test_group_0, test_group_1, test_group_2,
146 test_group_3, test_group_4, test_group_5, 146 test_group_3, test_group_4, test_group_5,
147 }; 147 };
148 148
149 } // namespace 149 } // namespace
150 150
151 namespace net { 151 namespace net {
152 namespace test { 152 namespace test {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 TEST(Aes128Gcm12EncrypterTest, GetCiphertextSize) { 233 TEST(Aes128Gcm12EncrypterTest, GetCiphertextSize) {
234 Aes128Gcm12Encrypter encrypter; 234 Aes128Gcm12Encrypter encrypter;
235 EXPECT_EQ(1012u, encrypter.GetCiphertextSize(1000)); 235 EXPECT_EQ(1012u, encrypter.GetCiphertextSize(1000));
236 EXPECT_EQ(112u, encrypter.GetCiphertextSize(100)); 236 EXPECT_EQ(112u, encrypter.GetCiphertextSize(100));
237 EXPECT_EQ(22u, encrypter.GetCiphertextSize(10)); 237 EXPECT_EQ(22u, encrypter.GetCiphertextSize(10));
238 } 238 }
239 239
240 } // namespace test 240 } // namespace test
241 } // namespace net 241 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/aes_128_gcm_12_decrypter_test.cc ('k') | net/quic/crypto/chacha20_poly1305_decrypter_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698