函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:rusted_instantiate - create a new trusted key* Unseal an existing trusted blob or, for a new key, get a* random key, then seal and create a trusted key-type key,* adding it to the specified keyring.* On success, return 0. Otherwise return errno.

函数原型:static int trusted_instantiate(struct key *key, struct key_preparsed_payload *prep)

返回类型:int

参数:

类型参数名称
struct key *key
struct key_preparsed_payload *prep
955  struct trusted_key_payload * payload = NULL
956  struct trusted_key_options * options = NULL
957  datalen等于Raw datalen
959  ret等于0
964  tpm2等于tpm_is_tpm2(chip)
965  如果tpm2小于0则返回:tpm2
968  如果datalen小于等于0或datalen大于32767或非Raw data 则返回:负EINVAL
971  datablob等于开辟内存
972  如果非datablob则返回:负ENOMEM
974  memcpy(datablob, Raw data , datalen)
975  datablob[datalen]等于'\0'
977  options等于trusted_options_alloc()
978  如果非options
979  ret等于负ENOMEM
980  转到:out
982  payload等于trusted_payload_alloc(key)
983  如果非payload
984  ret等于负ENOMEM
985  转到:out
988  key_cmd等于datablob_parse - parse the keyctl data and fill in the* payload and options structures* On success returns 0, otherwise -EINVAL.
989  如果key_cmd小于0则
990  ret等于key_cmd
991  转到:out
994  如果非keyhandle
995  ret等于负EINVAL
996  转到:out
999  dump_payload(payload)
1000  dump_options(options)
1003  :key_cmd恒等于Opt_load
1004  如果tpm2ret等于tpm2_unseal_trusted(chip, payload, options)
1006  否则ret等于Have the TPM unseal(decrypt) the symmetric key
1008  dump_payload(payload)
1009  dump_options(options)
1010  如果ret小于0则打印信息("trusted_key: key_unseal failed (%d)\n", ret)
1012  退出
1013  :key_cmd恒等于Opt_new
1014  key_len等于key_len
1015  ret等于tpm_get_random(chip, key, key_len)
1016  如果ret不等于key_len
1017  打印信息("trusted_key: key_create failed (%d)\n", ret)
1018  转到:out
1020  如果tpm2ret等于pm2_seal_trusted() - seal the payload of a trusted key*@chip: TPM chip to use*@payload: the key data in clear and encrypted form*@options: authentication values and other options* Return: < 0 on error and 0 on success.
1022  否则ret等于Have the TPM seal(encrypt) the symmetric key
1024  如果ret小于0则打印信息("trusted_key: key_seal failed (%d)\n", ret)
1026  退出
1027  默认
1028  ret等于负EINVAL
1029  转到:out
1031  如果非retpcrlockret等于Lock a trusted key, by extending a selected PCR.* Prevents a trusted key that is sealed to PCRs from being accessed.* This uses the tpm driver's extend function.
1033  out :
1034  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
1035  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
1036  如果非retrcu_assign_keypointer(key, payload)
1038  否则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
1040  返回:ret