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 #ifndef TINK_EXAMPLES_WALKTHROUGH_OBTAIN_AND_USE_A_PRIMITIVE_H_ 17 #define TINK_EXAMPLES_WALKTHROUGH_OBTAIN_AND_USE_A_PRIMITIVE_H_ 18 19 #include <memory> 20 #include <string> 21 22 #include "absl/strings/string_view.h" 23 #include "tink/keyset_handle.h" 24 #include "tink/util/statusor.h" 25 26 namespace tink_walkthrough { 27 28 // AEAD encrypts `plaintext` with `associated_data` and the primary key in 29 // `keyset_handle`. 30 crypto::tink::util::StatusOr<std::string> AeadEncrypt( 31 const crypto::tink::KeysetHandle& keyset_handle, 32 absl::string_view palintext, absl::string_view associated_data); 33 34 // AEAD decrypts `ciphertext` with `associated_data` and the correct key in 35 // `keyset_handle`. 36 crypto::tink::util::StatusOr<std::string> AeadDecrypt( 37 const crypto::tink::KeysetHandle& keyset_handle, 38 absl::string_view ciphertext, absl::string_view associated_data); 39 40 } // namespace tink_walkthrough 41 42 #endif // TINK_EXAMPLES_WALKTHROUGH_OBTAIN_AND_USE_A_PRIMITIVE_H_ 43