2 * Copyright (c) 2015 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
18 #include <sys/mount.h>
19 #include <sys/syscall.h>
20 #include <linux/limits.h>
22 #include "kernel-keyring.h"
25 #define KEYCTL_SEARCH 10
28 int32_t KernelKeyRing::add(const std::string& type, const std::string& description, const void* payload, size_t plen, int32_t ringid)
30 return ::syscall(__NR_add_key, type.c_str(), description.c_str(), payload, plen, ringid);
33 long KernelKeyRing::search(int32_t ringid, const std::string& type, const std::string& description, int32_t destringid)
35 return ::syscall(__NR_keyctl, KEYCTL_SEARCH, ringid, type.c_str(), description.c_str(), destringid);
38 long KernelKeyRing::link(int32_t keyid, int32_t ringid)
40 return ::syscall(__NR_keyctl, KEYCTL_LINK, keyid, ringid);
43 long KernelKeyRing::unlink(int32_t keyid, int32_t ringid)
45 return ::syscall(__NR_keyctl, KEYCTL_UNLINK, keyid, ringid);