Lines Matching refs:tb
393 static int osap(struct tpm_buf *tb, struct osapsess *s, in osap() argument
404 INIT_BUF(tb); in osap()
405 store16(tb, TPM_TAG_RQU_COMMAND); in osap()
406 store32(tb, TPM_OSAP_SIZE); in osap()
407 store32(tb, TPM_ORD_OSAP); in osap()
408 store16(tb, type); in osap()
409 store32(tb, handle); in osap()
410 storebytes(tb, ononce, TPM_NONCE_SIZE); in osap()
412 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in osap()
416 s->handle = LOAD32(tb->data, TPM_DATA_OFFSET); in osap()
417 memcpy(s->enonce, &(tb->data[TPM_DATA_OFFSET + sizeof(uint32_t)]), in osap()
419 memcpy(enonce, &(tb->data[TPM_DATA_OFFSET + sizeof(uint32_t) + in osap()
428 static int oiap(struct tpm_buf *tb, uint32_t *handle, unsigned char *nonce) in oiap() argument
432 INIT_BUF(tb); in oiap()
433 store16(tb, TPM_TAG_RQU_COMMAND); in oiap()
434 store32(tb, TPM_OIAP_SIZE); in oiap()
435 store32(tb, TPM_ORD_OIAP); in oiap()
436 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in oiap()
440 *handle = LOAD32(tb->data, TPM_DATA_OFFSET); in oiap()
441 memcpy(nonce, &tb->data[TPM_DATA_OFFSET + sizeof(uint32_t)], in oiap()
458 static int tpm_seal(struct tpm_buf *tb, uint16_t keytype, in tpm_seal() argument
483 ret = osap(tb, &sess, keyauth, keytype, keyhandle); in tpm_seal()
529 INIT_BUF(tb); in tpm_seal()
530 store16(tb, TPM_TAG_RQU_AUTH1_COMMAND); in tpm_seal()
531 store32(tb, TPM_SEAL_SIZE + pcrinfosize + datalen); in tpm_seal()
532 store32(tb, TPM_ORD_SEAL); in tpm_seal()
533 store32(tb, keyhandle); in tpm_seal()
534 storebytes(tb, td->encauth, SHA1_DIGEST_SIZE); in tpm_seal()
535 store32(tb, pcrinfosize); in tpm_seal()
536 storebytes(tb, pcrinfo, pcrinfosize); in tpm_seal()
537 store32(tb, datalen); in tpm_seal()
538 storebytes(tb, data, datalen); in tpm_seal()
539 store32(tb, sess.handle); in tpm_seal()
540 storebytes(tb, td->nonceodd, TPM_NONCE_SIZE); in tpm_seal()
541 store8(tb, cont); in tpm_seal()
542 storebytes(tb, td->pubauth, SHA1_DIGEST_SIZE); in tpm_seal()
544 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in tpm_seal()
549 sealinfosize = LOAD32(tb->data, TPM_DATA_OFFSET + sizeof(uint32_t)); in tpm_seal()
550 encdatasize = LOAD32(tb->data, TPM_DATA_OFFSET + sizeof(uint32_t) + in tpm_seal()
556 ret = TSS_checkhmac1(tb->data, ordinal, td->nonceodd, sess.secret, in tpm_seal()
562 memcpy(blob, tb->data + TPM_DATA_OFFSET, storedsize); in tpm_seal()
573 static int tpm_unseal(struct tpm_buf *tb, in tpm_unseal() argument
592 ret = oiap(tb, &authhandle1, enonce1); in tpm_unseal()
597 ret = oiap(tb, &authhandle2, enonce2); in tpm_unseal()
622 INIT_BUF(tb); in tpm_unseal()
623 store16(tb, TPM_TAG_RQU_AUTH2_COMMAND); in tpm_unseal()
624 store32(tb, TPM_UNSEAL_SIZE + bloblen); in tpm_unseal()
625 store32(tb, TPM_ORD_UNSEAL); in tpm_unseal()
626 store32(tb, keyhandle); in tpm_unseal()
627 storebytes(tb, blob, bloblen); in tpm_unseal()
628 store32(tb, authhandle1); in tpm_unseal()
629 storebytes(tb, nonceodd, TPM_NONCE_SIZE); in tpm_unseal()
630 store8(tb, cont); in tpm_unseal()
631 storebytes(tb, authdata1, SHA1_DIGEST_SIZE); in tpm_unseal()
632 store32(tb, authhandle2); in tpm_unseal()
633 storebytes(tb, nonceodd, TPM_NONCE_SIZE); in tpm_unseal()
634 store8(tb, cont); in tpm_unseal()
635 storebytes(tb, authdata2, SHA1_DIGEST_SIZE); in tpm_unseal()
637 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in tpm_unseal()
643 *datalen = LOAD32(tb->data, TPM_DATA_OFFSET); in tpm_unseal()
644 ret = TSS_checkhmac2(tb->data, ordinal, nonceodd, in tpm_unseal()
654 memcpy(data, tb->data + TPM_DATA_OFFSET + sizeof(uint32_t), *datalen); in tpm_unseal()
664 struct tpm_buf *tb; in key_seal() local
667 tb = kzalloc(sizeof *tb, GFP_KERNEL); in key_seal()
668 if (!tb) in key_seal()
674 ret = tpm_seal(tb, o->keytype, o->keyhandle, o->keyauth, in key_seal()
680 kfree(tb); in key_seal()
690 struct tpm_buf *tb; in key_unseal() local
693 tb = kzalloc(sizeof *tb, GFP_KERNEL); in key_unseal()
694 if (!tb) in key_unseal()
697 ret = tpm_unseal(tb, o->keyhandle, o->keyauth, p->blob, p->blob_len, in key_unseal()
705 kfree(tb); in key_unseal()