aboutsummaryrefslogtreecommitdiff
path: root/Unseal.c
blob: 8318e461b6bdf29ae811b4f8aaf39ace3508ec8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This file was extracted from the TCG Published
// Trusted Platform Module Library
// Part 3: Commands
// Family "2.0"
// Level 00 Revision 01.16
// October 30, 2014

#include "InternalRoutines.h"
#include "Unseal_fp.h"
//
//
//     Error Returns                     Meaning
//
//     TPM_RC_ATTRIBUTES                 itemHandle has wrong attributes
//     TPM_RC_TYPE                       itemHandle is not a KEYEDHASH data object
//
TPM_RC
TPM2_Unseal(
   Unseal_In         *in,
   Unseal_Out        *out
   )
{
   OBJECT                    *object;

// Input Validation

   // Get pointer to loaded object
   object = ObjectGet(in->itemHandle);

   // Input handle must be a data object
   if(object->publicArea.type != TPM_ALG_KEYEDHASH)
       return TPM_RC_TYPE + RC_Unseal_itemHandle;
   if(   object->publicArea.objectAttributes.decrypt == SET
      || object->publicArea.objectAttributes.sign == SET
      || object->publicArea.objectAttributes.restricted == SET)
       return TPM_RC_ATTRIBUTES + RC_Unseal_itemHandle;

// Command Output

   // Copy data
   MemoryCopy2B(&out->outData.b, &object->sensitive.sensitive.bits.b,
                sizeof(out->outData.t.buffer));

   return TPM_RC_SUCCESS;
}