1 // Copyright 2017 Google Inc. 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_DETERMINISTIC_AEAD_H_ 18 #define TINK_DETERMINISTIC_AEAD_H_ 19 20 #include <string> 21 22 #include "absl/strings/string_view.h" 23 #include "tink/util/statusor.h" 24 25 namespace crypto { 26 namespace tink { 27 28 /////////////////////////////////////////////////////////////////////////////// 29 // The interface for deterministic authenticated encryption with associated 30 // data. 31 // TODO(bleichen): Copy the interface from Java. 32 // Check the properties: 33 // - authenticated 34 // - secure in multi-user setting 35 // - thread safe/copy safe 36 // References: 37 // https://eprint.iacr.org/2016/1124.pdf 38 class DeterministicAead { 39 public: 40 // Encrypts 'plaintext' with 'associated_data' as associated data 41 // deterministically, and returns the resulting ciphertext. 42 // The ciphertext allows for checking authenticity and integrity 43 // of the associated data, but does not guarantee its secrecy. 44 virtual crypto::tink::util::StatusOr<std::string> EncryptDeterministically( 45 absl::string_view plaintext, absl::string_view associated_data) const = 0; 46 47 // Decrypts 'ciphertext' with 'associated_data' as associated data, 48 // and returns the resulting plaintext. 49 // The decryption verifies the authenticity and integrity 50 // of the associated data, but there are no guarantees wrt. secrecy 51 // of that data. 52 virtual crypto::tink::util::StatusOr<std::string> DecryptDeterministically( 53 absl::string_view ciphertext, 54 absl::string_view associated_data) const = 0; 55 56 virtual ~DeterministicAead() = default; 57 }; 58 59 } // namespace tink 60 } // namespace crypto 61 62 #endif // TINK_DETERMINISTIC_AEAD_H_ 63