Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name: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.

Proto:int tpm2_seal_trusted(struct tpm_chip *chip, struct trusted_key_payload *payload, struct trusted_key_options *options)

Type:int

Parameter:

TypeParameterName
struct tpm_chip *chip
struct trusted_key_payload *payload
struct trusted_key_options *options
72  When i < ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(tpm2_hash_map) cycle
73  If hash == crypto_id Then
74  hash = tpm_id
75  Break
79  If i == ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(tpm2_hash_map) Then Return -EINVAL
82  rc = tpm_buf_init( & buf, TPM2_ST_SESSIONS, TPM2_CC_CREATE)
83  If rc Then Return rc
86  tpm_buf_append_u32( & buf, keyhandle)
87  pm_buf_append_auth() - append TPMS_AUTH_COMMAND to the buffer
94  tpm_buf_append_u16( & buf, 4 + Max TPM v1.2 PCR size + key_len + 1)
96  tpm_buf_append_u16( & buf, Max TPM v1.2 PCR size )
97  tpm_buf_append( & buf, blobauth, Max TPM v1.2 PCR size )
98  tpm_buf_append_u16( & buf, key_len + 1)
99  tpm_buf_append( & buf, key, key_len)
100  tpm_buf_append_u8( & buf, migratable)
103  tpm_buf_append_u16( & buf, 14 + policydigest_len)
104  tpm_buf_append_u16( & buf, TPM_ALG_KEYEDHASH)
105  tpm_buf_append_u16( & buf, hash)
108  If policydigest_len Then
109  tpm_buf_append_u32( & buf, 0)
110  tpm_buf_append_u16( & buf, policydigest_len)
111  tpm_buf_append( & buf, policydigest, policydigest_len)
113  Else
114  tpm_buf_append_u32( & buf, TPM2_OA_USER_WITH_AUTH)
115  tpm_buf_append_u16( & buf, 0)
119  tpm_buf_append_u16( & buf, TPM_ALG_NULL)
120  tpm_buf_append_u16( & buf, 0)
123  tpm_buf_append_u16( & buf, 0)
126  tpm_buf_append_u32( & buf, 0)
128  If flags & TPM_BUF_OVERFLOW Then
129  rc = -E2BIG
130  Go to out
133  rc = tpm_send(chip, data, tpm_buf_length( & buf))
134  If rc Then Go to out
137  blob_len = be32_to_cpup((__be32 * ) & data[TPM_HEADER_SIZE])
138  If blob_len > MAX_BLOB_SIZE Then
139  rc = -E2BIG
140  Go to out
142  If tpm_buf_length( & buf) < TPM_HEADER_SIZE + 4 + blob_len Then
143  rc = -EFAULT
144  Go to out
147  memcpy(blob, & data[TPM_HEADER_SIZE + 4], blob_len)
148  blob_len = blob_len
150  out :
151  tpm_buf_destroy( & buf)
153  If rc > 0 Then
154  If tpm2_rc_value(rc) == RC_FMT1 Then rc = -EINVAL
156  Else rc = -EPERM
160  Return rc
Caller
NameDescribe
trusted_instantiaterusted_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.