Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\encrypted-keys\encrypted.c Create Date:2022-07-28 18:32:55
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:datablob_parse - parse the keyctl data* datablob format:* new [<format>] <master-key name> <decrypted data length>* load [<format>] <master-key name> <decrypted data length>* <encrypted iv + data>* update <new-master-key name>* Tokenizes a copy of the

Proto:static int datablob_parse(char *datablob, const char **format, char **master_desc, char **decrypted_datalen, char **hex_encoded_iv)

Type:int

Parameter:

TypeParameterName
char *datablob
const char **format
char **master_desc
char **decrypted_datalen
char **hex_encoded_iv
176  ret = -EINVAL
181  keyword = strsep - Split a string into tokens*@s: The string to be searched*@ct: The characters to search for* strsep() updates @s to point after the token, ready for the next call.* It returns empty tokens, too, behaving exactly like the libc function
182  If Not keyword Then
183  pr_info("encrypted_key: insufficient parameters specified\n")
184  Return ret
186  key_cmd = match_token(keyword, key_tokens, args)
189  p = strsep - Split a string into tokens*@s: The string to be searched*@ct: The characters to search for* strsep() updates @s to point after the token, ready for the next call.* It returns empty tokens, too, behaving exactly like the libc function
190  If Not p Then
191  pr_err("encrypted_key: insufficient parameters specified\n")
192  Return ret
195  key_format = match_token(p, key_format_tokens, args)
197  Case key_format == Opt_ecryptfs
198  Case key_format == Opt_enc32
199  Case key_format == Opt_default
200  format = p
201  master_desc = strsep - Split a string into tokens*@s: The string to be searched*@ct: The characters to search for* strsep() updates @s to point after the token, ready for the next call.* It returns empty tokens, too, behaving exactly like the libc function
202  Break
203  Case key_format == Opt_error
204  master_desc = p
205  Break
208  If Not master_desc Then
209  pr_info("encrypted_key: master key parameter is missing\n")
210  Go to out
213  If valid_master_desc - verify the 'key-type:desc' of a new/updated master-key* key-type:= "trusted:" | "user:"* desc:= master-key description* Verify that 'key-type' is valid and that 'desc' exists. On key update, < 0 Then
214  pr_info("encrypted_key: master key parameter \'%s\' is invalid\n", * master_desc)
216  Go to out
219  If decrypted_datalen Then
220  decrypted_datalen = strsep - Split a string into tokens*@s: The string to be searched*@ct: The characters to search for* strsep() updates @s to point after the token, ready for the next call.* It returns empty tokens, too, behaving exactly like the libc function
221  If Not decrypted_datalen Then
222  pr_info("encrypted_key: keylen parameter is missing\n")
223  Go to out
228  Case key_cmd == Opt_new
229  If Not decrypted_datalen Then
230  pr_info("encrypted_key: keyword \'%s\' not allowed when called from .update method\n", keyword)
232  Break
234  ret = 0
235  Break
236  Case key_cmd == Opt_load
237  If Not decrypted_datalen Then
238  pr_info("encrypted_key: keyword \'%s\' not allowed when called from .update method\n", keyword)
240  Break
243  If Not hex_encoded_iv Then
244  pr_info("encrypted_key: hex blob is missing\n")
245  Break
247  ret = 0
248  Break
249  Case key_cmd == Opt_update
250  If decrypted_datalen Then
251  pr_info("encrypted_key: keyword \'%s\' not allowed when called from .instantiate method\n", keyword)
254  Break
256  ret = 0
257  Break
258  Case key_cmd == Opt_err
259  pr_info("encrypted_key: keyword \'%s\' not recognized\n", keyword)
261  Break
263  out :
264  Return ret
Caller
NameDescribe
encrypted_instantiaterypted_instantiate - instantiate an encrypted key* Decrypt an existing encrypted datablob or create a new encrypted key* based on a kernel random number.* On success, return 0. Otherwise return errno.
encrypted_updaterypted_update - update the master key description* Change the master key description for an existing encrypted key.* The next read will return an encrypted datablob using the new* master key description.* On success, return 0. Otherwise return errno.