Replace private implemetation with interface.
[platform/core/security/key-manager.git] / src / include / ckm / ckm-control.h
1 /*
2  *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  *
16  *
17  * @file        ckm-manager.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Main header file for client library.
21  */
22 #pragma once
23
24 #include <string>
25 #include <vector>
26 #include <memory>
27
28 #include <ckm/ckm-error.h>
29
30 // Central Key Manager namespace
31 namespace CKM {
32
33 class Control;
34 typedef std::shared_ptr<Control> ControlShPtr;
35
36 // used by login manager to unlock user data with global password
37 class Control
38 {
39 public:
40     // decrypt user key with password
41     virtual int unlockUserKey(uid_t user, const std::string &password) const = 0;
42
43     // remove user key from memory
44     virtual int lockUserKey(uid_t user) const = 0;
45
46     // remove user data from Store and erase key used for encryption
47     virtual int removeUserData(uid_t user) const = 0;
48
49     // change password for user
50     virtual int changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) const = 0;
51
52     // This is work around for security-server api - resetPassword that may be called without passing oldPassword.
53     // This api should not be supported on tizen 3.0
54     // User must be already logged in and his DKEK is already loaded into memory in plain text form.
55     // The service will use DKEK in plain text and encrypt it in encrypted form (using new password).
56     virtual int resetUserPassword(uid_t user, const std::string &newPassword) const = 0;
57
58     virtual ~Control(){}
59
60     static ControlShPtr create();
61 };
62
63 } // namespace CKM
64