1c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
2c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Copyright (C) 2011 The Android Open Source Project
3c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
4c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Licensed under the Apache License, Version 2.0 (the "License");
5c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// you may not use this file except in compliance with the License.
6c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// You may obtain a copy of the License at
7c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
8c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//      http://www.apache.org/licenses/LICENSE-2.0
9c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
10c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Unless required by applicable law or agreed to in writing, software
11c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// distributed under the License is distributed on an "AS IS" BASIS,
12c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// See the License for the specific language governing permissions and
14c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// limitations under the License.
15c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
16877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
17c45688bb3881f0c2216e6ec0e19ebda0be33e871Ben Chan#ifndef SHILL_CRYPTO_INTERFACE_H_
18c45688bb3881f0c2216e6ec0e19ebda0be33e871Ben Chan#define SHILL_CRYPTO_INTERFACE_H_
19877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
20877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov#include <string>
21877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
22877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkovnamespace shill {
23877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
24877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov// An interface to an encryption/decryption module.
25877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkovclass CryptoInterface {
26877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov public:
27877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov  virtual ~CryptoInterface() {}
28877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
29877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov  // Returns a unique identifier for this crypto module.
30877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov  virtual std::string GetID() = 0;
31877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
32877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov  // Encrypts |plaintext| into |ciphertext|. Returns true on success.
33a794cd60a7339d576ea2eed263a4f0a20fb255afPaul Stewart  virtual bool Encrypt(const std::string& plaintext,
34a794cd60a7339d576ea2eed263a4f0a20fb255afPaul Stewart                       std::string* ciphertext) = 0;
35877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
36877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov  // Decrypts |ciphertext| into |plaintext|. Returns true on success.
37a794cd60a7339d576ea2eed263a4f0a20fb255afPaul Stewart  virtual bool Decrypt(const std::string& ciphertext,
38a794cd60a7339d576ea2eed263a4f0a20fb255afPaul Stewart                       std::string* plaintext) = 0;
39877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov};
40877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
41877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov}  // namespace shill
42877642b0c9e2416f69a2f76b26539f30ef98d43cDarin Petkov
43c45688bb3881f0c2216e6ec0e19ebda0be33e871Ben Chan#endif  // SHILL_CRYPTO_INTERFACE_H_
44