| 1 |
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 OR ISC |
| 3 |
|
| 4 |
#include <gtest/gtest.h> |
| 5 |
|
| 6 |
#include "../crypto/test/file_util.h" |
| 7 |
#include "../crypto/test/test_util.h" |
| 8 |
#include "internal.h" |
| 9 |
#include "ssl_common_test.h" |
| 10 |
|
| 11 |
BSSL_NAMESPACE_BEGIN |
| 12 |
|
| 13 |
TEST(GrowableArrayTest, Resize) { |
| 14 |
GrowableArray<size_t> array; |
| 15 |
ASSERT_TRUE(array.empty()); |
| 16 |
EXPECT_EQ(array.size(), 0u); |
| 17 |
|
| 18 |
ASSERT_TRUE(array.Push(42)); |
| 19 |
ASSERT_TRUE(!array.empty()); |
| 20 |
EXPECT_EQ(array.size(), 1u); |
| 21 |
|
| 22 |
// Force a resize operation to occur |
| 23 |
for (size_t i = 0; i < 16; i++) { |
| 24 |
ASSERT_TRUE(array.Push(i + 1)); |
| 25 |
} |
| 26 |
|
| 27 |
EXPECT_EQ(array.size(), 17u); |
| 28 |
|
| 29 |
// Verify that expected values are still contained in array |
| 30 |
for (size_t i = 0; i < array.size(); i++) { |
| 31 |
EXPECT_EQ(array[i], i == 0 ? 42 : i); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
TEST(GrowableArrayTest, MoveConstructor) { |
| 36 |
GrowableArray<size_t> array; |
| 37 |
for (size_t i = 0; i < 100; i++) { |
| 38 |
ASSERT_TRUE(array.Push(i)); |
| 39 |
} |
| 40 |
|
| 41 |
GrowableArray<size_t> array_moved(std::move(array)); |
| 42 |
for (size_t i = 0; i < 100; i++) { |
| 43 |
EXPECT_EQ(array_moved[i], i); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
TEST(GrowableArrayTest, GrowableArrayContainingGrowableArrays) { |
| 48 |
// Representative example of a struct that contains a GrowableArray. |
| 49 |
struct TagAndArray { |
| 50 |
size_t tag; |
| 51 |
GrowableArray<size_t> array; |
| 52 |
}; |
| 53 |
|
| 54 |
GrowableArray<TagAndArray> array; |
| 55 |
for (size_t i = 0; i < 100; i++) { |
| 56 |
TagAndArray elem; |
| 57 |
elem.tag = i; |
| 58 |
for (size_t j = 0; j < i; j++) { |
| 59 |
ASSERT_TRUE(elem.array.Push(j)); |
| 60 |
} |
| 61 |
ASSERT_TRUE(array.Push(std::move(elem))); |
| 62 |
} |
| 63 |
EXPECT_EQ(array.size(), static_cast<size_t>(100)); |
| 64 |
|
| 65 |
GrowableArray<TagAndArray> array_moved(std::move(array)); |
| 66 |
EXPECT_EQ(array_moved.size(), static_cast<size_t>(100)); |
| 67 |
size_t count = 0; |
| 68 |
for (const TagAndArray &elem : array_moved) { |
| 69 |
// Test the square bracket operator returns the same value as iteration. |
| 70 |
EXPECT_EQ(&elem, &array_moved[count]); |
| 71 |
|
| 72 |
EXPECT_EQ(elem.tag, count); |
| 73 |
EXPECT_EQ(elem.array.size(), count); |
| 74 |
for (size_t j = 0; j < count; j++) { |
| 75 |
EXPECT_EQ(elem.array[j], j); |
| 76 |
} |
| 77 |
count++; |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
struct EncodeDecodeKATTestParam { |
| 83 |
const char *input; |
| 84 |
const char *output; |
| 85 |
}; |
| 86 |
|
| 87 |
static const EncodeDecodeKATTestParam kEncodeDecodeKATs[] = { |
| 88 |
// V1 input round-trips as V2 output |
| 89 |
{"308201173082011302010102020303020240003081fa0201010408000000000000000104" |
| 90 |
"0800000000000000010420000004d29e62f41ded4bb33d0faa6ffada380e2c489dfbfb44" |
| 91 |
"4f574e475244010420cf3926d1ec5a562a642935a8050222b0aed93ffd9d1cac682274d9" |
| 92 |
"42e99e42a604020000020100020103040cb9b409f5129440622f87f84402010c040c1f49" |
| 93 |
"e2e989c66a263e9c227502010c020100020100020100a05b3059020101020203030402cc" |
| 94 |
"a80400043085668dcf9f0921094ebd7f91bf2a8c60d276e4c279fd85a989402f67868232" |
| 95 |
"4fd8098dc19d900b856d0a77e048e3ced2a104020204d2a20402021c20a4020400b10301" |
| 96 |
"01ffb20302011da206040474657374a7030101ff020108020100a0030101ff", |
| 97 |
"3082011c3082011802010102020303020240003081fa02010304080000000000000001040" |
| 98 |
"800000000000000010420000004d29e62f41ded4bb33d0faa6ffada380e2c489dfbfb444f" |
| 99 |
"574e475244010420cf3926d1ec5a562a642935a8050222b0aed93ffd9d1cac682274d942e" |
| 100 |
"99e42a604020000020100020103040cb9b409f5129440622f87f84402010c040c1f49e2e9" |
| 101 |
"89c66a263e9c227502010c020100020100020100a05b3059020101020203030402cca8040" |
| 102 |
"0043085668dcf9f0921094ebd7f91bf2a8c60d276e4c279fd85a989402f678682324fd809" |
| 103 |
"8dc19d900b856d0a77e048e3ced2a104020204d2a20402021c20a4020400b1030101ffb20" |
| 104 |
"302011da206040474657374a7030101ff020108020100a0030101ffa203020100"}, |
| 105 |
// In runner.go, the test case "Basic-Server-TLS-Sync-SSL_Transfer" is used |
| 106 |
// to generate below bytes by adding print statement on the output of |
| 107 |
// |SSL_to_bytes| in bssl_shim.cc. |
| 108 |
// We've bumped the buffer size in the |previous_client/server_finished| |
| 109 |
// fields. This verifies that the original size is parsable and reencoded |
| 110 |
// with the new size. |
| 111 |
{"308201173082011302010102020303020240003081fa0201020408000000000000000104" |
| 112 |
"0800000000000000010420000004d29e62f41ded4bb33d0faa6ffada380e2c489dfbfb44" |
| 113 |
"4f574e475244010420cf3926d1ec5a562a642935a8050222b0aed93ffd9d1cac682274d9" |
| 114 |
"42e99e42a604020000020100020103040cb9b409f5129440622f87f84402010c040c1f49" |
| 115 |
"e2e989c66a263e9c227502010c020100020100020100a05b3059020101020203030402cc" |
| 116 |
"a80400043085668dcf9f0921094ebd7f91bf2a8c60d276e4c279fd85a989402f67868232" |
| 117 |
"4fd8098dc19d900b856d0a77e048e3ced2a104020204d2a20402021c20a4020400b10301" |
| 118 |
"01ffb20302011da206040474657374a7030101ff020108020100a0030101ff", |
| 119 |
"3082011c3082011802010102020303020240003081fa02010304080000000000000001040" |
| 120 |
"800000000000000010420000004d29e62f41ded4bb33d0faa6ffada380e2c489dfbfb444f" |
| 121 |
"574e475244010420cf3926d1ec5a562a642935a8050222b0aed93ffd9d1cac682274d942e" |
| 122 |
"99e42a604020000020100020103040cb9b409f5129440622f87f84402010c040c1f49e2e9" |
| 123 |
"89c66a263e9c227502010c020100020100020100a05b3059020101020203030402cca8040" |
| 124 |
"0043085668dcf9f0921094ebd7f91bf2a8c60d276e4c279fd85a989402f678682324fd809" |
| 125 |
"8dc19d900b856d0a77e048e3ced2a104020204d2a20402021c20a4020400b1030101ffb20" |
| 126 |
"302011da206040474657374a7030101ff020108020100a0030101ffa203020100"}, |
| 127 |
// In runner.go, the test case |
| 128 |
// "TLS-TLS13-AES_128_GCM_SHA256-server-SSL_Transfer" is used to generate |
| 129 |
// below bytes by adding print statement on the output of |SSL_to_bytes| in |
| 130 |
// bssl_shim.cc. |
| 131 |
// We've bumped the buffer size in the |previous_client/server_finished| |
| 132 |
// fields. This verifies that the original size is parsable and reencoded |
| 133 |
// with the new size. |
| 134 |
{"308203883082038402010102020304020240003082036a020102040800000000000000000" |
| 135 |
"408000000000000000004206beca5c14aff6b92757545948b883c6c175327814bedcf38a6" |
| 136 |
"b2e4c43bc02d180420a32aee5b7705a19e4bb2b47f4918199c76cee7245f1311bc4ba3888" |
| 137 |
"3d33f236a04020000020100020101040c000000000000000000000000020100040c000000" |
| 138 |
"000000000000000000020100020100020100020100a04e304c02010102020304040213010" |
| 139 |
"40004200b66320d38c8fa1b0dfe9e37fcf2bf0bafb43077fa31ed2f1220dd245cef4c4da1" |
| 140 |
"04020204d2a205020302a300a4020400b20302011db9050203093a80a206040474657374a" |
| 141 |
"b03020100ac03010100ad03010100ae03010100af03020100b032043034c0893be938bade" |
| 142 |
"e7029ca3cfea4c821dde48e03f0d07641cba33b247bc161c0000000000000000000000000" |
| 143 |
"0000000b103020120b232043094b319ed2f41ee11aa73e141a238e5724c04f2aa8298c16b" |
| 144 |
"43c910c40cc98d1500000000000000000000000000000000b303020120b432043015a178c" |
| 145 |
"e69c0110ad36da8d58ca8428d9615ff07fc6a4e1bbab026c1bb0c02180000000000000000" |
| 146 |
"0000000000000000b503020120b88201700482016c040000b20002a30056355452010000a" |
| 147 |
"027abfd1f1aa28cee6e8e2396112e8285f150768898158dbce97a1aef0a63fa6dda1002a4" |
| 148 |
"d75942a3739c11e4b25827f529ab59d22e34e0cf0b59b9336eb60edbb1f686c072ab33c30" |
| 149 |
"e784f876da5b4c7fddd67f4a2ffa995f8c9ccf2128200ae9668d626866b1b7c6bb111867a" |
| 150 |
"87ed2a96122736595374f8fe5343e6ca492b278b67b1571423f2c1bcb673922e9044e9094" |
| 151 |
"9975ff72ab4a0eb659d8de664cac600042a2a0000040000b20002a3009e8c6738010100a0" |
| 152 |
"27abfd1f1aa28cee6e8e2396112e82851f15c84668b2f1d717681d1a3c6d2ea52d3401d31" |
| 153 |
"10a04498246480b96a7e5b3c39ea6cef3a2a86b81896f1621950472d858d18796c97e8320" |
| 154 |
"4daf94c1f30dfe763cd282fbee718a679dca8bff3cc8e11724062232e573bcf0252dc4d39" |
| 155 |
"0baa2b7f49a164b46d2d685e9fe826465cc135130f3e2e47838658af57173f864070fdce2" |
| 156 |
"41be58ecbd60d18128dfa28f4b1a00042a2a0000ba2330210201010204030013013016020" |
| 157 |
"101020117040e300c0201010201000201000101ffbb233021020101020403001301301602" |
| 158 |
"0101020117040e300c0201010201000201000101ff020108020100a0030101ff", |
| 159 |
"3082034a30820346020101020203040202400030820327020103040800000000000000000" |
| 160 |
"408000000000000000004206beca5c14aff6b92757545948b883c6c175327814bedcf38a6" |
| 161 |
"b2e4c43bc02d180420a32aee5b7705a19e4bb2b47f4918199c76cee7245f1311bc4ba3888" |
| 162 |
"3d33f236a0402000002010002010104000201000400020100020100020100020100a04e30" |
| 163 |
"4c0201010202030404021301040004200b66320d38c8fa1b0dfe9e37fcf2bf0bafb43077f" |
| 164 |
"a31ed2f1220dd245cef4c4da104020204d2a205020302a300a4020400b20302011db90502" |
| 165 |
"03093a80a206040474657374ab03020100ac03010100ad03010100ae03010100af0302010" |
| 166 |
"0b022042034c0893be938badee7029ca3cfea4c821dde48e03f0d07641cba33b247bc161c" |
| 167 |
"b103020120b222042094b319ed2f41ee11aa73e141a238e5724c04f2aa8298c16b43c910c" |
| 168 |
"40cc98d15b303020120b422042015a178ce69c0110ad36da8d58ca8428d9615ff07fc6a4e" |
| 169 |
"1bbab026c1bb0c0218b503020120b88201700482016c040000b20002a3005635545201000" |
| 170 |
"0a027abfd1f1aa28cee6e8e2396112e8285f150768898158dbce97a1aef0a63fa6dda1002" |
| 171 |
"a4d75942a3739c11e4b25827f529ab59d22e34e0cf0b59b9336eb60edbb1f686c072ab33c" |
| 172 |
"30e784f876da5b4c7fddd67f4a2ffa995f8c9ccf2128200ae9668d626866b1b7c6bb11186" |
| 173 |
"7a87ed2a96122736595374f8fe5343e6ca492b278b67b1571423f2c1bcb673922e9044e90" |
| 174 |
"949975ff72ab4a0eb659d8de664cac600042a2a0000040000b20002a3009e8c6738010100" |
| 175 |
"a027abfd1f1aa28cee6e8e2396112e82851f15c84668b2f1d717681d1a3c6d2ea52d3401d" |
| 176 |
"3110a04498246480b96a7e5b3c39ea6cef3a2a86b81896f1621950472d858d18796c97e83" |
| 177 |
"204daf94c1f30dfe763cd282fbee718a679dca8bff3cc8e11724062232e573bcf0252dc4d" |
| 178 |
"390baa2b7f49a164b46d2d685e9fe826465cc135130f3e2e47838658af57173f864070fdc" |
| 179 |
"e241be58ecbd60d18128dfa28f4b1a00042a2a0000ba23302102010102040300130130160" |
| 180 |
"20101020117040e300c0201010201000201000101ffbb2330210201010204030013013016" |
| 181 |
"020101020117040e300c0201010201000201000101ffbc030201ff020108020100a003010" |
| 182 |
"1ffa203020100"}, |
| 183 |
// In runner.go, the test case |
| 184 |
// "TLS-ECH-Server-Cipher-HKDF-SHA256-AES-256-GCM-SSL_Transfer" is used |
| 185 |
// to generate below bytes by adding print statement on the output of |
| 186 |
// |SSL_to_bytes| in bssl_shim.cc. |
| 187 |
{"308203e8308203e40201010202030402024000308203c5020102040800000000000000000" |
| 188 |
"4080000000000000000042028431b914ffdb44ea92ca53d5734976c6a16f141d44f180b08" |
| 189 |
"16a5cb2b8e79030420bdaf544fa82d833d58c92213e44e850cc0b8147699b0b410d4aa2a2" |
| 190 |
"77030f3220402000002010002010104409e155007d04cd03cf4d8a95ce244dc978a87e180" |
| 191 |
"8f0f6c6acb51ad7bf8063ae00000000000000000000000000000000000000000000000000" |
| 192 |
"00000000000000002012004406680e8c36429d465ea520ae74a2062a5e07c39f34b688024" |
| 193 |
"ae2edfab28986707000000000000000000000000000000000000000000000000000000000" |
| 194 |
"0000000020120020100020100020100a04e304c020101020203040402130304000420df74" |
| 195 |
"ecd172087ad53083d505145ec4f6cf0ec5ed64b67ba526d55c918a0f8936a104020204d2a" |
| 196 |
"205020302a300a4020400b20302011db9050203093a80a210040e7365637265742e657861" |
| 197 |
"6d706c65ab03020100ac03010100ad03010100ae03010100af03020100b0320430c40f9f9" |
| 198 |
"5646fa700d58934e79c36b84ba3502d33df04248d56cded3444927e300000000000000000" |
| 199 |
"0000000000000000b103020120b23204307a1a99bf276b5e5be57dd68968411594e77b1a4" |
| 200 |
"8cf2c03cc5c143985aa40b32e00000000000000000000000000000000b303020120b43204" |
| 201 |
"30cbf50af88bc5a610910139172a468663675882caacaf176aa961b12a38a0df2a0000000" |
| 202 |
"0000000000000000000000000b503020120b703020101b88201700482016c040000b20002" |
| 203 |
"a300bbccf972010000a041e0b13ecd71dfb3d9e3cb451e37cfde81973a1b73106b6669b53" |
| 204 |
"475781f0203a3f32f45cef7742cf0efb86d850081254f20d3b6bd8330bc70331464905bcd" |
| 205 |
"99383c33e42c7d34bfeb47b387bf43b5c796daa4581f8b0043b7eb216911f8eebaf1e8bd5" |
| 206 |
"d05277943d5a319cc03d9555e414990099f56ee887145f34e8bff27f06d1865aa64d548a2" |
| 207 |
"2208318566959a097c080fa3e5e0d4b1d933132ef329299500045a5a0000040000b20002a" |
| 208 |
"3002ecba343010100a041e0b13ecd71dfb3d9e3cb451e37cfde289f90201519fb0dff08aa" |
| 209 |
"9e14a9f4ee1434edce481e49d22f061529bb4d230258f3dac886c2c1100bee2ccc7be889a" |
| 210 |
"90b417270c30b3b770558ef6f3c444ddefd08e673f788931d86542c4a1e7ec44b0957bb31" |
| 211 |
"5c17851bd8498b1d1131a79e19c66463e0566985ef55deb548fe370058ba83566278d01b3" |
| 212 |
"a565075b8ef2a82bea17ae95fa91b7b3ffa611a7d8a633100045a5a0000ba153013020101" |
| 213 |
"02040300130330080201010201050400bb153013020101020403001303300802010102010" |
| 214 |
"50400020108020100a0030101ffa203020100", |
| 215 |
"3082037d3082037902010102020304020240003082035a020103040800000000000000000" |
| 216 |
"4080000000000000000042028431b914ffdb44ea92ca53d5734976c6a16f141d44f180b08" |
| 217 |
"16a5cb2b8e79030420bdaf544fa82d833d58c92213e44e850cc0b8147699b0b410d4aa2a2" |
| 218 |
"77030f3220402000002010002010104209e155007d04cd03cf4d8a95ce244dc978a87e180" |
| 219 |
"8f0f6c6acb51ad7bf8063ae002012004206680e8c36429d465ea520ae74a2062a5e07c39f" |
| 220 |
"34b688024ae2edfab28986707020120020100020100020100a04e304c0201010202030404" |
| 221 |
"02130304000420df74ecd172087ad53083d505145ec4f6cf0ec5ed64b67ba526d55c918a0" |
| 222 |
"f8936a104020204d2a205020302a300a4020400b20302011db9050203093a80a210040e73" |
| 223 |
"65637265742e6578616d706c65ab03020100ac03010100ad03010100ae03010100af03020" |
| 224 |
"100b0220420c40f9f95646fa700d58934e79c36b84ba3502d33df04248d56cded3444927e" |
| 225 |
"30b103020120b22204207a1a99bf276b5e5be57dd68968411594e77b1a48cf2c03cc5c143" |
| 226 |
"985aa40b32eb303020120b4220420cbf50af88bc5a610910139172a468663675882caacaf" |
| 227 |
"176aa961b12a38a0df2ab503020120b703020101b88201700482016c040000b20002a300b" |
| 228 |
"bccf972010000a041e0b13ecd71dfb3d9e3cb451e37cfde81973a1b73106b6669b5347578" |
| 229 |
"1f0203a3f32f45cef7742cf0efb86d850081254f20d3b6bd8330bc70331464905bcd99383" |
| 230 |
"c33e42c7d34bfeb47b387bf43b5c796daa4581f8b0043b7eb216911f8eebaf1e8bd5d0527" |
| 231 |
"7943d5a319cc03d9555e414990099f56ee887145f34e8bff27f06d1865aa64d548a222083" |
| 232 |
"18566959a097c080fa3e5e0d4b1d933132ef329299500045a5a0000040000b20002a3002e" |
| 233 |
"cba343010100a041e0b13ecd71dfb3d9e3cb451e37cfde289f90201519fb0dff08aa9e14a" |
| 234 |
"9f4ee1434edce481e49d22f061529bb4d230258f3dac886c2c1100bee2ccc7be889a90b41" |
| 235 |
"7270c30b3b770558ef6f3c444ddefd08e673f788931d86542c4a1e7ec44b0957bb315c178" |
| 236 |
"51bd8498b1d1131a79e19c66463e0566985ef55deb548fe370058ba83566278d01b3a5650" |
| 237 |
"75b8ef2a82bea17ae95fa91b7b3ffa611a7d8a633100045a5a0000ba15301302010102040" |
| 238 |
"300130330080201010201050400bb15301302010102040300130330080201010201050400" |
| 239 |
"bc030201ff020108020100a0030101ffa203020100"}, |
| 240 |
{"3082038a30820386020101020203040202400030820367020103040800000000000000000" |
| 241 |
"408000000000000000004208a0ac796db0e095391eeecd8023859d7c3681dbad2cc2aa74c" |
| 242 |
"096898756b804804204031c03eb662248ec9fa4e2ed49d030b00dbdb01a917a5978170f2d" |
| 243 |
"57f8f847a04020000020100020101042009a7a3b071b47296724aa98a0032b64d214f0321" |
| 244 |
"261ad553a1e1d915531909700201200420679419e0cedc3fb1d3c4b86844f028a120b6a43" |
| 245 |
"dca0602998d3456b96a4b433b020120020100020100020100a04e304c0201010202030404" |
| 246 |
"021301040004204aa6fac8dfe556ac9e00d748bb808c558b1119bea2ca8c272722c73be63" |
| 247 |
"d7b75a104020204d2a205020302a300a4020400b20302011db9050203093a80a206040474" |
| 248 |
"657374ab03020100ac03010100ad03010100ae03010100af03020100b022042041be9ecd2" |
| 249 |
"da1f2698bc89eb8259aba83f3810c8c1c4fba3fc2c557503bf79acdb103020120b2220420" |
| 250 |
"920ee9ed795ecd4db21dab3b9e207cf60ede7f1874d9a40fd419b7e5dcfd760fb30302012" |
| 251 |
"0b422042084307e1c1e54eb4e4b082546c46abd418ba09b0702b2979500dd8a38187f5204" |
| 252 |
"b503020120b88201700482016c040000b20002a3001d38486f010000a0f602f344b7cac7c" |
| 253 |
"d9ec544f5dcd4e59b74c4f91448d2b01ea5eaf485132448c18f508e5b07587bf147117bff" |
| 254 |
"3fe4f925c4502fd3e43ba6021dbf0bbd01c69556e3779ce6ad9e70c61158011fad4ee5549" |
| 255 |
"665a98365f8b345e3d589afc2f23a5404f05282d9b8b7d858a463f6460d64f8ae75ce6c23" |
| 256 |
"680831e44e014c69f7763f53295f4180c2949f0de73c653d244b10bd08dd9a72e3b2929ee" |
| 257 |
"9cdcacb687aef0004caca0000040000b20002a300f0ddbd9c010100a0f602f344b7cac7cd" |
| 258 |
"9ec544f5dcd4e59b00e726b096faa8169217e8d11bbbcf759075b4545aa2ee20a369a1955" |
| 259 |
"454d6e132a22840878ffb646b282f40d5f8b62d2a1ee6498cce66712c969aa4008a0f54f2" |
| 260 |
"037e12f90e62a9edcb13d03b96dc3ec9d79f82bf0ba43987e88223f6d2ba6f9b216bbc850" |
| 261 |
"d68aaeb63397124769fe0e4e238f2b38e7bb670a6fa0c070669228e94644071d564231349" |
| 262 |
"0c5d54435ece0004caca0000ba2330210201010204030013013016020101020117040e300" |
| 263 |
"c0201010201000201000101ffbb2330210201010204030013013016020101020117040e30" |
| 264 |
"0c0201010201000201000101ffbc030201ff020108020100a0030101ffa203020100", |
| 265 |
nullptr}}; |
| 266 |
|
| 267 |
class EncodeDecodeKATTest |
| 268 |
: public testing::TestWithParam<EncodeDecodeKATTestParam> {}; |
| 269 |
|
| 270 |
INSTANTIATE_TEST_SUITE_P(EncodeAndDecodeKATTests, EncodeDecodeKATTest, |
| 271 |
testing::ValuesIn(kEncodeDecodeKATs)); |
| 272 |
|
| 273 |
TEST_P(EncodeDecodeKATTest, RoundTrips) { |
| 274 |
std::string input(GetParam().input); |
| 275 |
std::string output; |
| 276 |
if (GetParam().output) { |
| 277 |
output = std::string(GetParam().output); |
| 278 |
} else { |
| 279 |
output = std::string(GetParam().input); |
| 280 |
} |
| 281 |
|
| 282 |
std::vector<uint8_t> input_bytes; |
| 283 |
ASSERT_TRUE(DecodeHex(&input_bytes, input)); |
| 284 |
std::vector<uint8_t> output_bytes; |
| 285 |
ASSERT_TRUE(DecodeHex(&output_bytes, output)); |
| 286 |
|
| 287 |
bssl::UniquePtr<SSL_CTX> server_ctx(SSL_CTX_new(TLS_method())); |
| 288 |
// Check the bytes are decoded successfully. |
| 289 |
bssl::UniquePtr<SSL> ssl( |
| 290 |
SSL_from_bytes(input_bytes.data(), input_bytes.size(), server_ctx.get())); |
| 291 |
ASSERT_TRUE(ssl); |
| 292 |
// Check the ssl can be encoded successfully. |
| 293 |
size_t encoded_len = 0; |
| 294 |
uint8_t *encoded = nullptr; |
| 295 |
ASSERT_TRUE(SSL_to_bytes(ssl.get(), &encoded, &encoded_len)); |
| 296 |
bssl::UniquePtr<uint8_t> encoded_ptr; |
| 297 |
encoded_ptr.reset(encoded); |
| 298 |
// Check the encoded bytes are the same as the test input. |
| 299 |
ASSERT_EQ(output_bytes.size(), encoded_len); |
| 300 |
ASSERT_EQ(OPENSSL_memcmp(output_bytes.data(), encoded, encoded_len), 0); |
| 301 |
} |
| 302 |
|
| 303 |
// Test that |SSL_shutdown|, when quiet shutdown is enabled, simulates receiving |
| 304 |
// a close_notify, down to |SSL_read| reporting |SSL_ERROR_ZERO_RETURN|. |
| 305 |
TEST(SSLTest, QuietShutdown) { |
| 306 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 307 |
bssl::UniquePtr<SSL_CTX> server_ctx = |
| 308 |
CreateContextWithTestCertificate(TLS_method()); |
| 309 |
ASSERT_TRUE(client_ctx); |
| 310 |
ASSERT_TRUE(server_ctx); |
| 311 |
SSL_CTX_set_quiet_shutdown(server_ctx.get(), 1); |
| 312 |
bssl::UniquePtr<SSL> client, server; |
| 313 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 314 |
server_ctx.get())); |
| 315 |
|
| 316 |
// Quiet shutdown is enabled, so |SSL_shutdown| on the server should |
| 317 |
// immediately return that bidirectional shutdown "completed". |
| 318 |
EXPECT_EQ(SSL_shutdown(server.get()), 1); |
| 319 |
|
| 320 |
// Shut down writes so the client gets an EOF. |
| 321 |
EXPECT_TRUE(BIO_shutdown_wr(SSL_get_wbio(server.get()))); |
| 322 |
|
| 323 |
// Confirm no close notify was actually sent. Client reads should report a |
| 324 |
// transport EOF, not a close_notify. (Both have zero return, but |
| 325 |
// |SSL_get_error| is different.) |
| 326 |
char buf[1]; |
| 327 |
int ret = SSL_read(client.get(), buf, sizeof(buf)); |
| 328 |
EXPECT_EQ(ret, 0); |
| 329 |
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_SYSCALL); |
| 330 |
|
| 331 |
// The server believes bidirectional shutdown completed, so reads should |
| 332 |
// replay the (simulated) close_notify. |
| 333 |
ret = SSL_read(server.get(), buf, sizeof(buf)); |
| 334 |
EXPECT_EQ(ret, 0); |
| 335 |
EXPECT_EQ(SSL_get_error(server.get(), ret), SSL_ERROR_ZERO_RETURN); |
| 336 |
} |
| 337 |
|
| 338 |
TEST(SSLTest, InvalidSignatureAlgorithm) { |
| 339 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 340 |
ASSERT_TRUE(ctx); |
| 341 |
|
| 342 |
static const uint16_t kInvalidPrefs[] = {1234}; |
| 343 |
EXPECT_FALSE(SSL_CTX_set_signing_algorithm_prefs( |
| 344 |
ctx.get(), kInvalidPrefs, OPENSSL_ARRAY_SIZE(kInvalidPrefs))); |
| 345 |
EXPECT_FALSE(SSL_CTX_set_verify_algorithm_prefs( |
| 346 |
ctx.get(), kInvalidPrefs, OPENSSL_ARRAY_SIZE(kInvalidPrefs))); |
| 347 |
|
| 348 |
static const uint16_t kDuplicatePrefs[] = {SSL_SIGN_RSA_PKCS1_SHA256, |
| 349 |
SSL_SIGN_RSA_PKCS1_SHA256}; |
| 350 |
EXPECT_FALSE(SSL_CTX_set_signing_algorithm_prefs( |
| 351 |
ctx.get(), kDuplicatePrefs, OPENSSL_ARRAY_SIZE(kDuplicatePrefs))); |
| 352 |
EXPECT_FALSE(SSL_CTX_set_verify_algorithm_prefs( |
| 353 |
ctx.get(), kDuplicatePrefs, OPENSSL_ARRAY_SIZE(kDuplicatePrefs))); |
| 354 |
} |
| 355 |
|
| 356 |
TEST(SSLTest, ErrorStrings) { |
| 357 |
int warning_value = SSL3_AD_CLOSE_NOTIFY | (SSL3_AL_WARNING << 8); |
| 358 |
int fatal_value = SSL3_AD_UNEXPECTED_MESSAGE | (SSL3_AL_FATAL << 8); |
| 359 |
int unknown_value = 99999; |
| 360 |
|
| 361 |
EXPECT_EQ(Bytes(SSL_alert_desc_string(warning_value)), Bytes("CN")); |
| 362 |
EXPECT_EQ(Bytes(SSL_alert_desc_string(fatal_value)), Bytes("UM")); |
| 363 |
EXPECT_EQ(Bytes(SSL_alert_desc_string(unknown_value)), Bytes("UK")); |
| 364 |
|
| 365 |
EXPECT_EQ(Bytes(SSL_alert_type_string(warning_value)), Bytes("W")); |
| 366 |
EXPECT_EQ(Bytes(SSL_alert_type_string(fatal_value)), Bytes("F")); |
| 367 |
EXPECT_EQ(Bytes(SSL_alert_type_string(unknown_value)), Bytes("U")); |
| 368 |
} |
| 369 |
|
| 370 |
TEST(SSLTest, NameLists) { |
| 371 |
struct { |
| 372 |
size_t (*func)(const char **, size_t); |
| 373 |
std::vector<std::string> expected; |
| 374 |
} kTests[] = { |
| 375 |
{SSL_get_all_version_names, {"TLSv1.3", "DTLSv1.2", "unknown"}}, |
| 376 |
{SSL_get_all_standard_cipher_names, |
| 377 |
{"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_AES_128_GCM_SHA256"}}, |
| 378 |
{SSL_get_all_cipher_names, |
| 379 |
{"ECDHE-ECDSA-AES128-GCM-SHA256", "TLS_AES_128_GCM_SHA256", "(NONE)"}}, |
| 380 |
{SSL_get_all_group_names, {"P-256", "X25519"}}, |
| 381 |
{SSL_get_all_signature_algorithm_names, |
| 382 |
{"rsa_pkcs1_sha256", "ecdsa_secp256r1_sha256", "ecdsa_sha256"}}, |
| 383 |
}; |
| 384 |
for (const auto &t : kTests) { |
| 385 |
size_t num = t.func(nullptr, 0); |
| 386 |
EXPECT_GT(num, 0u); |
| 387 |
|
| 388 |
std::vector<const char *> list(num); |
| 389 |
EXPECT_EQ(num, t.func(list.data(), list.size())); |
| 390 |
|
| 391 |
// Check the expected values are in the list. |
| 392 |
for (const auto &s : t.expected) { |
| 393 |
EXPECT_NE(list.end(), std::find(list.begin(), list.end(), s)) |
| 394 |
<< "Could not find " << s; |
| 395 |
} |
| 396 |
|
| 397 |
// Passing in a larger buffer should leave excess space alone. |
| 398 |
std::vector<const char *> list2(num + 1, "placeholder"); |
| 399 |
EXPECT_EQ(num, t.func(list2.data(), list2.size())); |
| 400 |
for (size_t i = 0; i < num; i++) { |
| 401 |
EXPECT_STREQ(list[i], list2[i]); |
| 402 |
} |
| 403 |
EXPECT_STREQ(list2.back(), "placeholder"); |
| 404 |
|
| 405 |
// Passing in a shorter buffer should truncate the list. |
| 406 |
for (size_t l = 0; l < num; l++) { |
| 407 |
SCOPED_TRACE(l); |
| 408 |
list2.resize(l); |
| 409 |
EXPECT_EQ(num, t.func(list2.data(), list2.size())); |
| 410 |
for (size_t i = 0; i < l; i++) { |
| 411 |
EXPECT_STREQ(list[i], list2[i]); |
| 412 |
} |
| 413 |
} |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
TEST(SSLTest, SSLFileTests) { |
| 420 |
#if defined(OPENSSL_ANDROID) |
| 421 |
// On Android, when running from an APK, temporary file creations do not work. |
| 422 |
// See b/36991167#comment8. |
| 423 |
GTEST_SKIP(); |
| 424 |
#endif |
| 425 |
|
| 426 |
char rsa_pem_filename[PATH_MAX]; |
| 427 |
char ecdsa_pem_filename[PATH_MAX]; |
| 428 |
ASSERT_TRUE(createTempFILEpath(rsa_pem_filename)); |
| 429 |
ASSERT_TRUE(createTempFILEpath(ecdsa_pem_filename)); |
| 430 |
|
| 431 |
ScopedFILE rsa_pem(fopen(rsa_pem_filename, "w")); |
| 432 |
ScopedFILE ecdsa_pem(fopen(ecdsa_pem_filename, "w")); |
| 433 |
ASSERT_TRUE(rsa_pem); |
| 434 |
ASSERT_TRUE(ecdsa_pem); |
| 435 |
|
| 436 |
bssl::UniquePtr<X509> rsa_leaf = GetChainTestCertificate(); |
| 437 |
bssl::UniquePtr<X509> rsa_intermediate = GetChainTestIntermediate(); |
| 438 |
bssl::UniquePtr<X509> ecdsa_leaf = GetECDSATestCertificate(); |
| 439 |
ASSERT_TRUE(PEM_write_X509(rsa_pem.get(), rsa_leaf.get())); |
| 440 |
ASSERT_TRUE(PEM_write_X509(rsa_pem.get(), rsa_intermediate.get())); |
| 441 |
ASSERT_TRUE(PEM_write_X509(ecdsa_pem.get(), ecdsa_leaf.get())); |
| 442 |
rsa_pem.reset(); |
| 443 |
ecdsa_pem.reset(); |
| 444 |
|
| 445 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 446 |
ASSERT_TRUE(ctx); |
| 447 |
// Load a certificate into |ctx| and verify that |ssl| inherits it. |
| 448 |
EXPECT_TRUE(SSL_CTX_use_certificate_chain_file(ctx.get(), rsa_pem_filename)); |
| 449 |
bssl::UniquePtr<SSL> ssl(SSL_new(ctx.get())); |
| 450 |
ASSERT_TRUE(ssl); |
| 451 |
EXPECT_EQ(X509_cmp(SSL_get_certificate(ssl.get()), rsa_leaf.get()), 0); |
| 452 |
|
| 453 |
// Load a new cert into |ssl| and verify that it's correctly loaded. |
| 454 |
EXPECT_TRUE(SSL_use_certificate_chain_file(ssl.get(), ecdsa_pem_filename)); |
| 455 |
EXPECT_EQ(X509_cmp(SSL_get_certificate(ssl.get()), ecdsa_leaf.get()), 0); |
| 456 |
|
| 457 |
ASSERT_EQ(remove(rsa_pem_filename), 0); |
| 458 |
ASSERT_EQ(remove(ecdsa_pem_filename), 0); |
| 459 |
} |
| 460 |
|
| 461 |
TEST(SSLTest, IncompatibleTLSVersionState) { |
| 462 |
// Using the following ASN.1 DER Sequence where 42 is the serialization |
| 463 |
// format version number of some future version not currently supported: |
| 464 |
// SEQUENCE { |
| 465 |
// SEQUENCE { |
| 466 |
// INTEGER { 42 } |
| 467 |
// } |
| 468 |
// } |
| 469 |
static constexpr size_t INCOMPATIBLE_DER_LEN = 7; |
| 470 |
static const uint8_t INCOMPATIBLE_DER[INCOMPATIBLE_DER_LEN] = { |
| 471 |
0x30, 0x05, 0x30, 0x03, 0x02, 0x01, 0x2a}; |
| 472 |
|
| 473 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 474 |
ASSERT_TRUE(ctx); |
| 475 |
|
| 476 |
ASSERT_FALSE( |
| 477 |
SSL_from_bytes(INCOMPATIBLE_DER, INCOMPATIBLE_DER_LEN, ctx.get())); |
| 478 |
ASSERT_EQ(ERR_GET_LIB(ERR_peek_error()), ERR_LIB_SSL); |
| 479 |
ASSERT_EQ(ERR_GET_REASON(ERR_peek_error()), |
| 480 |
SSL_R_SERIALIZATION_INVALID_SERDE_VERSION); |
| 481 |
} |
| 482 |
|
| 483 |
// Test that it is possible for the certificate to be configured on a mix of |
| 484 |
// SSL_CTX and SSL. This ensures that we do not inadvertently overshare objects |
| 485 |
// in SSL_new. |
| 486 |
TEST(SSLTest, MixContextAndConnection) { |
| 487 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 488 |
ASSERT_TRUE(ctx); |
| 489 |
bssl::UniquePtr<X509> cert = GetTestCertificate(); |
| 490 |
ASSERT_TRUE(cert); |
| 491 |
bssl::UniquePtr<EVP_PKEY> key = GetTestKey(); |
| 492 |
ASSERT_TRUE(key); |
| 493 |
|
| 494 |
// Configure the certificate, but not the private key, on the context. |
| 495 |
ASSERT_TRUE(SSL_CTX_use_certificate(ctx.get(), cert.get())); |
| 496 |
|
| 497 |
bssl::UniquePtr<SSL> ssl1(SSL_new(ctx.get())); |
| 498 |
ASSERT_TRUE(ssl1.get()); |
| 499 |
bssl::UniquePtr<SSL> ssl2(SSL_new(ctx.get())); |
| 500 |
ASSERT_TRUE(ssl2.get()); |
| 501 |
|
| 502 |
// There is no private key configured yet. |
| 503 |
EXPECT_FALSE(SSL_CTX_get0_privatekey(ctx.get())); |
| 504 |
EXPECT_FALSE(SSL_get_privatekey(ssl1.get())); |
| 505 |
EXPECT_FALSE(SSL_get_privatekey(ssl2.get())); |
| 506 |
|
| 507 |
// Configuring the private key on |ssl1| works. |
| 508 |
ASSERT_TRUE(SSL_use_PrivateKey(ssl1.get(), key.get())); |
| 509 |
EXPECT_TRUE(SSL_get_privatekey(ssl1.get())); |
| 510 |
|
| 511 |
// It does not impact the other connection or the context. |
| 512 |
EXPECT_FALSE(SSL_CTX_get0_privatekey(ctx.get())); |
| 513 |
EXPECT_FALSE(SSL_get_privatekey(ssl2.get())); |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
static int XORCompressFunc(SSL *ssl, CBB *out, const uint8_t *in, |
| 518 |
size_t in_len) { |
| 519 |
for (size_t i = 0; i < in_len; i++) { |
| 520 |
if (!CBB_add_u8(out, in[i] ^ 0x55)) { |
| 521 |
return 0; |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
SSL_set_app_data(ssl, XORCompressFunc); |
| 526 |
|
| 527 |
return 1; |
| 528 |
} |
| 529 |
|
| 530 |
static int XORDecompressFunc(SSL *ssl, CRYPTO_BUFFER **out, |
| 531 |
size_t uncompressed_len, const uint8_t *in, |
| 532 |
size_t in_len) { |
| 533 |
if (in_len != uncompressed_len) { |
| 534 |
return 0; |
| 535 |
} |
| 536 |
|
| 537 |
uint8_t *data = nullptr; |
| 538 |
*out = CRYPTO_BUFFER_alloc(&data, uncompressed_len); |
| 539 |
if (*out == nullptr) { |
| 540 |
return 0; |
| 541 |
} |
| 542 |
|
| 543 |
for (size_t i = 0; i < in_len; i++) { |
| 544 |
data[i] = in[i] ^ 0x55; |
| 545 |
} |
| 546 |
|
| 547 |
SSL_set_app_data(ssl, XORDecompressFunc); |
| 548 |
|
| 549 |
return 1; |
| 550 |
} |
| 551 |
|
| 552 |
TEST(SSLTest, CertCompression) { |
| 553 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 554 |
bssl::UniquePtr<SSL_CTX> server_ctx( |
| 555 |
CreateContextWithTestCertificate(TLS_method())); |
| 556 |
ASSERT_TRUE(client_ctx); |
| 557 |
ASSERT_TRUE(server_ctx); |
| 558 |
|
| 559 |
ASSERT_TRUE(SSL_CTX_set_max_proto_version(client_ctx.get(), TLS1_3_VERSION)); |
| 560 |
ASSERT_TRUE(SSL_CTX_set_max_proto_version(server_ctx.get(), TLS1_3_VERSION)); |
| 561 |
ASSERT_TRUE(SSL_CTX_add_cert_compression_alg( |
| 562 |
client_ctx.get(), 0x1234, XORCompressFunc, XORDecompressFunc)); |
| 563 |
ASSERT_TRUE(SSL_CTX_add_cert_compression_alg( |
| 564 |
server_ctx.get(), 0x1234, XORCompressFunc, XORDecompressFunc)); |
| 565 |
|
| 566 |
bssl::UniquePtr<SSL> client, server; |
| 567 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 568 |
server_ctx.get())); |
| 569 |
|
| 570 |
EXPECT_TRUE(SSL_get_app_data(client.get()) == XORDecompressFunc); |
| 571 |
EXPECT_TRUE(SSL_get_app_data(server.get()) == XORCompressFunc); |
| 572 |
} |
| 573 |
|
| 574 |
static size_t test_ecc_privkey_calls = 0; |
| 575 |
|
| 576 |
static enum ssl_private_key_result_t test_ecc_privkey_complete(SSL *ssl, |
| 577 |
uint8_t *out, |
| 578 |
size_t *out_len, |
| 579 |
size_t max_out) { |
| 580 |
test_ecc_privkey_calls += 1; |
| 581 |
return ssl_private_key_success; |
| 582 |
} |
| 583 |
|
| 584 |
static enum ssl_private_key_result_t test_ecc_privkey_sign( |
| 585 |
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out, |
| 586 |
uint16_t signature_algorithm, const uint8_t *in, size_t in_len) { |
| 587 |
bssl::UniquePtr<EVP_PKEY> pkey(GetECDSATestKey()); |
| 588 |
|
| 589 |
if (EVP_PKEY_id(pkey.get()) != |
| 590 |
SSL_get_signature_algorithm_key_type(signature_algorithm)) { |
| 591 |
return ssl_private_key_failure; |
| 592 |
} |
| 593 |
|
| 594 |
const EVP_MD *md = SSL_get_signature_algorithm_digest(signature_algorithm); |
| 595 |
bssl::ScopedEVP_MD_CTX ctx; |
| 596 |
EVP_PKEY_CTX *pctx = nullptr; |
| 597 |
if (!EVP_DigestSignInit(ctx.get(), &pctx, md, nullptr, pkey.get())) { |
| 598 |
return ssl_private_key_failure; |
| 599 |
} |
| 600 |
|
| 601 |
size_t len = 0; |
| 602 |
if (!EVP_DigestSign(ctx.get(), nullptr, &len, in, in_len) || len > max_out) { |
| 603 |
return ssl_private_key_failure; |
| 604 |
} |
| 605 |
|
| 606 |
*out_len = max_out; |
| 607 |
|
| 608 |
if (!EVP_DigestSign(ctx.get(), out, out_len, in, in_len)) { |
| 609 |
return ssl_private_key_failure; |
| 610 |
} |
| 611 |
|
| 612 |
return test_ecc_privkey_complete(ssl, out, out_len, max_out); |
| 613 |
} |
| 614 |
|
| 615 |
static enum ssl_private_key_result_t test_ecc_privkey_decrypt( |
| 616 |
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out, const uint8_t *in, |
| 617 |
size_t in_len) { |
| 618 |
return ssl_private_key_failure; |
| 619 |
} |
| 620 |
|
| 621 |
static const SSL_PRIVATE_KEY_METHOD test_ecc_private_key_method = { |
| 622 |
test_ecc_privkey_sign, |
| 623 |
test_ecc_privkey_decrypt, |
| 624 |
test_ecc_privkey_complete, |
| 625 |
}; |
| 626 |
|
| 627 |
TEST(SSLTest, SSLPrivateKeyMethod) { |
| 628 |
{ |
| 629 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 630 |
bssl::UniquePtr<SSL_CTX> server_ctx(SSL_CTX_new(TLS_method())); |
| 631 |
|
| 632 |
bssl::UniquePtr<X509> ecdsa_cert(GetECDSATestCertificate()); |
| 633 |
bssl::UniquePtr<CRYPTO_BUFFER> ecdsa_leaf = |
| 634 |
x509_to_buffer(ecdsa_cert.get()); |
| 635 |
std::vector<CRYPTO_BUFFER *> chain = { |
| 636 |
ecdsa_leaf.get(), |
| 637 |
}; |
| 638 |
|
| 639 |
// Index should be have been set to default, 0, but no key loaded |
| 640 |
EXPECT_EQ(server_ctx->cert->cert_private_key_idx, SSL_PKEY_RSA); |
| 641 |
EXPECT_EQ( |
| 642 |
server_ctx->cert->cert_private_keys[SSL_PKEY_RSA].privatekey.get(), |
| 643 |
nullptr); |
| 644 |
EXPECT_EQ(server_ctx->cert->key_method, nullptr); |
| 645 |
|
| 646 |
|
| 647 |
// Load a certificate chain containg the leaf but set private key method |
| 648 |
ASSERT_TRUE(SSL_CTX_set_chain_and_key(server_ctx.get(), &chain[0], |
| 649 |
chain.size(), nullptr, |
| 650 |
&test_ecc_private_key_method)); |
| 651 |
|
| 652 |
// Should be initiall zero |
| 653 |
ASSERT_EQ(test_ecc_privkey_calls, (size_t)0); |
| 654 |
|
| 655 |
// Index must be ECC key now, but key_method must be set. |
| 656 |
ASSERT_EQ(server_ctx->cert->cert_private_key_idx, SSL_PKEY_ECC); |
| 657 |
ASSERT_EQ(server_ctx->cert->key_method, &test_ecc_private_key_method); |
| 658 |
|
| 659 |
bssl::UniquePtr<SSL> client, server; |
| 660 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 661 |
server_ctx.get(), ClientConfig(), |
| 662 |
false)); |
| 663 |
|
| 664 |
ASSERT_TRUE(CompleteHandshakes(client.get(), server.get())); |
| 665 |
|
| 666 |
ASSERT_EQ(test_ecc_privkey_calls, (size_t)1); |
| 667 |
|
| 668 |
// Check the internal slot index to verify that the correct slot was used |
| 669 |
// during the handshake. |
| 670 |
ASSERT_EQ(server->config->cert->cert_private_key_idx, SSL_PKEY_ECC); |
| 671 |
ASSERT_EQ(server->config->cert->key_method, &test_ecc_private_key_method); |
| 672 |
} |
| 673 |
|
| 674 |
{ |
| 675 |
size_t current_invoke_count = test_ecc_privkey_calls; |
| 676 |
|
| 677 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 678 |
bssl::UniquePtr<SSL_CTX> server_ctx(SSL_CTX_new(TLS_method())); |
| 679 |
|
| 680 |
// Index should be have been set to default, 0, but no key loaded |
| 681 |
EXPECT_EQ(server_ctx->cert->cert_private_key_idx, SSL_PKEY_RSA); |
| 682 |
EXPECT_EQ( |
| 683 |
server_ctx->cert->cert_private_keys[SSL_PKEY_RSA].privatekey.get(), |
| 684 |
nullptr); |
| 685 |
EXPECT_EQ(server_ctx->cert->key_method, nullptr); |
| 686 |
|
| 687 |
bssl::UniquePtr<X509> ed_cert(GetED25519TestCertificate()); |
| 688 |
bssl::UniquePtr<EVP_PKEY> ed_key(GetED25519TestKey()); |
| 689 |
bssl::UniquePtr<CRYPTO_BUFFER> ed_leaf = x509_to_buffer(ed_cert.get()); |
| 690 |
std::vector<CRYPTO_BUFFER *> ed_chain = { |
| 691 |
ed_leaf.get(), |
| 692 |
}; |
| 693 |
|
| 694 |
// Load a certificate chain containg the leaf but set private key method |
| 695 |
ASSERT_TRUE(SSL_CTX_set_chain_and_key(server_ctx.get(), &ed_chain[0], |
| 696 |
ed_chain.size(), ed_key.get(), |
| 697 |
nullptr)); |
| 698 |
|
| 699 |
// Index must be ECC key now, but key_method must not be set. |
| 700 |
ASSERT_EQ(server_ctx->cert->cert_private_key_idx, SSL_PKEY_ED25519); |
| 701 |
ASSERT_EQ(server_ctx->cert->key_method, nullptr); |
| 702 |
|
| 703 |
std::vector<uint16_t> sigalgs = {SSL_SIGN_ED25519}; |
| 704 |
|
| 705 |
ASSERT_TRUE(SSL_CTX_set_signing_algorithm_prefs( |
| 706 |
client_ctx.get(), sigalgs.data(), sigalgs.size())); |
| 707 |
ASSERT_TRUE(SSL_CTX_set_verify_algorithm_prefs( |
| 708 |
client_ctx.get(), sigalgs.data(), sigalgs.size())); |
| 709 |
|
| 710 |
bssl::UniquePtr<SSL> client, server; |
| 711 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 712 |
server_ctx.get(), ClientConfig(), |
| 713 |
false)); |
| 714 |
|
| 715 |
ASSERT_TRUE(CompleteHandshakes(client.get(), server.get())); |
| 716 |
|
| 717 |
// This should still be the same, as we didn't use the private key method |
| 718 |
// functionality, so it shouldn't have incremented. |
| 719 |
ASSERT_EQ(test_ecc_privkey_calls, current_invoke_count); |
| 720 |
|
| 721 |
// Check the internal slot index to verify that the correct slot was used |
| 722 |
// during the handshake and that key_method was not set. |
| 723 |
ASSERT_EQ(server->config->cert->cert_private_key_idx, SSL_PKEY_ED25519); |
| 724 |
ASSERT_EQ(server->config->cert->key_method, nullptr); |
| 725 |
} |
| 726 |
} |
| 727 |
|
| 728 |
// Test that |key_method| and per-slot |privatekey| maintain mutual exclusivity |
| 729 |
// across all mutation paths. Setting one must clear the other so that stale |
| 730 |
// values never silently take effect. |
| 731 |
TEST(SSLTest, KeyMethodPrivateKeyMutualExclusivity) { |
| 732 |
// Test 1: SSL_CTX_set_private_key_method clears the active slot's |
| 733 |
// privatekey. |
| 734 |
{ |
| 735 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 736 |
ASSERT_TRUE(ctx); |
| 737 |
|
| 738 |
bssl::UniquePtr<X509> cert(GetECDSATestCertificate()); |
| 739 |
bssl::UniquePtr<EVP_PKEY> key(GetECDSATestKey()); |
| 740 |
ASSERT_TRUE(cert); |
| 741 |
ASSERT_TRUE(key); |
| 742 |
|
| 743 |
// Set a real private key first. |
| 744 |
ASSERT_TRUE(SSL_CTX_use_certificate(ctx.get(), cert.get())); |
| 745 |
ASSERT_TRUE(SSL_CTX_use_PrivateKey(ctx.get(), key.get())); |
| 746 |
EXPECT_EQ(ctx->cert->cert_private_key_idx, SSL_PKEY_ECC); |
| 747 |
EXPECT_NE(ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 748 |
nullptr); |
| 749 |
EXPECT_EQ(ctx->cert->key_method, nullptr); |
| 750 |
|
| 751 |
// Switch to key_method. The per-slot privatekey must be cleared. |
| 752 |
SSL_CTX_set_private_key_method(ctx.get(), &test_ecc_private_key_method); |
| 753 |
EXPECT_EQ(ctx->cert->key_method, &test_ecc_private_key_method); |
| 754 |
EXPECT_EQ(ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 755 |
nullptr); |
| 756 |
} |
| 757 |
|
| 758 |
// Test 2: SSL_use_PrivateKey clears key_method. |
| 759 |
{ |
| 760 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 761 |
ASSERT_TRUE(ctx); |
| 762 |
|
| 763 |
bssl::UniquePtr<X509> cert(GetECDSATestCertificate()); |
| 764 |
bssl::UniquePtr<EVP_PKEY> key(GetECDSATestKey()); |
| 765 |
ASSERT_TRUE(cert); |
| 766 |
ASSERT_TRUE(key); |
| 767 |
|
| 768 |
// Set key_method first via set_chain_and_key. |
| 769 |
bssl::UniquePtr<CRYPTO_BUFFER> leaf = x509_to_buffer(cert.get()); |
| 770 |
ASSERT_TRUE(leaf); |
| 771 |
std::vector<CRYPTO_BUFFER *> chain = {leaf.get()}; |
| 772 |
ASSERT_TRUE(SSL_CTX_set_chain_and_key(ctx.get(), &chain[0], chain.size(), |
| 773 |
nullptr, |
| 774 |
&test_ecc_private_key_method)); |
| 775 |
EXPECT_EQ(ctx->cert->key_method, &test_ecc_private_key_method); |
| 776 |
EXPECT_EQ(ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 777 |
nullptr); |
| 778 |
|
| 779 |
// Now create an SSL and switch to a real private key. key_method must be |
| 780 |
// cleared. |
| 781 |
bssl::UniquePtr<SSL> ssl(SSL_new(ctx.get())); |
| 782 |
ASSERT_TRUE(ssl); |
| 783 |
ASSERT_TRUE(SSL_use_PrivateKey(ssl.get(), key.get())); |
| 784 |
EXPECT_EQ(ssl->config->cert->key_method, nullptr); |
| 785 |
EXPECT_NE( |
| 786 |
ssl->config->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 787 |
nullptr); |
| 788 |
} |
| 789 |
|
| 790 |
// Test 3: SSL_CTX_set_chain_and_key with a real privkey clears a |
| 791 |
// pre-existing key_method. |
| 792 |
{ |
| 793 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 794 |
ASSERT_TRUE(ctx); |
| 795 |
|
| 796 |
bssl::UniquePtr<X509> cert(GetECDSATestCertificate()); |
| 797 |
bssl::UniquePtr<EVP_PKEY> key(GetECDSATestKey()); |
| 798 |
ASSERT_TRUE(cert); |
| 799 |
ASSERT_TRUE(key); |
| 800 |
|
| 801 |
// Set key_method first. |
| 802 |
SSL_CTX_set_private_key_method(ctx.get(), &test_ecc_private_key_method); |
| 803 |
EXPECT_EQ(ctx->cert->key_method, &test_ecc_private_key_method); |
| 804 |
|
| 805 |
// Now set chain and key with a real privkey. key_method must be cleared. |
| 806 |
bssl::UniquePtr<CRYPTO_BUFFER> leaf = x509_to_buffer(cert.get()); |
| 807 |
ASSERT_TRUE(leaf); |
| 808 |
std::vector<CRYPTO_BUFFER *> chain = {leaf.get()}; |
| 809 |
ASSERT_TRUE(SSL_CTX_set_chain_and_key(ctx.get(), &chain[0], chain.size(), |
| 810 |
key.get(), nullptr)); |
| 811 |
EXPECT_EQ(ctx->cert->key_method, nullptr); |
| 812 |
EXPECT_NE(ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 813 |
nullptr); |
| 814 |
} |
| 815 |
|
| 816 |
// Test 4: SSL_CTX_set_chain_and_key with key_method clears a pre-existing |
| 817 |
// per-slot privatekey. |
| 818 |
{ |
| 819 |
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); |
| 820 |
ASSERT_TRUE(ctx); |
| 821 |
|
| 822 |
bssl::UniquePtr<X509> cert(GetECDSATestCertificate()); |
| 823 |
bssl::UniquePtr<EVP_PKEY> key(GetECDSATestKey()); |
| 824 |
ASSERT_TRUE(cert); |
| 825 |
ASSERT_TRUE(key); |
| 826 |
|
| 827 |
// Set a real private key first. |
| 828 |
ASSERT_TRUE(SSL_CTX_use_certificate(ctx.get(), cert.get())); |
| 829 |
ASSERT_TRUE(SSL_CTX_use_PrivateKey(ctx.get(), key.get())); |
| 830 |
EXPECT_NE(ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 831 |
nullptr); |
| 832 |
EXPECT_EQ(ctx->cert->key_method, nullptr); |
| 833 |
|
| 834 |
// Now set chain and key with key_method. The per-slot privatekey must be |
| 835 |
// cleared. |
| 836 |
bssl::UniquePtr<CRYPTO_BUFFER> leaf = x509_to_buffer(cert.get()); |
| 837 |
ASSERT_TRUE(leaf); |
| 838 |
std::vector<CRYPTO_BUFFER *> chain = {leaf.get()}; |
| 839 |
ASSERT_TRUE(SSL_CTX_set_chain_and_key(ctx.get(), &chain[0], chain.size(), |
| 840 |
nullptr, |
| 841 |
&test_ecc_private_key_method)); |
| 842 |
EXPECT_EQ(ctx->cert->key_method, &test_ecc_private_key_method); |
| 843 |
EXPECT_EQ(ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 844 |
nullptr); |
| 845 |
} |
| 846 |
|
| 847 |
// Test 5: Handshake succeeds after switching from key_method to a real |
| 848 |
// private key. Verifies the stale key_method does not interfere. |
| 849 |
{ |
| 850 |
size_t calls_before = test_ecc_privkey_calls; |
| 851 |
|
| 852 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 853 |
bssl::UniquePtr<SSL_CTX> server_ctx(SSL_CTX_new(TLS_method())); |
| 854 |
ASSERT_TRUE(client_ctx); |
| 855 |
ASSERT_TRUE(server_ctx); |
| 856 |
|
| 857 |
bssl::UniquePtr<X509> cert(GetECDSATestCertificate()); |
| 858 |
bssl::UniquePtr<EVP_PKEY> key(GetECDSATestKey()); |
| 859 |
ASSERT_TRUE(cert); |
| 860 |
ASSERT_TRUE(key); |
| 861 |
|
| 862 |
// Configure with key_method first. |
| 863 |
bssl::UniquePtr<CRYPTO_BUFFER> leaf = x509_to_buffer(cert.get()); |
| 864 |
ASSERT_TRUE(leaf); |
| 865 |
std::vector<CRYPTO_BUFFER *> chain = {leaf.get()}; |
| 866 |
ASSERT_TRUE(SSL_CTX_set_chain_and_key(server_ctx.get(), &chain[0], |
| 867 |
chain.size(), nullptr, |
| 868 |
&test_ecc_private_key_method)); |
| 869 |
ASSERT_EQ(server_ctx->cert->key_method, &test_ecc_private_key_method); |
| 870 |
|
| 871 |
// Switch to a real private key. key_method must be cleared. |
| 872 |
ASSERT_TRUE(SSL_CTX_use_PrivateKey(server_ctx.get(), key.get())); |
| 873 |
ASSERT_EQ(server_ctx->cert->key_method, nullptr); |
| 874 |
ASSERT_NE( |
| 875 |
server_ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 876 |
nullptr); |
| 877 |
|
| 878 |
// Handshake must succeed using the real key, not the old key_method. |
| 879 |
bssl::UniquePtr<SSL> client, server; |
| 880 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 881 |
server_ctx.get(), ClientConfig(), |
| 882 |
false)); |
| 883 |
ASSERT_TRUE(CompleteHandshakes(client.get(), server.get())); |
| 884 |
|
| 885 |
// The key_method callbacks must not have been invoked. |
| 886 |
ASSERT_EQ(test_ecc_privkey_calls, calls_before); |
| 887 |
} |
| 888 |
|
| 889 |
// Test 6: Handshake succeeds after switching from a real private key to |
| 890 |
// key_method. Verifies the key_method callbacks are used, not the stale |
| 891 |
// per-slot privatekey. |
| 892 |
{ |
| 893 |
size_t calls_before = test_ecc_privkey_calls; |
| 894 |
|
| 895 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 896 |
bssl::UniquePtr<SSL_CTX> server_ctx(SSL_CTX_new(TLS_method())); |
| 897 |
ASSERT_TRUE(client_ctx); |
| 898 |
ASSERT_TRUE(server_ctx); |
| 899 |
|
| 900 |
bssl::UniquePtr<X509> cert(GetECDSATestCertificate()); |
| 901 |
bssl::UniquePtr<EVP_PKEY> key(GetECDSATestKey()); |
| 902 |
ASSERT_TRUE(cert); |
| 903 |
ASSERT_TRUE(key); |
| 904 |
|
| 905 |
// Configure with a real private key first. |
| 906 |
ASSERT_TRUE(SSL_CTX_use_certificate(server_ctx.get(), cert.get())); |
| 907 |
ASSERT_TRUE(SSL_CTX_use_PrivateKey(server_ctx.get(), key.get())); |
| 908 |
ASSERT_EQ(server_ctx->cert->key_method, nullptr); |
| 909 |
|
| 910 |
// Switch to key_method. The per-slot privatekey must be cleared. |
| 911 |
SSL_CTX_set_private_key_method(server_ctx.get(), |
| 912 |
&test_ecc_private_key_method); |
| 913 |
ASSERT_EQ(server_ctx->cert->key_method, &test_ecc_private_key_method); |
| 914 |
ASSERT_EQ( |
| 915 |
server_ctx->cert->cert_private_keys[SSL_PKEY_ECC].privatekey.get(), |
| 916 |
nullptr); |
| 917 |
|
| 918 |
// Handshake must succeed using the key_method callbacks. |
| 919 |
bssl::UniquePtr<SSL> client, server; |
| 920 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 921 |
server_ctx.get(), ClientConfig(), |
| 922 |
false)); |
| 923 |
ASSERT_TRUE(CompleteHandshakes(client.get(), server.get())); |
| 924 |
|
| 925 |
// The key_method callbacks must have been invoked. |
| 926 |
ASSERT_GT(test_ecc_privkey_calls, calls_before); |
| 927 |
} |
| 928 |
} |
| 929 |
|
| 930 |
|
| 931 |
// Test that failures are supressed on (potentially) |
| 932 |
// transient empty reads. |
| 933 |
TEST(SSLTest, IntermittentEmptyRead) { |
| 934 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 935 |
bssl::UniquePtr<SSL_CTX> server_ctx = |
| 936 |
CreateContextWithTestCertificate(TLS_method()); |
| 937 |
ASSERT_TRUE(client_ctx); |
| 938 |
ASSERT_TRUE(server_ctx); |
| 939 |
bssl::UniquePtr<SSL> client, server; |
| 940 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 941 |
server_ctx.get())); |
| 942 |
|
| 943 |
// Create a fake read BIO that returns 0 on read to simulate empty read |
| 944 |
bssl::UniquePtr<BIO_METHOD> method(BIO_meth_new(0, nullptr)); |
| 945 |
ASSERT_TRUE(method); |
| 946 |
ASSERT_TRUE(BIO_meth_set_create(method.get(), [](BIO *b) -> int { |
| 947 |
BIO_set_init(b, 1); |
| 948 |
return 1; |
| 949 |
})); |
| 950 |
ASSERT_TRUE(BIO_meth_set_read(method.get(), |
| 951 |
[](BIO *, char *, int) -> int { return 0; })); |
| 952 |
bssl::UniquePtr<BIO> rbio_empty(BIO_new(method.get())); |
| 953 |
ASSERT_TRUE(rbio_empty); |
| 954 |
BIO_set_flags(rbio_empty.get(), BIO_FLAGS_READ); |
| 955 |
|
| 956 |
// Save off client rbio and use empty read BIO |
| 957 |
bssl::UniquePtr<BIO> client_rbio(SSL_get_rbio(client.get())); |
| 958 |
ASSERT_TRUE(client_rbio); |
| 959 |
// Up-ref |client_rbio| as SSL_CTX dtor will also attempt to free it |
| 960 |
ASSERT_TRUE(BIO_up_ref(client_rbio.get())); |
| 961 |
SSL_set0_rbio(client.get(), rbio_empty.release()); |
| 962 |
|
| 963 |
// Server writes some data to the client |
| 964 |
const uint8_t write_data[] = {1, 2, 3}; |
| 965 |
int ret = SSL_write(server.get(), write_data, (int)sizeof(write_data)); |
| 966 |
EXPECT_EQ(ret, (int)sizeof(write_data)); |
| 967 |
EXPECT_EQ(SSL_get_error(server.get(), ret), SSL_ERROR_NONE); |
| 968 |
|
| 969 |
uint8_t read_data[] = {0, 0, 0}; |
| 970 |
ret = SSL_read(client.get(), read_data, sizeof(read_data)); |
| 971 |
EXPECT_EQ(ret, 0); |
| 972 |
// On empty read, client should still want a read so caller will retry. |
| 973 |
// This would have returned |SSL_ERROR_SYSCALL| in OpenSSL 1.0.2. |
| 974 |
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_WANT_READ); |
| 975 |
|
| 976 |
// Reset client rbio, read should succeed |
| 977 |
SSL_set0_rbio(client.get(), client_rbio.release()); |
| 978 |
ret = SSL_read(client.get(), read_data, sizeof(read_data)); |
| 979 |
EXPECT_EQ(ret, (int)sizeof(write_data)); |
| 980 |
EXPECT_EQ(OPENSSL_memcmp(read_data, write_data, sizeof(write_data)), 0); |
| 981 |
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_NONE); |
| 982 |
|
| 983 |
// Subsequent attempts to read should fail |
| 984 |
ret = SSL_read(client.get(), read_data, sizeof(read_data)); |
| 985 |
EXPECT_LT(ret, 0); |
| 986 |
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_WANT_READ); |
| 987 |
} |
| 988 |
|
| 989 |
enum ssl_test_ticket_aead_failure_mode { |
| 990 |
ssl_test_ticket_aead_ok = 0, |
| 991 |
ssl_test_ticket_aead_seal_fail, |
| 992 |
ssl_test_ticket_aead_open_soft_fail, |
| 993 |
ssl_test_ticket_aead_open_hard_fail, |
| 994 |
}; |
| 995 |
|
| 996 |
struct ssl_test_ticket_aead_state { |
| 997 |
unsigned retry_count = 0; |
| 998 |
ssl_test_ticket_aead_failure_mode failure_mode = ssl_test_ticket_aead_ok; |
| 999 |
}; |
| 1000 |
|
| 1001 |
static int ssl_test_ticket_aead_ex_index_dup(CRYPTO_EX_DATA *to, |
| 1002 |
const CRYPTO_EX_DATA *from, |
| 1003 |
void **from_d, int index, |
| 1004 |
long argl, void *argp) { |
| 1005 |
abort(); |
| 1006 |
} |
| 1007 |
|
| 1008 |
static void ssl_test_ticket_aead_ex_index_free(void *parent, void *ptr, |
| 1009 |
CRYPTO_EX_DATA *ad, int index, |
| 1010 |
long argl, void *argp) { |
| 1011 |
delete reinterpret_cast<ssl_test_ticket_aead_state *>(ptr); |
| 1012 |
} |
| 1013 |
|
| 1014 |
static CRYPTO_once_t g_ssl_test_ticket_aead_ex_index_once = CRYPTO_ONCE_INIT; |
| 1015 |
static int g_ssl_test_ticket_aead_ex_index; |
| 1016 |
|
| 1017 |
static int ssl_test_ticket_aead_get_ex_index() { |
| 1018 |
CRYPTO_once(&g_ssl_test_ticket_aead_ex_index_once, [] { |
| 1019 |
g_ssl_test_ticket_aead_ex_index = SSL_get_ex_new_index( |
| 1020 |
0, nullptr, nullptr, ssl_test_ticket_aead_ex_index_dup, |
| 1021 |
ssl_test_ticket_aead_ex_index_free); |
| 1022 |
}); |
| 1023 |
return g_ssl_test_ticket_aead_ex_index; |
| 1024 |
} |
| 1025 |
|
| 1026 |
static size_t ssl_test_ticket_aead_max_overhead(SSL *ssl) { return 1; } |
| 1027 |
|
| 1028 |
static int ssl_test_ticket_aead_seal(SSL *ssl, uint8_t *out, size_t *out_len, |
| 1029 |
size_t max_out_len, const uint8_t *in, |
| 1030 |
size_t in_len) { |
| 1031 |
auto state = reinterpret_cast<ssl_test_ticket_aead_state *>( |
| 1032 |
SSL_get_ex_data(ssl, ssl_test_ticket_aead_get_ex_index())); |
| 1033 |
|
| 1034 |
if (state->failure_mode == ssl_test_ticket_aead_seal_fail || |
| 1035 |
max_out_len < in_len + 1) { |
| 1036 |
return 0; |
| 1037 |
} |
| 1038 |
|
| 1039 |
OPENSSL_memmove(out, in, in_len); |
| 1040 |
out[in_len] = 0xff; |
| 1041 |
*out_len = in_len + 1; |
| 1042 |
|
| 1043 |
return 1; |
| 1044 |
} |
| 1045 |
|
| 1046 |
static ssl_ticket_aead_result_t ssl_test_ticket_aead_open( |
| 1047 |
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out_len, |
| 1048 |
const uint8_t *in, size_t in_len) { |
| 1049 |
auto state = reinterpret_cast<ssl_test_ticket_aead_state *>( |
| 1050 |
SSL_get_ex_data(ssl, ssl_test_ticket_aead_get_ex_index())); |
| 1051 |
|
| 1052 |
if (state->retry_count > 0) { |
| 1053 |
state->retry_count--; |
| 1054 |
return ssl_ticket_aead_retry; |
| 1055 |
} |
| 1056 |
|
| 1057 |
switch (state->failure_mode) { |
| 1058 |
case ssl_test_ticket_aead_ok: |
| 1059 |
break; |
| 1060 |
case ssl_test_ticket_aead_seal_fail: |
| 1061 |
// If |seal| failed then there shouldn't be any ticket to try and |
| 1062 |
// decrypt. |
| 1063 |
abort(); |
| 1064 |
break; |
| 1065 |
case ssl_test_ticket_aead_open_soft_fail: |
| 1066 |
return ssl_ticket_aead_ignore_ticket; |
| 1067 |
case ssl_test_ticket_aead_open_hard_fail: |
| 1068 |
return ssl_ticket_aead_error; |
| 1069 |
} |
| 1070 |
|
| 1071 |
if (in_len == 0 || in[in_len - 1] != 0xff) { |
| 1072 |
return ssl_ticket_aead_ignore_ticket; |
| 1073 |
} |
| 1074 |
|
| 1075 |
if (max_out_len < in_len - 1) { |
| 1076 |
return ssl_ticket_aead_error; |
| 1077 |
} |
| 1078 |
|
| 1079 |
OPENSSL_memmove(out, in, in_len - 1); |
| 1080 |
*out_len = in_len - 1; |
| 1081 |
return ssl_ticket_aead_success; |
| 1082 |
} |
| 1083 |
|
| 1084 |
static const SSL_TICKET_AEAD_METHOD kSSLTestTicketMethod = { |
| 1085 |
ssl_test_ticket_aead_max_overhead, |
| 1086 |
ssl_test_ticket_aead_seal, |
| 1087 |
ssl_test_ticket_aead_open, |
| 1088 |
}; |
| 1089 |
|
| 1090 |
static void ConnectClientAndServerWithTicketMethod( |
| 1091 |
bssl::UniquePtr<SSL> *out_client, bssl::UniquePtr<SSL> *out_server, |
| 1092 |
SSL_CTX *client_ctx, SSL_CTX *server_ctx, unsigned retry_count, |
| 1093 |
ssl_test_ticket_aead_failure_mode failure_mode, SSL_SESSION *session) { |
| 1094 |
bssl::UniquePtr<SSL> client(SSL_new(client_ctx)), server(SSL_new(server_ctx)); |
| 1095 |
ASSERT_TRUE(client); |
| 1096 |
ASSERT_TRUE(server); |
| 1097 |
SSL_set_connect_state(client.get()); |
| 1098 |
SSL_set_accept_state(server.get()); |
| 1099 |
|
| 1100 |
auto state = new ssl_test_ticket_aead_state; |
| 1101 |
state->retry_count = retry_count; |
| 1102 |
state->failure_mode = failure_mode; |
| 1103 |
|
| 1104 |
ASSERT_GE(ssl_test_ticket_aead_get_ex_index(), 0); |
| 1105 |
ASSERT_TRUE(SSL_set_ex_data(server.get(), ssl_test_ticket_aead_get_ex_index(), |
| 1106 |
state)); |
| 1107 |
|
| 1108 |
SSL_set_session(client.get(), session); |
| 1109 |
|
| 1110 |
BIO *bio1 = nullptr, *bio2 = nullptr; |
| 1111 |
ASSERT_TRUE(BIO_new_bio_pair(&bio1, 0, &bio2, 0)); |
| 1112 |
|
| 1113 |
// SSL_set_bio takes ownership. |
| 1114 |
SSL_set_bio(client.get(), bio1, bio1); |
| 1115 |
SSL_set_bio(server.get(), bio2, bio2); |
| 1116 |
|
| 1117 |
if (CompleteHandshakes(client.get(), server.get())) { |
| 1118 |
*out_client = std::move(client); |
| 1119 |
*out_server = std::move(server); |
| 1120 |
} else { |
| 1121 |
out_client->reset(); |
| 1122 |
out_server->reset(); |
| 1123 |
} |
| 1124 |
} |
| 1125 |
|
| 1126 |
using TicketAEADMethodParam = |
| 1127 |
testing::tuple<uint16_t, unsigned, ssl_test_ticket_aead_failure_mode, bool>; |
| 1128 |
|
| 1129 |
class TicketAEADMethodTest |
| 1130 |
: public ::testing::TestWithParam<TicketAEADMethodParam> {}; |
| 1131 |
|
| 1132 |
TEST_P(TicketAEADMethodTest, Resume) { |
| 1133 |
bssl::UniquePtr<SSL_CTX> server_ctx = |
| 1134 |
CreateContextWithTestCertificate(TLS_method()); |
| 1135 |
ASSERT_TRUE(server_ctx); |
| 1136 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 1137 |
ASSERT_TRUE(client_ctx); |
| 1138 |
|
| 1139 |
const uint16_t version = testing::get<0>(GetParam()); |
| 1140 |
const unsigned retry_count = testing::get<1>(GetParam()); |
| 1141 |
const ssl_test_ticket_aead_failure_mode failure_mode = |
| 1142 |
testing::get<2>(GetParam()); |
| 1143 |
const bool transfer_ssl = testing::get<3>(GetParam()); |
| 1144 |
|
| 1145 |
ASSERT_TRUE(SSL_CTX_set_min_proto_version(client_ctx.get(), version)); |
| 1146 |
ASSERT_TRUE(SSL_CTX_set_max_proto_version(client_ctx.get(), version)); |
| 1147 |
ASSERT_TRUE(SSL_CTX_set_min_proto_version(server_ctx.get(), version)); |
| 1148 |
ASSERT_TRUE(SSL_CTX_set_max_proto_version(server_ctx.get(), version)); |
| 1149 |
|
| 1150 |
SSL_CTX_set_session_cache_mode(client_ctx.get(), SSL_SESS_CACHE_BOTH); |
| 1151 |
SSL_CTX_set_session_cache_mode(server_ctx.get(), SSL_SESS_CACHE_BOTH); |
| 1152 |
SSL_CTX_set_current_time_cb(client_ctx.get(), FrozenTimeCallback); |
| 1153 |
SSL_CTX_set_current_time_cb(server_ctx.get(), FrozenTimeCallback); |
| 1154 |
SSL_CTX_sess_set_new_cb(client_ctx.get(), SaveLastSession); |
| 1155 |
|
| 1156 |
SSL_CTX_set_ticket_aead_method(server_ctx.get(), &kSSLTestTicketMethod); |
| 1157 |
|
| 1158 |
bssl::UniquePtr<SSL> client, server; |
| 1159 |
ASSERT_NO_FATAL_FAILURE(ConnectClientAndServerWithTicketMethod( |
| 1160 |
&client, &server, client_ctx.get(), server_ctx.get(), retry_count, |
| 1161 |
failure_mode, nullptr)); |
| 1162 |
// Only transfer when the code is to test SSL transfer and the connection is |
| 1163 |
// finished successuflly. |
| 1164 |
if (transfer_ssl && server) { |
| 1165 |
// |server| is reset to hold the transferred SSL. |
| 1166 |
TransferSSL(&server, server_ctx.get(), nullptr); |
| 1167 |
} |
| 1168 |
switch (failure_mode) { |
| 1169 |
case ssl_test_ticket_aead_ok: |
| 1170 |
case ssl_test_ticket_aead_open_hard_fail: |
| 1171 |
case ssl_test_ticket_aead_open_soft_fail: |
| 1172 |
ASSERT_TRUE(client); |
| 1173 |
break; |
| 1174 |
case ssl_test_ticket_aead_seal_fail: |
| 1175 |
EXPECT_FALSE(client); |
| 1176 |
return; |
| 1177 |
} |
| 1178 |
EXPECT_FALSE(SSL_session_reused(client.get())); |
| 1179 |
EXPECT_FALSE(SSL_session_reused(server.get())); |
| 1180 |
|
| 1181 |
ASSERT_TRUE(FlushNewSessionTickets(client.get(), server.get())); |
| 1182 |
bssl::UniquePtr<SSL_SESSION> session = std::move(g_last_session); |
| 1183 |
ASSERT_NO_FATAL_FAILURE(ConnectClientAndServerWithTicketMethod( |
| 1184 |
&client, &server, client_ctx.get(), server_ctx.get(), retry_count, |
| 1185 |
failure_mode, session.get())); |
| 1186 |
// Do SSL transfer again. |
| 1187 |
// Only transfer when the code is to test SSL transfer and the connection is |
| 1188 |
// finished successuflly. |
| 1189 |
if (transfer_ssl && server) { |
| 1190 |
// |server| is reset to hold the transferred SSL. |
| 1191 |
TransferSSL(&server, server_ctx.get(), nullptr); |
| 1192 |
} |
| 1193 |
switch (failure_mode) { |
| 1194 |
case ssl_test_ticket_aead_ok: |
| 1195 |
ASSERT_TRUE(client); |
| 1196 |
EXPECT_TRUE(SSL_session_reused(client.get())); |
| 1197 |
EXPECT_TRUE(SSL_session_reused(server.get())); |
| 1198 |
break; |
| 1199 |
case ssl_test_ticket_aead_seal_fail: |
| 1200 |
abort(); |
| 1201 |
break; |
| 1202 |
case ssl_test_ticket_aead_open_hard_fail: |
| 1203 |
EXPECT_FALSE(client); |
| 1204 |
break; |
| 1205 |
case ssl_test_ticket_aead_open_soft_fail: |
| 1206 |
ASSERT_TRUE(client); |
| 1207 |
EXPECT_FALSE(SSL_session_reused(client.get())); |
| 1208 |
EXPECT_FALSE(SSL_session_reused(server.get())); |
| 1209 |
} |
| 1210 |
} |
| 1211 |
|
| 1212 |
static std::string TicketAEADMethodParamToString( |
| 1213 |
const testing::TestParamInfo<TicketAEADMethodParam> ¶ms) { |
| 1214 |
std::string ret = GetVersionName(std::get<0>(params.param)); |
| 1215 |
// GTest only allows alphanumeric characters and '_' in the parameter |
| 1216 |
// string. Additionally filter out the 'v' to get "TLS13" over "TLSv13". |
| 1217 |
for (auto it = ret.begin(); it != ret.end();) { |
| 1218 |
if (*it == '.' || *it == 'v') { |
| 1219 |
it = ret.erase(it); |
| 1220 |
} else { |
| 1221 |
++it; |
| 1222 |
} |
| 1223 |
} |
| 1224 |
char retry_count[256]; |
| 1225 |
snprintf(retry_count, sizeof(retry_count), "%u", std::get<1>(params.param)); |
| 1226 |
ret += "_"; |
| 1227 |
ret += retry_count; |
| 1228 |
ret += "Retries_"; |
| 1229 |
switch (std::get<2>(params.param)) { |
| 1230 |
case ssl_test_ticket_aead_ok: |
| 1231 |
ret += "OK"; |
| 1232 |
break; |
| 1233 |
case ssl_test_ticket_aead_seal_fail: |
| 1234 |
ret += "SealFail"; |
| 1235 |
break; |
| 1236 |
case ssl_test_ticket_aead_open_soft_fail: |
| 1237 |
ret += "OpenSoftFail"; |
| 1238 |
break; |
| 1239 |
case ssl_test_ticket_aead_open_hard_fail: |
| 1240 |
ret += "OpenHardFail"; |
| 1241 |
break; |
| 1242 |
} |
| 1243 |
if (std::get<3>(params.param)) { |
| 1244 |
ret += "_SSLTransfer"; |
| 1245 |
} |
| 1246 |
return ret; |
| 1247 |
} |
| 1248 |
|
| 1249 |
INSTANTIATE_TEST_SUITE_P( |
| 1250 |
TicketAEADMethodTests, TicketAEADMethodTest, |
| 1251 |
testing::Combine(testing::Values(TLS1_2_VERSION, TLS1_3_VERSION), |
| 1252 |
testing::Values(0, 1, 2), |
| 1253 |
testing::Values(ssl_test_ticket_aead_ok, |
| 1254 |
ssl_test_ticket_aead_seal_fail, |
| 1255 |
ssl_test_ticket_aead_open_soft_fail, |
| 1256 |
ssl_test_ticket_aead_open_hard_fail), |
| 1257 |
testing::Values(TRANSFER_SSL, !TRANSFER_SSL)), |
| 1258 |
TicketAEADMethodParamToString); |
| 1259 |
|
| 1260 |
TEST(SSLTest, GetTrafficSecrets) { |
| 1261 |
// Set up client and server contexts with TLS 1.3 |
| 1262 |
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); |
| 1263 |
bssl::UniquePtr<SSL_CTX> server_ctx = |
| 1264 |
CreateContextWithTestCertificate(TLS_method()); |
| 1265 |
ASSERT_TRUE(client_ctx); |
| 1266 |
ASSERT_TRUE(server_ctx); |
| 1267 |
|
| 1268 |
// Ensure TLS 1.3 is used |
| 1269 |
ASSERT_TRUE(SSL_CTX_set_min_proto_version(client_ctx.get(), TLS1_3_VERSION)); |
| 1270 |
ASSERT_TRUE(SSL_CTX_set_max_proto_version(client_ctx.get(), TLS1_3_VERSION)); |
| 1271 |
ASSERT_TRUE(SSL_CTX_set_min_proto_version(server_ctx.get(), TLS1_3_VERSION)); |
| 1272 |
ASSERT_TRUE(SSL_CTX_set_max_proto_version(server_ctx.get(), TLS1_3_VERSION)); |
| 1273 |
|
| 1274 |
// Connect client and server |
| 1275 |
bssl::UniquePtr<SSL> client, server; |
| 1276 |
ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), |
| 1277 |
server_ctx.get())); |
| 1278 |
|
| 1279 |
// Test getting traffic secrets |
| 1280 |
uint8_t client_read_secret[SSL_MAX_MD_SIZE] = {0}; |
| 1281 |
uint8_t client_write_secret[SSL_MAX_MD_SIZE] = {0}; |
| 1282 |
uint8_t server_read_secret[SSL_MAX_MD_SIZE] = {0}; |
| 1283 |
uint8_t server_write_secret[SSL_MAX_MD_SIZE] = {0}; |
| 1284 |
size_t client_read_len = 0, client_write_len = 0, server_read_len = 0, |
| 1285 |
server_write_len = 0; |
| 1286 |
|
| 1287 |
// First check the lengths |
| 1288 |
ASSERT_TRUE( |
| 1289 |
SSL_get_read_traffic_secret(client.get(), nullptr, &client_read_len)); |
| 1290 |
ASSERT_TRUE( |
| 1291 |
SSL_get_write_traffic_secret(client.get(), nullptr, &client_write_len)); |
| 1292 |
ASSERT_TRUE( |
| 1293 |
SSL_get_read_traffic_secret(server.get(), nullptr, &server_read_len)); |
| 1294 |
ASSERT_TRUE( |
| 1295 |
SSL_get_write_traffic_secret(server.get(), nullptr, &server_write_len)); |
| 1296 |
|
| 1297 |
ASSERT_EQ(client_read_len, server_write_len); |
| 1298 |
ASSERT_EQ(client_write_len, server_read_len); |
| 1299 |
|
| 1300 |
// Get the actual secrets |
| 1301 |
ASSERT_TRUE(SSL_get_read_traffic_secret(client.get(), client_read_secret, |
| 1302 |
&client_read_len)); |
| 1303 |
ASSERT_TRUE(SSL_get_write_traffic_secret(client.get(), client_write_secret, |
| 1304 |
&client_write_len)); |
| 1305 |
ASSERT_TRUE(SSL_get_read_traffic_secret(server.get(), server_read_secret, |
| 1306 |
&server_read_len)); |
| 1307 |
ASSERT_TRUE(SSL_get_write_traffic_secret(server.get(), server_write_secret, |
| 1308 |
&server_write_len)); |
| 1309 |
|
| 1310 |
// Client's read secret should match server's write secret |
| 1311 |
ASSERT_EQ(0, OPENSSL_memcmp(client_read_secret, server_write_secret, |
| 1312 |
client_read_len)); |
| 1313 |
// Client's write secret should match server's read secret |
| 1314 |
ASSERT_EQ(0, OPENSSL_memcmp(client_write_secret, server_read_secret, |
| 1315 |
client_write_len)); |
| 1316 |
|
| 1317 |
// Test error cases |
| 1318 |
bssl::UniquePtr<SSL> unconnected(SSL_new(client_ctx.get())); |
| 1319 |
ASSERT_TRUE(unconnected); |
| 1320 |
size_t unused = 0; |
| 1321 |
ASSERT_FALSE( |
| 1322 |
SSL_get_read_traffic_secret(unconnected.get(), nullptr, &unused)); |
| 1323 |
ASSERT_FALSE( |
| 1324 |
SSL_get_write_traffic_secret(unconnected.get(), nullptr, &unused)); |
| 1325 |
|
| 1326 |
// Test buffer too small |
| 1327 |
uint8_t small_buffer[1]; |
| 1328 |
size_t actual_size = sizeof(small_buffer); |
| 1329 |
ASSERT_FALSE( |
| 1330 |
SSL_get_read_traffic_secret(client.get(), small_buffer, &actual_size)); |
| 1331 |
ASSERT_FALSE( |
| 1332 |
SSL_get_write_traffic_secret(client.get(), small_buffer, &actual_size)); |
| 1333 |
|
| 1334 |
// Passing null buffers and null size |
| 1335 |
ASSERT_FALSE(SSL_get_read_traffic_secret(client.get(), nullptr, nullptr)); |
| 1336 |
ASSERT_FALSE(SSL_get_write_traffic_secret(client.get(), nullptr, nullptr)); |
| 1337 |
} |
| 1338 |
|
| 1339 |
struct InvalidTransferEncodingTestParam { |
| 1340 |
const char *input; |
| 1341 |
}; |
| 1342 |
|
| 1343 |
static const InvalidTransferEncodingTestParam kInvalidTransferEncodings[] = { |
| 1344 |
// The serialized read_buffer OCTET STRING has 8 extra bytes then it should |
| 1345 |
{"3082026e3082026a020101020203040202400030820250020103040800000000000000140" |
| 1346 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1347 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1348 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1349 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1350 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1351 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1352 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1353 |
"08a0030201ed020102a93630340201020101ff02011802010502011802010004201703030" |
| 1354 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7e0001020304050607ab03020100ac0301" |
| 1355 |
"0100ad03010100ae03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b" |
| 1356 |
"1f3d2c95839fd9b380b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b4" |
| 1357 |
"3f7857797569b0459c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e" |
| 1358 |
"4d4d31da55f01129be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b1703" |
| 1359 |
"030016835338b2dcab482315b8d92421d601c602b50f2041bbba233021020101020403001" |
| 1360 |
"3013016020101020117040e300c0201010201000201000101ffbb23302102010102040300" |
| 1361 |
"13013016020101020117040e300c0201010201000201000101ffbc0302010102010802010" |
| 1362 |
"0a203020100"}, |
| 1363 |
// The serialized read_buffer OCTET STRING is larger then inline_buf_ |
| 1364 |
{"308202493082024502010102020304020240003082022b020103040800000000000000140" |
| 1365 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1366 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1367 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1368 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1369 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1370 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1371 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a91d30" |
| 1372 |
"1b020102010100020105020105020100020100040700010203040506ab03020100ac03010" |
| 1373 |
"100ad03010100ae03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1" |
| 1374 |
"f3d2c95839fd9b380b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43" |
| 1375 |
"f7857797569b0459c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4" |
| 1376 |
"d4d31da55f01129be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b17030" |
| 1377 |
"30016835338b2dcab482315b8d92421d601c602b50f2041bbba2330210201010204030013" |
| 1378 |
"013016020101020117040e300c0201010201000201000101ffbb233021020101020403001" |
| 1379 |
"3013016020101020117040e300c0201010201000201000101ffbc03020101020108020100" |
| 1380 |
"a203020100"}, |
| 1381 |
// pending_app_data offset is smaller then what is representable as int64 |
| 1382 |
{"3082027530820271020101020203040202400030820257020103040800000000000000140" |
| 1383 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1384 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1385 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1386 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1387 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1388 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1389 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a81930" |
| 1390 |
"17a0120210ffffffffffffffff7fffffffffffffff020102a92e302c0201020101ff02011" |
| 1391 |
"802010502011802010004181703030013313917e5402dfef87b011cdaedf9fb56e0ce7eab" |
| 1392 |
"03020100ac03010100ad03010100ae03010100af03020100b0220420ee4651b968739c5f6" |
| 1393 |
"e10f16b49f8e4b1f3d2c95839fd9b380b90a2f327e8d8a1b103020120b22204202d2027d1" |
| 1394 |
"5f143f516939b43f7857797569b0459c0b3f9e02c9d798e891d5a5a6b303020120b422042" |
| 1395 |
"07d6420075c44e4d4d31da55f01129be4208c0f4a8bca3da25615289c1eba7674b5030201" |
| 1396 |
"20b91d041b1703030016835338b2dcab482315b8d92421d601c602b50f2041bbba2330210" |
| 1397 |
"201010204030013013016020101020117040e300c0201010201000201000101ffbb233021" |
| 1398 |
"0201010204030013013016020101020117040e300c0201010201000201000101ffbc03020" |
| 1399 |
"101020108020100a203020100"}, |
| 1400 |
// pending_app_data offset is larger then what is representable as int64 |
| 1401 |
{"3082027530820271020101020203040202400030820257020103040800000000000000140" |
| 1402 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1403 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1404 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1405 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1406 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1407 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1408 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a81930" |
| 1409 |
"17a012021000000000000000008000000000000000020102a92e302c0201020101ff02011" |
| 1410 |
"802010502011802010004181703030013313917e5402dfef87b011cdaedf9fb56e0ce7eab" |
| 1411 |
"03020100ac03010100ad03010100ae03010100af03020100b0220420ee4651b968739c5f6" |
| 1412 |
"e10f16b49f8e4b1f3d2c95839fd9b380b90a2f327e8d8a1b103020120b22204202d2027d1" |
| 1413 |
"5f143f516939b43f7857797569b0459c0b3f9e02c9d798e891d5a5a6b303020120b422042" |
| 1414 |
"07d6420075c44e4d4d31da55f01129be4208c0f4a8bca3da25615289c1eba7674b5030201" |
| 1415 |
"20b91d041b1703030016835338b2dcab482315b8d92421d601c602b50f2041bbba2330210" |
| 1416 |
"201010204030013013016020101020117040e300c0201010201000201000101ffbb233021" |
| 1417 |
"0201010204030013013016020101020117040e300c0201010201000201000101ffbc03020" |
| 1418 |
"101020108020100a203020100"}, |
| 1419 |
// pending_app_data offset falls outside of read_buffer |
| 1420 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1421 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1422 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1423 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1424 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1425 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1426 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1427 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1428 |
"08a003020108020100a92e302c0201020101ff02011802010502011802010004181703030" |
| 1429 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1430 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1431 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1432 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1433 |
"be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dc" |
| 1434 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1435 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1436 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1437 |
// pending_app_data offset+size falls outside of read_buffer |
| 1438 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1439 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1440 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1441 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1442 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1443 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1444 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1445 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1446 |
"08a003020107020101a92e302c0201020101ff02011802010502011802010004181703030" |
| 1447 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1448 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1449 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1450 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1451 |
"be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dc" |
| 1452 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1453 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1454 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1455 |
// pending_app_data offset falls before read_buffer start |
| 1456 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1457 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1458 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1459 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1460 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1461 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1462 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1463 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1464 |
"08a0030201e0020100a92e302c0201020101ff02011802010502011802010004181703030" |
| 1465 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1466 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1467 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1468 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1469 |
"be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dc" |
| 1470 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1471 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1472 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1473 |
// CBS_len(&previous_client_finished) != previous_client_finished_len |
| 1474 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1475 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1476 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1477 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1478 |
"670e10469c94e67d421205210201050420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1479 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1480 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1481 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1482 |
"08a0030201ed020102a92e302c0201020101ff02011802010502011802010004181703030" |
| 1483 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1484 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1485 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1486 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1487 |
"be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dc" |
| 1488 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1489 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1490 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1491 |
// previous_client_finished_len > PREV_FINISHED_MAX_SIZE |
| 1492 |
{"3082028730820283020101020203040202400030820269020103040800000000000000140" |
| 1493 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1494 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1495 |
"77d3ec125040200000201000201010441da505fe678128954a65c747dee14514f160b3b3c" |
| 1496 |
"670e10469c94e67d42120521da505fe678128954a65c747dee14514f160b3b3c670e10469" |
| 1497 |
"c94e67d42120521ff0201410420b4a380d705da4a9138c941f97a95ff5029e0a91041d019" |
| 1498 |
"c7f311126faf72e728020120020100020100020100a050304e02010102020304040213010" |
| 1499 |
"4000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30df354a1" |
| 1500 |
"06020468a38654a205020302a300a4020400b20302011db9050203093a80a80a3008a0030" |
| 1501 |
"201ed020102a92e302c0201020101ff020118020105020118020100041817030300133139" |
| 1502 |
"17e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae0301010" |
| 1503 |
"0af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b380b90a2" |
| 1504 |
"f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b0459c0b3f9" |
| 1505 |
"e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129be4208c" |
| 1506 |
"0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dcab48231" |
| 1507 |
"5b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020117040e" |
| 1508 |
"300c0201010201000201000101ffbb2330210201010204030013013016020101020117040" |
| 1509 |
"e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1510 |
// CBS_len(&previous_server_finished) != previous_server_finished_len) |
| 1511 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1512 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1513 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1514 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1515 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1516 |
"041d019c7f311126faf72e728020140020100020100020100a050304e0201010202030404" |
| 1517 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1518 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1519 |
"08a0030201ed020102a92e302c0201020101ff02011802010502011802010004181703030" |
| 1520 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1521 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1522 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1523 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1524 |
"be4208c0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dc" |
| 1525 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1526 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1527 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1528 |
// previous_server_finished_len > PREV_FINISHED_MAX_SIZE |
| 1529 |
{"3082028730820283020101020203040202400030820269020103040800000000000000140" |
| 1530 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1531 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1532 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1533 |
"670e10469c94e67d421205210201200441b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1534 |
"041d019c7f311126faf72e728b4a380d705da4a9138c941f97a95ff5029e0a91041d019c7" |
| 1535 |
"f311126faf72e728ff020141020100020100020100a050304e02010102020304040213010" |
| 1536 |
"4000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30df354a1" |
| 1537 |
"06020468a38654a205020302a300a4020400b20302011db9050203093a80a80a3008a0030" |
| 1538 |
"201ed020102a92e302c0201020101ff020118020105020118020100041817030300133139" |
| 1539 |
"17e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae0301010" |
| 1540 |
"0af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b380b90a2" |
| 1541 |
"f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b0459c0b3f9" |
| 1542 |
"e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129be4208c" |
| 1543 |
"0f4a8bca3da25615289c1eba7674b503020120b91d041b1703030016835338b2dcab48231" |
| 1544 |
"5b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020117040e" |
| 1545 |
"300c0201010201000201000101ffbb2330210201010204030013013016020101020117040" |
| 1546 |
"e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1547 |
// exporter_secret_len > UINT8_MAX |
| 1548 |
{"3082026730820263020101020203040202400030820249020103040800000000000000140" |
| 1549 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1550 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1551 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1552 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1553 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1554 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1555 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1556 |
"08a0030201ed020102a92e302c0201020101ff02011802010502011802010004181703030" |
| 1557 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1558 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1559 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1560 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1561 |
"be4208c0f4a8bca3da25615289c1eba7674b50402020100b91d041b1703030016835338b2" |
| 1562 |
"dcab482315b8d92421d601c602b50f2041bbba23302102010102040300130130160201010" |
| 1563 |
"20117040e300c0201010201000201000101ffbb2330210201010204030013013016020101" |
| 1564 |
"020117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1565 |
// exporter_secret_len > SSL_MAX_MD_SIZE |
| 1566 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1567 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1568 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1569 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1570 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1571 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1572 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1573 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1574 |
"08a0030201ed020102a92e302c0201020101ff02011802010502011802010004181703030" |
| 1575 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1576 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1577 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1578 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1579 |
"be4208c0f4a8bca3da25615289c1eba7674b503020131b91d041b1703030016835338b2dc" |
| 1580 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1581 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1582 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1583 |
// CBS_len(&exporter_secret) != exporter_secret_len) |
| 1584 |
{"3082026630820262020101020203040202400030820248020103040800000000000000140" |
| 1585 |
"40800000000000000000420b01de2070af16e7412a6fa4fd947248c2df0f1ebbaf3adc9a4" |
| 1586 |
"b97f3b0be6ae360420a606b526d185e18a6eb1a2d88943d3ac4d2d14db0807af71d39f4f8" |
| 1587 |
"77d3ec125040200000201000201010420da505fe678128954a65c747dee14514f160b3b3c" |
| 1588 |
"670e10469c94e67d421205210201200420b4a380d705da4a9138c941f97a95ff5029e0a91" |
| 1589 |
"041d019c7f311126faf72e728020120020100020100020100a050304e0201010202030404" |
| 1590 |
"02130104000420ae1689a5645a728a77eb1869e3b2d7d67b79c12229e7027b2847215ca30" |
| 1591 |
"df354a106020468a38654a205020302a300a4020400b20302011db9050203093a80a80a30" |
| 1592 |
"08a0030201ed020102a92e302c0201020101ff02011802010502011802010004181703030" |
| 1593 |
"013313917e5402dfef87b011cdaedf9fb56e0ce7eab03020100ac03010100ad03010100ae" |
| 1594 |
"03010100af03020100b0220420ee4651b968739c5f6e10f16b49f8e4b1f3d2c95839fd9b3" |
| 1595 |
"80b90a2f327e8d8a1b103020120b22204202d2027d15f143f516939b43f7857797569b045" |
| 1596 |
"9c0b3f9e02c9d798e891d5a5a6b303020120b42204207d6420075c44e4d4d31da55f01129" |
| 1597 |
"be4208c0f4a8bca3da25615289c1eba7674b503020130b91d041b1703030016835338b2dc" |
| 1598 |
"ab482315b8d92421d601c602b50f2041bbba2330210201010204030013013016020101020" |
| 1599 |
"117040e300c0201010201000201000101ffbb233021020101020403001301301602010102" |
| 1600 |
"0117040e300c0201010201000201000101ffbc03020101020108020100a203020100"}, |
| 1601 |
}; |
| 1602 |
|
| 1603 |
class InvalidTransferEncoding |
| 1604 |
: public testing::TestWithParam<InvalidTransferEncodingTestParam> {}; |
| 1605 |
|
| 1606 |
INSTANTIATE_TEST_SUITE_P(InvalidTransferEncodings, InvalidTransferEncoding, |
| 1607 |
testing::ValuesIn(kInvalidTransferEncodings)); |
| 1608 |
|
| 1609 |
TEST_P(InvalidTransferEncoding, FailsDeserialization) { |
| 1610 |
std::string input(GetParam().input); |
| 1611 |
|
| 1612 |
std::vector<uint8_t> input_bytes; |
| 1613 |
ASSERT_TRUE(DecodeHex(&input_bytes, input)); |
| 1614 |
|
| 1615 |
bssl::UniquePtr<SSL_CTX> server_ctx(SSL_CTX_new(TLS_method())); |
| 1616 |
bssl::UniquePtr<SSL> ssl( |
| 1617 |
SSL_from_bytes(input_bytes.data(), input_bytes.size(), server_ctx.get())); |
| 1618 |
ASSERT_FALSE(ssl); |
| 1619 |
} |
| 1620 |
|
| 1621 |
BSSL_NAMESPACE_END |