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, void **_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(3),
74       request-key(8)
75
76
77
78Linux                             4 May 2006                    KEYCTL_READ(3)
Impressum