aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/keys.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/keys.txt')
-rw-r--r--Documentation/keys.txt93
1 files changed, 79 insertions, 14 deletions
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index 947d57d53453..51652d39e61c 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -4,7 +4,7 @@
4 4
5This service allows cryptographic keys, authentication tokens, cross-domain 5This service allows cryptographic keys, authentication tokens, cross-domain
6user mappings, and similar to be cached in the kernel for the use of 6user mappings, and similar to be cached in the kernel for the use of
7filesystems other kernel services. 7filesystems and other kernel services.
8 8
9Keyrings are permitted; these are a special type of key that can hold links to 9Keyrings are permitted; these are a special type of key that can hold links to
10other keys. Processes each have three standard keyring subscriptions that a 10other keys. Processes each have three standard keyring subscriptions that a
@@ -726,6 +726,15 @@ call, and the key released upon close. How to deal with conflicting keys due to
726two different users opening the same file is left to the filesystem author to 726two different users opening the same file is left to the filesystem author to
727solve. 727solve.
728 728
729To access the key manager, the following header must be #included:
730
731 <linux/key.h>
732
733Specific key types should have a header file under include/keys/ that should be
734used to access that type. For keys of type "user", for example, that would be:
735
736 <keys/user-type.h>
737
729Note that there are two different types of pointers to keys that may be 738Note that there are two different types of pointers to keys that may be
730encountered: 739encountered:
731 740
@@ -791,6 +800,36 @@ payload contents" for more information.
791 passed to the key_type->request_key() op if it exists. 800 passed to the key_type->request_key() op if it exists.
792 801
793 802
803(*) A key can be requested asynchronously by calling one of:
804
805 struct key *request_key_async(const struct key_type *type,
806 const char *description,
807 const char *callout_string);
808
809 or:
810
811 struct key *request_key_async_with_auxdata(const struct key_type *type,
812 const char *description,
813 const char *callout_string,
814 void *aux);
815
816 which are asynchronous equivalents of request_key() and
817 request_key_with_auxdata() respectively.
818
819 These two functions return with the key potentially still under
820 construction. To wait for contruction completion, the following should be
821 called:
822
823 int wait_for_key_construction(struct key *key, bool intr);
824
825 The function will wait for the key to finish being constructed and then
826 invokes key_validate() to return an appropriate value to indicate the state
827 of the key (0 indicates the key is usable).
828
829 If intr is true, then the wait can be interrupted by a signal, in which
830 case error ERESTARTSYS will be returned.
831
832
794(*) When it is no longer required, the key should be released using: 833(*) When it is no longer required, the key should be released using:
795 834
796 void key_put(struct key *key); 835 void key_put(struct key *key);
@@ -924,7 +963,11 @@ DEFINING A KEY TYPE
924 963
925A kernel service may want to define its own key type. For instance, an AFS 964A kernel service may want to define its own key type. For instance, an AFS
926filesystem might want to define a Kerberos 5 ticket key type. To do this, it 965filesystem might want to define a Kerberos 5 ticket key type. To do this, it
927author fills in a struct key_type and registers it with the system. 966author fills in a key_type struct and registers it with the system.
967
968Source files that implement key types should include the following header file:
969
970 <linux/key-type.h>
928 971
929The structure has a number of fields, some of which are mandatory: 972The structure has a number of fields, some of which are mandatory:
930 973
@@ -1053,22 +1096,44 @@ The structure has a number of fields, some of which are mandatory:
1053 as might happen when the userspace buffer is accessed. 1096 as might happen when the userspace buffer is accessed.
1054 1097
1055 1098
1056 (*) int (*request_key)(struct key *key, struct key *authkey, const char *op, 1099 (*) int (*request_key)(struct key_construction *cons, const char *op,
1057 void *aux); 1100 void *aux);
1058 1101
1059 This method is optional. If provided, request_key() and 1102 This method is optional. If provided, request_key() and friends will
1060 request_key_with_auxdata() will invoke this function rather than 1103 invoke this function rather than upcalling to /sbin/request-key to operate
1061 upcalling to /sbin/request-key to operate upon a key of this type. 1104 upon a key of this type.
1105
1106 The aux parameter is as passed to request_key_async_with_auxdata() and
1107 similar or is NULL otherwise. Also passed are the construction record for
1108 the key to be operated upon and the operation type (currently only
1109 "create").
1110
1111 This method is permitted to return before the upcall is complete, but the
1112 following function must be called under all circumstances to complete the
1113 instantiation process, whether or not it succeeds, whether or not there's
1114 an error:
1115
1116 void complete_request_key(struct key_construction *cons, int error);
1117
1118 The error parameter should be 0 on success, -ve on error. The
1119 construction record is destroyed by this action and the authorisation key
1120 will be revoked. If an error is indicated, the key under construction
1121 will be negatively instantiated if it wasn't already instantiated.
1122
1123 If this method returns an error, that error will be returned to the
1124 caller of request_key*(). complete_request_key() must be called prior to
1125 returning.
1126
1127 The key under construction and the authorisation key can be found in the
1128 key_construction struct pointed to by cons:
1129
1130 (*) struct key *key;
1131
1132 The key under construction.
1062 1133
1063 The aux parameter is as passed to request_key_with_auxdata() or is NULL 1134 (*) struct key *authkey;
1064 otherwise. Also passed are the key to be operated upon, the
1065 authorisation key for this operation and the operation type (currently
1066 only "create").
1067 1135
1068 This function should return only when the upcall is complete. Upon return 1136 The authorisation key.
1069 the authorisation key will be revoked, and the target key will be
1070 negatively instantiated if it is still uninstantiated. The error will be
1071 returned to the caller of request_key*().
1072 1137
1073 1138
1074============================ 1139============================