blob: ec2294b75e39439a379754bd9a21ab11d9129de7 [file] [log] [blame]
Alex Vakulenkodf381642015-10-08 07:34:23 -07001// Copyright 2015 The Android Open Source Project
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#ifndef BUFFET_KEYSTORE_ENCRYPTOR_H_
16#define BUFFET_KEYSTORE_ENCRYPTOR_H_
17
18#include "buffet/encryptor.h"
19
20#include <memory>
21
22#include <keystore/keystore_client.h>
23
24namespace buffet {
25
26// An Encryptor implementation backed by Brillo Keystore. This class is intended
27// to be the default encryptor on platforms that support it. An implementation
28// of Encryptor::CreateDefaultEncryptor is provided for this class.
29class KeystoreEncryptor : public Encryptor {
30 public:
31 explicit KeystoreEncryptor(
32 std::unique_ptr<keystore::KeystoreClient> keystore);
33 ~KeystoreEncryptor() override = default;
34
35 bool EncryptWithAuthentication(const std::string& plaintext,
36 std::string* ciphertext) override;
37 bool DecryptWithAuthentication(const std::string& ciphertext,
38 std::string* plaintext) override;
39
40 private:
41 std::unique_ptr<keystore::KeystoreClient> keystore_;
42};
43
44} // namespace buffet
45
46#endif // BUFFET_KEYSTORE_ENCRYPTOR_H_