1 // Copyright 2017 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 ///////////////////////////////////////////////////////////////////////////////
16
17 #include "tink/hybrid/ecies_aead_hkdf_hybrid_decrypt.h"
18
19 #include <memory>
20 #include <string>
21 #include <utility>
22 #include <vector>
23
24 #include "gtest/gtest.h"
25 #include "absl/memory/memory.h"
26 #include "tink/aead/aes_ctr_hmac_aead_key_manager.h"
27 #include "tink/aead/aes_gcm_key_manager.h"
28 #include "tink/aead/xchacha20_poly1305_key_manager.h"
29 #include "tink/daead/aes_siv_key_manager.h"
30 #include "tink/hybrid/ecies_aead_hkdf_hybrid_encrypt.h"
31 #include "tink/hybrid_decrypt.h"
32 #include "tink/internal/ec_util.h"
33 #include "tink/internal/ssl_util.h"
34 #include "tink/subtle/random.h"
35 #include "tink/util/enums.h"
36 #include "tink/util/statusor.h"
37 #include "tink/util/test_matchers.h"
38 #include "tink/util/test_util.h"
39 #include "proto/aes_gcm.pb.h"
40 #include "proto/common.pb.h"
41 #include "proto/ecies_aead_hkdf.pb.h"
42
43 using crypto::tink::subtle::Random;
44 using ::crypto::tink::test::IsOkAndHolds;
45 using google::crypto::tink::EciesAeadHkdfPrivateKey;
46 using google::crypto::tink::EcPointFormat;
47 using google::crypto::tink::EllipticCurveType;
48 using google::crypto::tink::HashType;
49 using ::testing::Eq;
50
51 namespace crypto {
52 namespace tink {
53 namespace {
54
55 class EciesAeadHkdfHybridDecryptTest : public ::testing::Test {
56 protected:
SetUp()57 void SetUp() override {}
TearDown()58 void TearDown() override {}
59
60 struct CommonHybridKeyParams {
61 EllipticCurveType ec_curve;
62 EcPointFormat ec_point_format;
63 HashType hash_type;
64 };
65
GetCommonHybridKeyParamsList()66 std::vector<CommonHybridKeyParams> GetCommonHybridKeyParamsList() {
67 std::vector<CommonHybridKeyParams> params_list;
68 for (auto ec_curve :
69 {EllipticCurveType::NIST_P256, EllipticCurveType::NIST_P384,
70 EllipticCurveType::NIST_P521, EllipticCurveType::CURVE25519}) {
71 for (auto ec_point_format :
72 {EcPointFormat::UNCOMPRESSED, EcPointFormat::COMPRESSED}) {
73 if (ec_curve == EllipticCurveType::CURVE25519 &&
74 ec_point_format == EcPointFormat::UNCOMPRESSED) {
75 continue;
76 }
77 for (auto hash_type : {HashType::SHA256, HashType::SHA512}) {
78 CommonHybridKeyParams params;
79 params.ec_curve = ec_curve;
80 params.ec_point_format = ec_point_format;
81 params.hash_type = hash_type;
82 params_list.push_back(params);
83 }
84 }
85 }
86 return params_list;
87 }
88
GetEciesPrivateKeyFromHexString(absl::string_view private_key_hex_string,CommonHybridKeyParams & key_params)89 EciesAeadHkdfPrivateKey GetEciesPrivateKeyFromHexString(
90 absl::string_view private_key_hex_string,
91 CommonHybridKeyParams& key_params) {
92 auto ecies_key = test::GetEciesAesSivHkdfTestKey(
93 key_params.ec_curve, key_params.ec_point_format, key_params.hash_type);
94 ecies_key.set_key_value(test::HexDecodeOrDie(private_key_hex_string));
95 return ecies_key;
96 }
97
TestValidKey(const EciesAeadHkdfPrivateKey & ecies_key)98 void TestValidKey(const EciesAeadHkdfPrivateKey& ecies_key) {
99 auto result(EciesAeadHkdfHybridDecrypt::New(ecies_key));
100 ASSERT_TRUE(result.ok()) << result.status() << ecies_key.DebugString();
101 std::unique_ptr<HybridDecrypt> hybrid_decrypt(std::move(result.value()));
102
103 std::unique_ptr<HybridEncrypt> hybrid_encrypt(std::move(
104 EciesAeadHkdfHybridEncrypt::New(ecies_key.public_key()).value()));
105
106 std::string context_info = "some context info";
107 for (uint32_t plaintext_size : {0, 1, 10, 100, 1000}) {
108 // Use the primitive.
109 std::string plaintext = Random::GetRandomBytes(plaintext_size);
110 auto ciphertext =
111 hybrid_encrypt->Encrypt(plaintext, context_info).value();
112 { // Regular decryption.
113 auto decrypt_result = hybrid_decrypt->Decrypt(ciphertext, context_info);
114 EXPECT_TRUE(decrypt_result.ok()) << decrypt_result.status();
115 EXPECT_EQ(plaintext, decrypt_result.value());
116 }
117 { // Encryption and decryption with empty context info.
118 const absl::string_view empty_context_info;
119 auto ciphertext =
120 hybrid_encrypt->Encrypt(plaintext, empty_context_info).value();
121 auto decrypt_result =
122 hybrid_decrypt->Decrypt(ciphertext, empty_context_info);
123 ASSERT_TRUE(decrypt_result.ok()) << decrypt_result.status();
124 EXPECT_EQ(plaintext, decrypt_result.value());
125 }
126 { // Encryption and decryption w/ empty msg & context info.
127 const absl::string_view empty_plaintext;
128 const absl::string_view empty_context_info;
129 auto ciphertext =
130 hybrid_encrypt->Encrypt(empty_plaintext, empty_context_info)
131 .value();
132 auto decrypt_result =
133 hybrid_decrypt->Decrypt(ciphertext, empty_context_info);
134 ASSERT_TRUE(decrypt_result.ok()) << decrypt_result.status();
135 EXPECT_EQ(empty_plaintext, decrypt_result.value());
136 }
137 { // Short bad ciphertext.
138 auto decrypt_result =
139 hybrid_decrypt->Decrypt(Random::GetRandomBytes(16), context_info);
140 EXPECT_FALSE(decrypt_result.ok());
141 EXPECT_EQ(absl::StatusCode::kInvalidArgument,
142 decrypt_result.status().code());
143 EXPECT_PRED_FORMAT2(testing::IsSubstring, "ciphertext too short",
144 std::string(decrypt_result.status().message()));
145 }
146 { // Long but still bad ciphertext.
147 auto decrypt_result =
148 hybrid_decrypt->Decrypt(Random::GetRandomBytes(142), context_info);
149 EXPECT_FALSE(decrypt_result.ok());
150 // TODO(przydatek): add more checks while avoiding flakiness.
151 }
152 { // Bad context info
153 auto decrypt_result =
154 hybrid_decrypt->Decrypt(ciphertext, Random::GetRandomBytes(14));
155 EXPECT_FALSE(decrypt_result.ok());
156 }
157 }
158 }
159 };
160
TEST_F(EciesAeadHkdfHybridDecryptTest,testInvalidKeys)161 TEST_F(EciesAeadHkdfHybridDecryptTest, testInvalidKeys) {
162 { // No fields set.
163 EciesAeadHkdfPrivateKey recipient_key;
164 auto result = EciesAeadHkdfHybridDecrypt::New(recipient_key);
165 EXPECT_FALSE(result.ok());
166 EXPECT_EQ(absl::StatusCode::kInvalidArgument, result.status().code());
167 EXPECT_PRED_FORMAT2(testing::IsSubstring, "missing required fields",
168 std::string(result.status().message()));
169 }
170
171 { // Only some fields set.
172 EciesAeadHkdfPrivateKey recipient_key;
173 recipient_key.set_version(0);
174 recipient_key.mutable_public_key()->set_x("some x bytes");
175 recipient_key.mutable_public_key()->set_y("some y bytes");
176 auto result(EciesAeadHkdfHybridDecrypt::New(recipient_key));
177 EXPECT_FALSE(result.ok());
178 EXPECT_EQ(absl::StatusCode::kInvalidArgument, result.status().code());
179 EXPECT_PRED_FORMAT2(testing::IsSubstring, "missing required fields",
180 std::string(result.status().message()));
181 }
182
183 { // Wrong EC type.
184 EciesAeadHkdfPrivateKey recipient_key;
185 recipient_key.set_version(0);
186 recipient_key.set_key_value("some key value bytes");
187 recipient_key.mutable_public_key()->set_x("some x bytes");
188 recipient_key.mutable_public_key()->set_y("some y bytes");
189 recipient_key.mutable_public_key()->mutable_params();
190 auto result(EciesAeadHkdfHybridDecrypt::New(recipient_key));
191 EXPECT_FALSE(result.ok());
192 EXPECT_EQ(absl::StatusCode::kUnimplemented, result.status().code());
193 EXPECT_PRED_FORMAT2(testing::IsSubstring, "Unsupported elliptic curve",
194 std::string(result.status().message()));
195 }
196
197 { // Unsupported DEM key type.
198 EllipticCurveType curve = EllipticCurveType::NIST_P256;
199 auto test_key =
200 internal::NewEcKey(util::Enums::ProtoToSubtle(curve)).value();
201 EciesAeadHkdfPrivateKey recipient_key;
202 recipient_key.set_version(0);
203 recipient_key.set_key_value("some key value bytes");
204 recipient_key.mutable_public_key()->set_x(test_key.pub_x);
205 recipient_key.mutable_public_key()->set_y(test_key.pub_y);
206 auto params = recipient_key.mutable_public_key()->mutable_params();
207 params->mutable_kem_params()->set_curve_type(curve);
208 params->mutable_kem_params()->set_hkdf_hash_type(HashType::SHA256);
209 auto aead_dem = params->mutable_dem_params()->mutable_aead_dem();
210 aead_dem->set_type_url("some.type.url/that.is.not.supported");
211 auto result(EciesAeadHkdfHybridDecrypt::New(recipient_key));
212 EXPECT_FALSE(result.ok());
213 EXPECT_EQ(absl::StatusCode::kInvalidArgument, result.status().code());
214 EXPECT_PRED_FORMAT2(testing::IsSubstring, "Unsupported DEM",
215 std::string(result.status().message()));
216 }
217 }
218
TEST_F(EciesAeadHkdfHybridDecryptTest,testAesGcmHybridDecryption)219 TEST_F(EciesAeadHkdfHybridDecryptTest, testAesGcmHybridDecryption) {
220 // Register DEM key manager.
221 std::string dem_key_type = AesGcmKeyManager().get_key_type();
222 ASSERT_TRUE(Registry::RegisterKeyTypeManager(
223 absl::make_unique<AesGcmKeyManager>(), true)
224 .ok());
225
226 int i = 0;
227 // Generate and test many keys with various parameters.
228 for (auto key_params : GetCommonHybridKeyParamsList()) {
229 for (uint32_t aes_gcm_key_size : {16, 32}) {
230 ++i;
231 auto ecies_key = test::GetEciesAesGcmHkdfTestKey(
232 key_params.ec_curve, key_params.ec_point_format, key_params.hash_type,
233 aes_gcm_key_size);
234 TestValidKey(ecies_key);
235 }
236 }
237 EXPECT_EQ(i, 32 - 4);
238 }
239
TEST_F(EciesAeadHkdfHybridDecryptTest,testAesCtrAeadHybridDecryption)240 TEST_F(EciesAeadHkdfHybridDecryptTest, testAesCtrAeadHybridDecryption) {
241 // Register DEM key manager.
242 std::string dem_key_type = AesCtrHmacAeadKeyManager().get_key_type();
243 ASSERT_TRUE(Registry::RegisterKeyTypeManager(
244 absl::make_unique<AesCtrHmacAeadKeyManager>(), true)
245 .ok());
246
247 uint32_t aes_ctr_iv_size = 16;
248 // Generate and test many keys with various parameters.
249 for (auto key_params : GetCommonHybridKeyParamsList()) {
250 for (uint32_t aes_ctr_key_size : {16, 32}) {
251 for (auto hmac_hash_type : {HashType::SHA256, HashType::SHA512}) {
252 for (uint32_t hmac_tag_size : {16, 32}) {
253 for (uint32_t hmac_key_size : {16, 32}) {
254 auto ecies_key = test::GetEciesAesCtrHmacHkdfTestKey(
255 key_params.ec_curve, key_params.ec_point_format,
256 key_params.hash_type, aes_ctr_key_size, aes_ctr_iv_size,
257 hmac_hash_type, hmac_tag_size, hmac_key_size);
258 TestValidKey(ecies_key);
259 }
260 }
261 }
262 }
263 }
264 }
265
TEST_F(EciesAeadHkdfHybridDecryptTest,testXChaCha20Poly1305HybridDecryption)266 TEST_F(EciesAeadHkdfHybridDecryptTest, testXChaCha20Poly1305HybridDecryption) {
267 if (!internal::IsBoringSsl()) {
268 GTEST_SKIP() << "XChaCha20-Poly1305 is not supported when OpenSSL is used";
269 }
270 // Register DEM key manager.
271 std::string dem_key_type = XChaCha20Poly1305KeyManager().get_key_type();
272 ASSERT_TRUE(Registry::RegisterKeyTypeManager(
273 absl::make_unique<XChaCha20Poly1305KeyManager>(), true)
274 .ok());
275
276 // Generate and test many keys with various parameters.
277 for (auto key_params : GetCommonHybridKeyParamsList()) {
278 auto ecies_key = test::GetEciesXChaCha20Poly1305HkdfTestKey(
279 key_params.ec_curve, key_params.ec_point_format, key_params.hash_type);
280 TestValidKey(ecies_key);
281 }
282 }
283
TEST_F(EciesAeadHkdfHybridDecryptTest,testAesSivHybridDecryption)284 TEST_F(EciesAeadHkdfHybridDecryptTest, testAesSivHybridDecryption) {
285 // Register DEM key manager.
286 std::string dem_key_type = AesSivKeyManager().get_key_type();
287 ASSERT_TRUE(Registry::RegisterKeyTypeManager(
288 absl::make_unique<AesSivKeyManager>(), true)
289 .ok());
290
291 // Generate and test many keys with various parameters.
292 for (auto key_params : GetCommonHybridKeyParamsList()) {
293 auto ecies_key = test::GetEciesAesSivHkdfTestKey(
294 key_params.ec_curve, key_params.ec_point_format, key_params.hash_type);
295 TestValidKey(ecies_key);
296 }
297 }
298
299 struct TestVector {
300 EciesAeadHkdfPrivateKey private_key;
301 std::string ciphertext;
302 std::string context_info;
303 std::string plaintext;
304 };
305
TEST_F(EciesAeadHkdfHybridDecryptTest,testAesSivHybridDecryptionWithTestVectors)306 TEST_F(EciesAeadHkdfHybridDecryptTest,
307 testAesSivHybridDecryptionWithTestVectors) {
308 // Register DEM key manager.
309 std::string dem_key_type = AesSivKeyManager().get_key_type();
310 ASSERT_TRUE(Registry::RegisterKeyTypeManager(
311 absl::make_unique<AesSivKeyManager>(), true)
312 .ok());
313
314 CommonHybridKeyParams key_params = {EllipticCurveType::NIST_P256,
315 EcPointFormat::UNCOMPRESSED,
316 HashType::SHA256};
317 TestVector hybrid_decryption_test_vectors[] = {
318 {
319 /*TEST 1*/
320 /*private_key=*/
321 GetEciesPrivateKeyFromHexString("32588172ed65830571bb83748f7fddd38332"
322 "3208a7825c80a71bef846333eb02",
323 key_params),
324 /*ciphertext=*/
325 test::HexDecodeOrDie(
326 "0401b11f8c9bafe30ae13f8bd15528714e752631a4328bf146009068e99489c8"
327 "e9fae1ec39e3fe9994723711417fcab2af4b3c9b60117d47d33d35175c87b483"
328 "b8935a73312940d1fbf8da3944a89b5e8b"),
329 /*context_info=*/
330 "some context info",
331 /*plaintext=*/"",
332 },
333 {
334 /*TEST 2*/
335 /*private_key=*/
336 GetEciesPrivateKeyFromHexString("32588172ed65830571bb83748f7fddd38332"
337 "3208a7825c80a71bef846333eb02",
338 key_params),
339 /*ciphertext=*/
340 test::HexDecodeOrDie(
341 "040230023d1547b55af5a735a7f460722612126d7539d7cd0f677d308b29c6f5"
342 "2a964e66e7b0cb44cff1673df9e2c793f1477ca755807bfbeadcae1ab20b45ec"
343 "b1501ca5e3f5b0626d3ca40aa5d010443d506e4df90b"),
344 /*context_info=*/
345 "some context info",
346 /*plaintext=*/"hello",
347 },
348 {
349 /*TEST 3*/
350 /*private_key=*/
351 GetEciesPrivateKeyFromHexString("32588172ed65830571bb83748f7fddd38332"
352 "3208a7825c80a71bef846333eb02",
353 key_params),
354 /*ciphertext=*/
355 test::HexDecodeOrDie(
356 "0441ddd246cea0825bd68bddff05cec54a4ee678da35b2f5cfbbb32e5350bdd8"
357 "17214bfb7b5ed5528131bde56916062cfbd8b9952d9e0907a6e87e1de54db5df"
358 "3aaccddd328efcf7771ce061e647488f66b8c11a9fca171dcff813e90b44b273"
359 "9573f9f23b60202491870c7ff8aaf0ae46838e48f17f8dc1ad55b67809699dd3"
360 "1eb6ca50dfa9beeee32d30bdc00a1eb1d8b0cbcedbe50b1e24619cc5e79042f2"
361 "5f49e2c2d5a35c79e833c0d68e31a93da4173aacd0428b367594ed4636763d16"
362 "c23e4f8c115d44bddc83bcefcaea13587238ce8b7a5d5fad53beeb59aaa1d748"
363 "3eb4bac93ed50ed4d3e9fd5af760283fd38080b58744b73212a36039179ce6f9"
364 "6ef1ecaa05b5186967d81c06b9cd91140dfbd54084ddcfd941527719848a2eec"
365 "b84278f6a0fe9357a3964f87222fcd16a12a353e1f64fd45dc227a4a2112da6f"
366 "61269f22f16b41e68eadf0b6b3a48c67b9e7e3ec1c66eecce50dda8ecbce99d3"
367 "778299aa28741b7247fbc46a1b8a908dc23943c2dd17210a270bb12b096c2c6a"
368 "00400a95c62894a15b9fc44e709d27348f2f2644a786cd9e96caf42ea9b949f7"
369 "6e85e6f7365e15fa2902e851222c025f6c208269d799fcfc4c0b37aba8979ed9"
370 "e6ccf543c217ee0b6ad05f0e3ffb92943d308c801b25efedab5bf93a733bdae6"
371 "11132d774d4b9ee4fb5e88ae63014315ae9571039a8c8c7020e2b3a1bbd4235b"
372 "65af94771c8417c87fd6cab423b82a557f60a99ae7402dba205e05136dd34f00"
373 "26fce87899d4b9819cc2b2ba686512d62c41a1e3a667a705ea45404aafa489cd"
374 "7f53f42455fff3f9b22f960d12a2587efd6ed0fa3e00dd4645face1b2f1268e6"
375 "019be70999eab00f0aeff3cb0e77b7c4a1ab1fdf15d00c4eedd7b75e8cf5c901"
376 "19346894089ee0299d58f1d7ebac9b592da2325a5a738ea2baecc1468670f5ae"
377 "c880bce32efecfb2a7c5ad3ae4096b0a07aa9bfe6cbaf53da6757377bb692e55"
378 "ec8caf5f0af28dafdc42e1d6e5893140945a853f56652c575b99d64399aad2d0"
379 "42948575134c8fe638fb0b80ac3a0f08a60f3aa817fe0a24c1fffee6933bd72e"
380 "a460e0b241d3f5d98b2321ee25d8c0302353fcfd41bce964d73ff67042286450"
381 "6cc56f3470362c90144586ccbfc8e5e6fefbb70429b0a517e4b1badb449cd110"
382 "92790aba6e19b914899872f4fb481c8dc47a33422fc05072ac99c958e40dae53"
383 "d96ebd87cfbde67a0f050203a89e487da5e03364951830e43771d36abfbe8f5a"
384 "7da8e7aa891f36a68dbe9a3b0e3dfbd1afd6327a3ced4a5cd8a5b256fef46d20"
385 "0df4af2e2da4dbb786ea0404bb968b6d961e4fc76f89e70ad7c9e11d6aee6526"
386 "b75b399811f73c053a29582ba9295ea4d5a8fffb5a8ccbac008d291dd60e2041"
387 "371acfc4c432a0ae0fcd8fa25c9551123c95da64caa134edaee5893e19c3c760"
388 "75bef419c09681a67f4ede6f28d747b53afd61ddc937d7de96a22c7db10ad870"
389 "0cade888de5d6f450c15d796978ddb5e6a52e5044e90247c988686d992105c85"
390 "f6d198e2de859330f973ded4d7e5d90de57051dbaf0db0febd4cf9d44da155e5"
391 "5293b0930f89c1d21cc227eba9615ca47cce41d16eaddb5bf5dc9bc8477df5cf"
392 "21f460b83241e7d0fa3707f9d2b322b9aaa42747d0653168b095ca0a83f38426"
393 "688f6f10143cbd1b84c08583b09ed6192c7366ecc23af528fc2e8c585560f9bd"
394 "0fcc255b82fc70723a92506bb475ebc1f5ae34a902bf2aa75997ed90a54762c8"
395 "e83720833b2fd607eee1beb347a75d3bd0f174ed450a72cce79f1be426de9d6f"
396 "1a6feff052674af141b3cea89f8e749118392e9533c62ddad870e60d509fd7ab"
397 "fa0bc33c2774b29a0170089b30d82047d6e130c49f6965f9871d1928b7f13e3e"
398 "40ad8e3dc85195f4b312f9f6d8e4158aca23a611f6c6c798983555139942536f"
399 "6ac59bbd6cc88b9933f22e81429e835bfd4fec27c67520d64a0ad8fd7feb6a3f"
400 "be52dc56cbbf59644b0fad0c462ed02ffbf7258e4b94bdedefb187fbdb729a0d"
401 "56a36e876ac76de766eed416f39ab4e8b1982b8d0a87cd33182ae81ecf1d1d52"
402 "02cc3e82c5762646d15db5f13cde3e81c83715195f9af9f27e01e1829ce529fa"
403 "0f715db1f5d227bb201c7c127ea8d0e9c21739c7e9c6a0d8d5a1aaea5216c549"
404 "f3715f889e583555ac1bfd77339f3eff1bee75ee2fc45457f5c3ffe9401b8b67"
405 "f5bb3f305f3269fe6153ba34de3fa90016c76811cd54b4b49b17b244b1a4f6ed"
406 "fa2eaf46e2819aded26005b4ed712e8b700ae7b6123fa2c179640ee523f86436"
407 "0d116ee243f13c66d2cd61d422709648d905ab17edf0d0075d2fed443889e153"
408 "44069b69b2d3d8273f197f8468baf167074bf6dfdeea5871f0c0652ab2801f39"
409 "4ef6fbf841e8072c8bf65026d85d441ca61e78785a2e7ca1e743640fecd6dfad"
410 "8b77adcbb8bcb8ce8532ad0cd8b3e51269c26ad037545273f756c1a551192540"
411 "8a5045af469ca947f9a3f5457bcc325d05291a192abe75b4da7c97a61adc2fa2"
412 "47984edb5a03285f1c3b99f13f6a22f007029faffdd38b62f7bf909ce602e4e0"
413 "6ab1ec4543013d354d0dd86d8933a53c17ead02faf0cc740d7191fe475be2f79"
414 "40c234f8c73420774a7213fd2a477847527172c02a54928de5fde5f15616760e"
415 "6f7ff3c03a233aec880a939d9f1ca68be7f474fd13184fe8f6deb0c4ea01617e"
416 "a207d5d765d067fddba58b94f3b59d5996e9f5434f483e2f0079c48050f3ba94"
417 "1b589294c41a0f350451d566fe58a9c9688cc3a75da314ff4b3473eeac58664c"
418 "5922ae4efae850fe0f7f11dcc089bc0b4df9a64547a35b2559f4a4a3e7d3782d"
419 "850997baa589534921becde8dc3f76380ae36bd9730956aae9f59b121d8ae4db"
420 "bc586c6b45ad9d5c17cf6821b746177bc9fcb727db3f4aa190688c48826421de"
421 "5ebcd429e0d9b479e66e676e8f9a3b4bd92621f47357a7b1b27942121f5a6e00"
422 "87e4192a5f8cf4da942cc9d86eac5e"),
423 /*context_info=*/
424 "some context info",
425 /*plaintext=*/
426 "08b8b2b733424243760fe426a4b54908"
427 "632110a66c2f6591eabd3345e3e4eb98"
428 "fa6e264bf09efe12ee50f8f54e9f77b1"
429 "e355f6c50544e23fb1433ddf73be84d8"
430 "79de7c0046dc4996d9e773f4bc9efe57"
431 "38829adb26c81b37c93a1b270b20329d"
432 "658675fc6ea534e0810a4432826bf58c"
433 "941efb65d57a338bbd2e26640f89ffbc"
434 "1a858efcb8550ee3a5e1998bd177e93a"
435 "7363c344fe6b199ee5d02e82d522c4fe"
436 "ba15452f80288a821a579116ec6dad2b"
437 "3b310da903401aa62100ab5d1a36553e"
438 "06203b33890cc9b832f79ef80560ccb9"
439 "a39ce767967ed628c6ad573cb116dbef"
440 "efd75499da96bd68a8a97b928a8bbc10"
441 "3b6621fcde2beca1231d206be6cd9ec7"
442 "aff6f6c94fcd7204ed3455c68c83f4a4"
443 "1da4af2b74ef5c53f1d8ac70bdcb7ed1"
444 "85ce81bd84359d44254d95629e9855a9"
445 "4a7c1958d1f8ada5d0532ed8a5aa3fb2"
446 "d17ba70eb6248e594e1a2297acbbb39d"
447 "502f1a8c6eb6f1ce22b3de1a1f40cc24"
448 "554119a831a9aad6079cad88425de6bd"
449 "e1a9187ebb6092cf67bf2b13fd65f270"
450 "88d78b7e883c8759d2c4f5c65adb7553"
451 "878ad575f9fad878e80a0c9ba63bcbcc"
452 "2732e69485bbc9c90bfbd62481d9089b"
453 "eccf80cfe2df16a2cf65bd92dd597b07"
454 "07e0917af48bbb75fed413d238f5555a"
455 "7a569d80c3414a8d0859dc65a46128ba"
456 "b27af87a71314f318c782b23ebfe808b"
457 "82b0ce26401d2e22f04d83d1255dc51a"
458 "ddd3b75a2b1ae0784504df543af8969b"
459 "e3ea7082ff7fc9888c144da2af58429e"
460 "c96031dbcad3dad9af0dcbaaaf268cb8"
461 "fcffead94f3c7ca495e056a9b47acdb7"
462 "51fb73e666c6c655ade8297297d07ad1"
463 "ba5e43f1bca32301651339e22904cc8c"
464 "42f58c30c04aafdb038dda0847dd988d"
465 "cda6f3bfd15c4b4c4525004aa06eeff8"
466 "ca61783aacec57fb3d1f92b0fe2fd1a8"
467 "5f6724517b65e614ad6808d6f6ee34df"
468 "f7310fdc82aebfd904b01e1dc54b2927"
469 "094b2db68d6f903b68401adebf5a7e08"
470 "d78ff4ef5d63653a65040cf9bfd4aca7"
471 "984a74d37145986780fc0b16ac451649"
472 "de6188a7dbdf191f64b5fc5e2ab47b57"
473 "f7f7276cd419c17a3ca8e1b939ae49e4"
474 "88acba6b965610b5480109c8b17b80e1"
475 "b7b750dfc7598d5d5011fd2dcc5600a3"
476 "2ef5b52a1ecc820e308aa342721aac09"
477 "43bf6686b64b2579376504ccc493d97e"
478 "6aed3fb0f9cd71a43dd497f01f17c0e2"
479 "cb3797aa2a2f256656168e6c496afc5f"
480 "b93246f6b1116398a346f1a641f3b041"
481 "e989f7914f90cc2c7fff357876e506b5"
482 "0d334ba77c225bc307ba537152f3f161"
483 "0e4eafe595f6d9d90d11faa933a15ef1"
484 "369546868a7f3a45a96768d40fd9d034"
485 "12c091c6315cf4fde7cb68606937380d"
486 "b2eaaa707b4c4185c32eddcdd306705e"
487 "4dc1ffc872eeee475a64dfac86aba41c"
488 "0618983f8741c5ef68d3a101e8a3b8ca"
489 "c60c905c15fc910840b94c00a0b9d0",
490 }};
491
492 for (const TestVector& test_vector : hybrid_decryption_test_vectors) {
493 std::unique_ptr<HybridDecrypt> hybrid_decrypt =
494 EciesAeadHkdfHybridDecrypt::New(test_vector.private_key).value();
495 EXPECT_THAT(hybrid_decrypt->Decrypt(test_vector.ciphertext,
496 test_vector.context_info),
497 IsOkAndHolds(Eq(test_vector.plaintext)));
498 }
499 }
500
501 } // namespace
502 } // namespace tink
503 } // namespace crypto
504