函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\dh.c Create Date:2022-07-27 20:01:40
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:__keyctl_dh_compute

函数原型:long __keyctl_dh_compute(struct keyctl_dh_params __user *params, char __user *buffer, size_t buflen, struct keyctl_kdf_params *kdfcopy)

返回类型:long

参数:

类型参数名称
struct keyctl_dh_params __user *params
char __user *buffer
size_tbuflen
struct keyctl_kdf_params *kdfcopy
243  struct kdf_sdesc * sdesc = NULL
245  如果非params或非bufferbuflen
246  ret等于负EINVAL
247  转到:out1
249  如果copy_from_user( & pcopy, params, pcopy的长度)不等于0则
250  ret等于负EFAULT
251  转到:out1
254  如果kdfcopy
258  ret等于负EINVAL
259  转到:out1
264  ret等于负EMSGSIZE
265  转到:out1
269  hashname等于strndup_user - duplicate an existing string from user space*@s: The string to duplicate*@n: Maximum number of bytes to copy, including the trailing NUL.* Return: newly allocated copy of @s or an ERR_PTR() in case of error
270  如果是错误
271  ret等于错误
272  转到:out1
276  ret等于kdf_alloc( & sdesc, hashname)
277  释放内存
278  如果ret则转到:out1
282  memset( & dh_inputs, 0, dh_inputs的长度)
284  dlen等于dh_data_from_key(prime, & p)
285  如果dlen小于0则
286  ret等于dlen
287  转到:out1
289  p_size等于dlen
291  dlen等于dh_data_from_key(base, & g)
292  如果dlen小于0则
293  ret等于dlen
294  转到:out2
296  g_size等于dlen
298  dlen等于dh_data_from_key(private, & key)
299  如果dlen小于0则
300  ret等于dlen
301  转到:out2
303  key_size等于dlen
305  secretlen等于rypto_dh_key_len() - Obtain the size of the private DH key*@params: private DH key* This function returns the packet DH key size
306  secret等于开辟内存
307  如果非secret
308  ret等于负ENOMEM
309  转到:out2
311  ret等于rypto_dh_encode_key() - encode the private key*@buf: Buffer allocated by the caller to hold the packet DH* private key
312  如果ret则转到:out3
315  tfm等于rypto_alloc_kpp() - allocate KPP tfm handle*@alg_name: is the name of the kpp algorithm (e.g. "dh", "ecdh")*@type: specifies the type of the algorithm*@mask: specifies the mask for the algorithm* Allocate a handle for kpp algorithm
316  如果是错误
317  ret等于错误
318  转到:out3
321  ret等于rypto_kpp_set_secret() - Invoke kpp operation* Function invokes the specific kpp operation for a given alg.*@tfm: tfm handle*@buffer: Buffer holding the packet representation of the private* key. The structure of the packet key depends on the particular
322  如果ret则转到:out4
325  outlen等于rypto_kpp_maxsize() - Get len for output buffer* Function returns the output buffer size required for a given key
327  如果非kdfcopy
332  如果buflen恒等于0则
333  ret等于outlen
334  转到:out4
335  否则如果outlen大于buflen
336  ret等于负EOVERFLOW
337  转到:out4
341  outbuf等于分配内存并置零
343  如果非outbuf
344  ret等于负ENOMEM
345  转到:out4
348  初始化散列表项目
350  req等于kpp_request_alloc() - allocates kpp request*@tfm: KPP tfm handle allocated with crypto_alloc_kpp()*@gfp: allocation flags* Return: allocated handle in case of success or NULL in case of an error.
351  如果非req
352  ret等于负ENOMEM
353  转到:out5
356  kpp_request_set_input() - Sets input buffer* Sets parameters required by generate_public_key*@req: kpp request*@input: ptr to input scatter list*@input_len: size of the input scatter list
357  kpp_request_set_output() - Sets output buffer* Sets parameters required by kpp operation*@req: kpp request*@output: ptr to output scatter list*@output_len: size of the output scatter list
358  init_completion( & completion)
359  kpp_request_set_callback() - Sets an asynchronous callback
367  ret等于rypto_kpp_generate_public_key() - Invoke kpp operation* Function invokes the specific kpp operation for generating the public part* for a given kpp algorithm.* To generate a private key, the caller should use a random number generator.
368  如果ret恒等于负EINPROGRESS
369  wait_for_completion: - waits for completion of a task*@x: holds the state of this particular completion* This waits to be signaled for completion of a specific task. It is NOT* interruptible and there is no timeout.* See also similar routines (i
370  ret等于err
371  如果ret则转到:out6
375  如果kdfcopy
380  如果copy_from_user(outbuf + dst_len, otherinfo, otherinfolen)不等于0则
382  ret等于负EFAULT
383  转到:out6
386  ret等于keyctl_dh_compute_kdf(sdesc, buffer, buflen, outbuf, dst_len + otherinfolen, outlen - dst_len)
389  否则如果copy_to_user(buffer, outbuf, dst_len)恒等于0则
390  ret等于dst_len
391  否则
392  ret等于负EFAULT
395  out6 :
396  kpp_request_free() - zeroize and free kpp request*@req: request to free
397  out5 :
398  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
399  out4 :
400  rypto_free_kpp() - free KPP tfm handle*@tfm: KPP tfm handle allocated with crypto_alloc_kpp()
401  out3 :
402  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
403  out2 :
404  dh_free_data( & dh_inputs)
405  out1 :
406  kdf_dealloc(sdesc)
407  返回:ret
调用者
名称描述
compat_keyctl_dh_computePerform the DH computation or DH based key derivation.* If successful, 0 will be returned.
keyctl_dh_compute