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
17 #ifndef __KERNEL_KEY_RING_H__
18 #define __KERNEL_KEY_RING_H__
20 #include <sys/types.h>
21 #include <linux/keyctl.h>
25 /* special process keyring shortcut IDs */
26 #define KEY_SPEC_THREAD_KEYRING -1
27 #define KEY_SPEC_PROCESS_KEYRING -2
28 #define KEY_SPEC_SESSION_KEYRING -3
29 #define KEY_SPEC_USER_KEYRING -4
30 #define KEY_SPEC_USER_SESSION_KEYRING -5
31 #define KEY_SPEC_GROUP_KEYRING -6
33 class KernelKeyRing final {
35 KernelKeyRing() = delete;
36 KernelKeyRing(const KernelKeyRing&) = delete;
37 KernelKeyRing(KernelKeyRing&&) = delete;
39 KernelKeyRing& operator=(const KernelKeyRing&) = delete;
40 KernelKeyRing& operator=(KernelKeyRing&&) = delete;
42 static int32_t add(const std::string& type, const std::string& description, const void* payload, size_t plen, int32_t ringid);
44 static long search(int32_t ringid, const std::string& type, const std::string& description, int32_t destringid);
46 static long link(int32_t keyid, int32_t ringid);
47 static long unlink(int32_t keyid, int32_t ringid);
50 #endif //!__KERNEL_KEY_RING_H__