Fixed missed <functional> header include
[platform/core/security/ode.git] / dummy-ksp / main.c
1 /*
2  *  Copyright (c) 2017 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 #include <ode-key-storage-plugin.h>
17
18 #include <stdlib.h>
19 #include <string.h>
20
21 static int copy(const unsigned char* in, size_t in_len,
22                                 unsigned char** out, size_t* out_len)
23 {
24         if (in == NULL || in_len == 0 || out == NULL || out_len == NULL)
25                 return ODE_KSP_ERROR_INVALID_PARAMETER;
26
27         *out = malloc(in_len * sizeof(unsigned char));
28         if (*out == NULL)
29                 return ODE_KSP_ERROR_UNKNOWN;
30
31         memcpy(*out, in, in_len * sizeof(unsigned char));
32         *out_len = in_len;
33
34         return ODE_KSP_ERROR_NONE;
35 }
36
37 int ode_ksp_store(const unsigned char* key, size_t key_len,
38                                   unsigned char** token, size_t* token_len)
39 {
40         return copy(key, key_len, token, token_len);
41 }
42
43 int ode_ksp_load(const unsigned char* token, size_t token_len,
44                                  unsigned char** key, size_t* key_len)
45 {
46         return copy(token, token_len, key, key_len);
47 }
48
49 int ode_ksp_remove(const unsigned char* token, size_t token_len)
50 {
51         return ODE_KSP_ERROR_NONE;
52 }