1 // Copyright 2022 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 #ifndef TINK_HYBRID_INTERNAL_TEST_HPKE_CONTEXT_BORINGSSL_H_ 18 #define TINK_HYBRID_INTERNAL_TEST_HPKE_CONTEXT_BORINGSSL_H_ 19 20 #include <stddef.h> 21 22 #include <memory> 23 #include <string> 24 #include <utility> 25 26 #include "absl/strings/string_view.h" 27 #include "openssl/base.h" 28 #include "openssl/hpke.h" 29 #include "tink/hybrid/internal/hpke_context_boringssl.h" 30 #include "tink/hybrid/internal/hpke_util.h" 31 #include "tink/internal/ssl_unique_ptr.h" 32 #include "tink/util/statusor.h" 33 34 namespace crypto { 35 namespace tink { 36 namespace internal { 37 38 class TestHpkeContextBoringSsl : public HpkeContextBoringSsl { 39 public: 40 // Sets up a test HPKE sender context. Returns an error if initialization 41 // fails. Otherwise, returns a unique pointer to the sender context. 42 // 43 // `params`: HPKE parameters (KEM, KDF, and AEAD). 44 // `recipient_public_key`: KEM-encoding of recipient public key. 45 // `info`: Application-specific context for key derivation. 46 // `seed_for_testing`: Seed used to match test vector values. 47 static crypto::tink::util::StatusOr<SenderHpkeContextBoringSsl> SetupSender( 48 const HpkeParams& params, absl::string_view recipient_public_key, 49 absl::string_view info, absl::string_view seed_for_testing); 50 51 private: TestHpkeContextBoringSsl(SslUniquePtr<EVP_HPKE_CTX> context)52 explicit TestHpkeContextBoringSsl(SslUniquePtr<EVP_HPKE_CTX> context) 53 : HpkeContextBoringSsl(std::move(context)) {} 54 }; 55 56 } // namespace internal 57 } // namespace tink 58 } // namespace crypto 59 60 #endif // TINK_HYBRID_INTERNAL_TEST_HPKE_CONTEXT_BORINGSSL_H_ 61