| 1 |
/* Microsoft Reference Implementation for TPM 2.0 |
| 2 |
* |
| 3 |
* The copyright in this software is being made available under the BSD License, |
| 4 |
* included below. This software may be subject to other third party and |
| 5 |
* contributor rights, including patent rights, and no such rights are granted |
| 6 |
* under this license. |
| 7 |
* |
| 8 |
* Copyright (c) Microsoft Corporation |
| 9 |
* |
| 10 |
* All rights reserved. |
| 11 |
* |
| 12 |
* BSD License |
| 13 |
* |
| 14 |
* Redistribution and use in source and binary forms, with or without modification, |
| 15 |
* are permitted provided that the following conditions are met: |
| 16 |
* |
| 17 |
* Redistributions of source code must retain the above copyright notice, this list |
| 18 |
* of conditions and the following disclaimer. |
| 19 |
* |
| 20 |
* Redistributions in binary form must reproduce the above copyright notice, this |
| 21 |
* list of conditions and the following disclaimer in the documentation and/or |
| 22 |
* other materials provided with the distribution. |
| 23 |
* |
| 24 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" |
| 25 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 27 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 28 |
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 29 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 30 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 31 |
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 32 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 |
*/ |
| 35 |
#include "Tpm.h" |
| 36 |
#include "ChangeEPS_fp.h" |
| 37 |
|
| 38 |
#if CC_ChangeEPS // Conditional expansion of this file |
| 39 |
|
| 40 |
/*(See part 3 specification) |
| 41 |
// Reset current EPS value |
| 42 |
*/ |
| 43 |
TPM_RC |
| 44 |
TPM2_ChangeEPS( |
| 45 |
ChangeEPS_In *in // IN: input parameter list |
| 46 |
) |
| 47 |
{ |
| 48 |
// The command needs NV update. Check if NV is available. |
| 49 |
// A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at |
| 50 |
// this point |
| 51 |
RETURN_IF_NV_IS_NOT_AVAILABLE; |
| 52 |
|
| 53 |
// Input parameter is not reference in command action |
| 54 |
NOT_REFERENCED(in); |
| 55 |
|
| 56 |
// Internal Data Update |
| 57 |
|
| 58 |
// Reset endorsement hierarchy seed from RNG |
| 59 |
CryptRandomGenerate(sizeof(gp.EPSeed.t.buffer), gp.EPSeed.t.buffer); |
| 60 |
|
| 61 |
// Create new ehProof value from RNG |
| 62 |
CryptRandomGenerate(sizeof(gp.ehProof.t.buffer), gp.ehProof.t.buffer); |
| 63 |
|
| 64 |
// Enable endorsement hierarchy |
| 65 |
gc.ehEnable = TRUE; |
| 66 |
|
| 67 |
// set authValue buffer to zeros |
| 68 |
MemorySet(gp.endorsementAuth.t.buffer, 0, gp.endorsementAuth.t.size); |
| 69 |
// Set endorsement authValue to null |
| 70 |
gp.endorsementAuth.t.size = 0; |
| 71 |
|
| 72 |
// Set endorsement authPolicy to null |
| 73 |
gp.endorsementAlg = TPM_ALG_NULL; |
| 74 |
gp.endorsementPolicy.t.size = 0; |
| 75 |
|
| 76 |
// Flush loaded object in endorsement hierarchy |
| 77 |
ObjectFlushHierarchy(TPM_RH_ENDORSEMENT); |
| 78 |
|
| 79 |
// Flush evict object of endorsement hierarchy stored in NV |
| 80 |
NvFlushHierarchy(TPM_RH_ENDORSEMENT); |
| 81 |
|
| 82 |
// Save hierarchy changes to NV |
| 83 |
NV_SYNC_PERSISTENT(EPSeed); |
| 84 |
NV_SYNC_PERSISTENT(ehProof); |
| 85 |
NV_SYNC_PERSISTENT(endorsementAuth); |
| 86 |
NV_SYNC_PERSISTENT(endorsementAlg); |
| 87 |
NV_SYNC_PERSISTENT(endorsementPolicy); |
| 88 |
|
| 89 |
// orderly state should be cleared because of the update to state clear data |
| 90 |
g_clearOrderly = TRUE; |
| 91 |
|
| 92 |
return TPM_RC_SUCCESS; |
| 93 |
} |
| 94 |
|
| 95 |
#endif // CC_ChangeEPS |