| Function report | 
| Source Code: security\keys\trusted-keys\trusted_tpm1.c | Create Date:2022-07-28 18:30:40 | 
| Last Modify:2020-03-12 14:18:49 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:Have the TPM seal(encrypt) the trusted key, possibly based on* Platform Configuration Registers (PCRs). AUTH1 for sealing key.
Proto:static int tpm_seal(struct tpm_buf *tb, uint16_t keytype, uint32_t keyhandle, const unsigned char *keyauth, const unsigned char *data, uint32_t datalen, unsigned char *blob, uint32_t *bloblen, const unsigned char *blobauth, const unsigned char *pcrinfo, uint32_t pcrinfosize)
Type:int
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| struct tpm_buf * | tb | |
| uint16_t | keytype | |
| uint32_t | keyhandle | |
| const unsigned char * | keyauth | |
| const unsigned char * | data | |
| uint32_t | datalen | |
| unsigned char * | blob | |
| uint32_t * | bloblen | |
| const unsigned char * | blobauth | |
| const unsigned char * | pcrinfo | |
| uint32_t | pcrinfosize | 
| 481 | td = Allocation memory | 
| 492 | memcpy(xorwork, secret, SHA1_DIGEST_SIZE) | 
| 493 | memcpy(xorwork + SHA1_DIGEST_SIZE, enonce, SHA1_DIGEST_SIZE) | 
| 494 | ret = TSS_sha1(xorwork, SHA1_DIGEST_SIZE * 2, xorhash) | 
| 498 | ret = tpm_get_random(chip, nonceodd, TPM_NONCE_SIZE) | 
| 499 | If ret != TPM_NONCE_SIZE Then Go to out | 
| 501 | ordinal = htonl(TPM_ORD_SEAL) | 
| 503 | pcrsize = htonl(pcrinfosize) | 
| 504 | cont = 0 | 
| 511 | If pcrinfosize == 0 Then | 
| 519 | Else | 
| 533 | tpm_buf_append_u32(tb, keyhandle) | 
| 534 | tpm_buf_append(tb, encauth, SHA1_DIGEST_SIZE) | 
| 535 | tpm_buf_append_u32(tb, pcrinfosize) | 
| 536 | tpm_buf_append(tb, pcrinfo, pcrinfosize) | 
| 537 | tpm_buf_append_u32(tb, datalen) | 
| 538 | tpm_buf_append(tb, data, datalen) | 
| 539 | tpm_buf_append_u32(tb, handle) | 
| 540 | tpm_buf_append(tb, nonceodd, TPM_NONCE_SIZE) | 
| 541 | tpm_buf_append_u8(tb, cont) | 
| 542 | tpm_buf_append(tb, pubauth, SHA1_DIGEST_SIZE) | 
| 544 | ret = For key specific tpm requests, we will generate and send our* own TPM command packets using the drivers send function. | 
| 549 | sealinfosize = LOAD32(data, TPM_DATA_OFFSET + sizeof(uint32_t)) | 
| 550 | encdatasize = LOAD32(data, TPM_DATA_OFFSET + sizeof(uint32_t) + sizeof(uint32_t) + sealinfosize) | 
| 552 | storedsize = sizeof(uint32_t) + sizeof(uint32_t) + sealinfosize + sizeof(uint32_t) + encdatasize | 
| 561 | If Not ret Then | 
| 562 | memcpy(blob, data + TPM_DATA_OFFSET, storedsize) | 
| 563 | bloblen = storedsize | 
| 565 | out : | 
| 567 | Return ret | 
| Name | Describe | 
|---|---|
| key_seal | Have the TPM seal(encrypt) the symmetric key | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |