1 // Copyright 2021 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_HPKE_DECRYPT_H_ 18 #define TINK_HYBRID_INTERNAL_HPKE_DECRYPT_H_ 19 20 #include <memory> 21 #include <string> 22 #include <utility> 23 24 #include "tink/hybrid_decrypt.h" 25 #include "tink/util/secret_data.h" 26 #include "tink/util/statusor.h" 27 #include "proto/hpke.pb.h" 28 29 namespace crypto { 30 namespace tink { 31 32 class HpkeDecrypt : public HybridDecrypt { 33 public: 34 // Copyable and movable. 35 HpkeDecrypt(const HpkeDecrypt& other) = default; 36 HpkeDecrypt& operator=(const HpkeDecrypt& other) = default; 37 HpkeDecrypt(HpkeDecrypt&& other) = default; 38 HpkeDecrypt& operator=(HpkeDecrypt&& other) = default; 39 40 static crypto::tink::util::StatusOr<std::unique_ptr<HybridDecrypt>> New( 41 const google::crypto::tink::HpkePrivateKey& recipient_private_key); 42 43 crypto::tink::util::StatusOr<std::string> Decrypt( 44 absl::string_view ciphertext, 45 absl::string_view context_info) const override; 46 47 private: HpkeDecrypt(const google::crypto::tink::HpkeParams & hpke_params,const util::SecretData & recipient_private_key)48 HpkeDecrypt(const google::crypto::tink::HpkeParams& hpke_params, 49 const util::SecretData& recipient_private_key) 50 : hpke_params_(hpke_params), 51 recipient_private_key_(recipient_private_key) {} 52 53 google::crypto::tink::HpkeParams hpke_params_; 54 util::SecretData recipient_private_key_; 55 }; 56 57 } // namespace tink 58 } // namespace crypto 59 60 #endif // TINK_HYBRID_INTERNAL_HPKE_DECRYPT_H_ 61