1KEYCTL_READ(3)            Linux Key Management Calls            KEYCTL_READ(3)
2
3
4

NAME

6       keyctl_read - Read a key
7

SYNOPSIS

9       #include <keyutils.h>
10
11       long keyctl_read(key_serial_t key, char *buffer,
12       size_tbuflen);
13
14       long keyctl_read_alloc(key_serial_t key, char **_buffer);
15

DESCRIPTION

17       keyctl_read() reads the payload of a key if the key type supports it.
18
19       The caller must have read permission on a key to be able to read it.
20
21       buffer  and  buflen specify the buffer into which the payload data will
22       be placed.  If the buffer is too small, the full size  of  the  payload
23       will be returned, and no copy will take place.
24
25       keyctl_read_alloc()  is  similar  to keyctl_read() except that it allo‐
26       cates a buffer big enough to hold the payload data and places the  data
27       in  it.   If successful, A pointer to the buffer is placed in *_buffer.
28       The caller must free the buffer.
29

READING KEYRINGS

31       This call can be used to list the contents of a keyring.  The  data  is
32       presented to the user as an array of key_serial_t values, each of which
33       corresponds to a key to which the keyring holds a link.
34
35       The size of the keyring will be sizeof(key_serial_t) multiplied by  the
36       number of keys.  The size of key_serial_t is invariant across different
37       word sizes, though the byte-ordering is as appropriate for the kernel.
38

RETURN VALUE

40       On success keyctl_read() returns the amount of  data  placed  into  the
41       buffer.   If the buffer was too small, then the size of buffer required
42       will be returned, but no data will be transferred.  On error, the value
43       -1  will  be  returned  and  errno will have been set to an appropriate
44       error.
45
46       On success keyctl_read_alloc() returns the amount of data in  the  buf‐
47       fer.   On error, the value -1 will be returned and errno will have been
48       set to an appropriate error.
49

ERRORS

51       ENOKEY The key specified is invalid.
52
53       EKEYEXPIRED
54              The key specified has expired.
55
56       EKEYREVOKED
57              The key specified had been revoked.
58
59       EACCES The key exists, but is not readable by the calling process.
60
61       EOPNOTSUPP
62              The key type does not support reading of the payload data.
63

LINKING

65       This is a library function that can  be  found  in  libkeyutils.   When
66       linking, -lkeyutils should be specified to the linker.
67

SEE ALSO

69       keyctl(1),
70       add_key(2),
71       keyctl(2),
72       request_key(2),
73       keyctl_get_keyring_ID(3),
74       keyctl_join_session_keyring(3),
75       keyctl_update(3),
76       keyctl_revoke(3),
77       keyctl_chown(3),
78       keyctl_setperm(3),
79       keyctl_describe(3),
80       keyctl_clear(3),
81       keyctl_link(3),
82       keyctl_unlink(3),
83       keyctl_search(3),
84       keyctl_instantiate(3),
85       keyctl_negate(3),
86       keyctl_set_reqkey_keyring(3),
87       keyctl_set_timeout(3),
88       keyctl_assume_authority(3),
89       keyctl_describe_alloc(3),
90       request-key(8)
91
92
93
94Linux                             4 May 2006                    KEYCTL_READ(3)
Impressum