2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
16 #include <ode-key-storage-plugin.h>
21 static int copy(const unsigned char* in, size_t in_len,
22 unsigned char** out, size_t* out_len)
24 if (in == NULL || in_len == 0 || out == NULL || out_len == NULL)
25 return ODE_KSP_ERROR_INVALID_PARAMETER;
27 *out = malloc(in_len * sizeof(unsigned char));
29 return ODE_KSP_ERROR_UNKNOWN;
31 memcpy(*out, in, in_len * sizeof(unsigned char));
34 return ODE_KSP_ERROR_NONE;
37 int ode_ksp_store(const unsigned char* key, size_t key_len,
38 unsigned char** token, size_t* token_len)
40 return copy(key, key_len, token, token_len);
43 int ode_ksp_load(const unsigned char* token, size_t token_len,
44 unsigned char** key, size_t* key_len)
46 return copy(token, token_len, key, key_len);
49 int ode_ksp_remove(const unsigned char* token, size_t token_len)
51 return ODE_KSP_ERROR_NONE;