Home | History | Annotate | Download | only in tpm2
      1 // This file was extracted from the TCG Published
      2 // Trusted Platform Module Library
      3 // Part 3: Commands
      4 // Family "2.0"
      5 // Level 00 Revision 01.16
      6 // October 30, 2014
      7 
      8 #include "InternalRoutines.h"
      9 #include "Unseal_fp.h"
     10 //
     11 //
     12 //     Error Returns                     Meaning
     13 //
     14 //     TPM_RC_ATTRIBUTES                 itemHandle has wrong attributes
     15 //     TPM_RC_TYPE                       itemHandle is not a KEYEDHASH data object
     16 //
     17 TPM_RC
     18 TPM2_Unseal(
     19    Unseal_In         *in,
     20    Unseal_Out        *out
     21    )
     22 {
     23    OBJECT                    *object;
     24 
     25 // Input Validation
     26 
     27    // Get pointer to loaded object
     28    object = ObjectGet(in->itemHandle);
     29 
     30    // Input handle must be a data object
     31    if(object->publicArea.type != TPM_ALG_KEYEDHASH)
     32        return TPM_RC_TYPE + RC_Unseal_itemHandle;
     33    if(   object->publicArea.objectAttributes.decrypt == SET
     34       || object->publicArea.objectAttributes.sign == SET
     35       || object->publicArea.objectAttributes.restricted == SET)
     36        return TPM_RC_ATTRIBUTES + RC_Unseal_itemHandle;
     37 
     38 // Command Output
     39 
     40    // Copy data
     41    MemoryCopy2B(&out->outData.b, &object->sensitive.sensitive.bits.b,
     42                 sizeof(out->outData.t.buffer));
     43 
     44    return TPM_RC_SUCCESS;
     45 }
     46