keyutils_raw/
constants.rs

1// Copyright (c) 2018, Ben Boeckel
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification,
5// are permitted provided that the following conditions are met:
6//
7//     * Redistributions of source code must retain the above copyright notice,
8//       this list of conditions and the following disclaimer.
9//     * Redistributions in binary form must reproduce the above copyright notice,
10//       this list of conditions and the following disclaimer in the documentation
11//       and/or other materials provided with the distribution.
12//     * Neither the name of this project nor the names of its contributors
13//       may be used to endorse or promote products derived from this software
14//       without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27use crate::{KeyPermissions, KeyringSerial};
28
29// TODO: change these to &CStr when const fns get unblocked.
30pub const KEY_TYPE_KEYRING:                 &str = "keyring";
31pub const KEY_TYPE_USER:                    &str = "user";
32pub const KEY_TYPE_LOGON:                   &str = "logon";
33pub const KEY_TYPE_BIG_KEY:                 &str = "big_key";
34
35pub const KEY_SPEC_THREAD_KEYRING:          KeyringSerial = unsafe { KeyringSerial::new_unchecked(-1) };
36pub const KEY_SPEC_PROCESS_KEYRING:         KeyringSerial = unsafe { KeyringSerial::new_unchecked(-2) };
37pub const KEY_SPEC_SESSION_KEYRING:         KeyringSerial = unsafe { KeyringSerial::new_unchecked(-3) };
38pub const KEY_SPEC_USER_KEYRING:            KeyringSerial = unsafe { KeyringSerial::new_unchecked(-4) };
39pub const KEY_SPEC_USER_SESSION_KEYRING:    KeyringSerial = unsafe { KeyringSerial::new_unchecked(-5) };
40pub const KEY_SPEC_GROUP_KEYRING:           KeyringSerial = unsafe { KeyringSerial::new_unchecked(-6) };
41pub const KEY_SPEC_REQKEY_AUTH_KEY:         KeyringSerial = unsafe { KeyringSerial::new_unchecked(-7) };
42
43pub const KEYCTL_SUPPORTS_ENCRYPT:          u32 = 0x01;
44pub const KEYCTL_SUPPORTS_DECRYPT:          u32 = 0x02;
45pub const KEYCTL_SUPPORTS_SIGN:             u32 = 0x04;
46pub const KEYCTL_SUPPORTS_VERIFY:           u32 = 0x08;
47
48pub const KEY_POS_VIEW:    KeyPermissions = 0x0100_0000;     /* possessor can view a key's attributes */
49pub const KEY_POS_READ:    KeyPermissions = 0x0200_0000;     /* possessor can read key payload / view keyring */
50pub const KEY_POS_WRITE:   KeyPermissions = 0x0400_0000;     /* possessor can update key payload / add link to keyring */
51pub const KEY_POS_SEARCH:  KeyPermissions = 0x0800_0000;     /* possessor can find a key in search / search a keyring */
52pub const KEY_POS_LINK:    KeyPermissions = 0x1000_0000;     /* possessor can create a link to a key/keyring */
53pub const KEY_POS_SETATTR: KeyPermissions = 0x2000_0000;     /* possessor can set key attributes */
54pub const KEY_POS_ALL:     KeyPermissions = 0x3f00_0000;
55
56pub const KEY_USR_VIEW:    KeyPermissions = 0x0001_0000;     /* user permissions... */
57pub const KEY_USR_READ:    KeyPermissions = 0x0002_0000;
58pub const KEY_USR_WRITE:   KeyPermissions = 0x0004_0000;
59pub const KEY_USR_SEARCH:  KeyPermissions = 0x0008_0000;
60pub const KEY_USR_LINK:    KeyPermissions = 0x0010_0000;
61pub const KEY_USR_SETATTR: KeyPermissions = 0x0020_0000;
62pub const KEY_USR_ALL:     KeyPermissions = 0x003f_0000;
63
64pub const KEY_GRP_VIEW:    KeyPermissions = 0x0000_0100;     /* group permissions... */
65pub const KEY_GRP_READ:    KeyPermissions = 0x0000_0200;
66pub const KEY_GRP_WRITE:   KeyPermissions = 0x0000_0400;
67pub const KEY_GRP_SEARCH:  KeyPermissions = 0x0000_0800;
68pub const KEY_GRP_LINK:    KeyPermissions = 0x0000_1000;
69pub const KEY_GRP_SETATTR: KeyPermissions = 0x0000_2000;
70pub const KEY_GRP_ALL:     KeyPermissions = 0x0000_3f00;
71
72pub const KEY_OTH_VIEW:    KeyPermissions = 0x0000_0001;     /* third party permissions... */
73pub const KEY_OTH_READ:    KeyPermissions = 0x0000_0002;
74pub const KEY_OTH_WRITE:   KeyPermissions = 0x0000_0004;
75pub const KEY_OTH_SEARCH:  KeyPermissions = 0x0000_0008;
76pub const KEY_OTH_LINK:    KeyPermissions = 0x0000_0010;
77pub const KEY_OTH_SETATTR: KeyPermissions = 0x0000_0020;
78pub const KEY_OTH_ALL:     KeyPermissions = 0x0000_003f;