20 TPMI_DH_OBJECT TpmKey;
26 TPMI_ALG_HASH AuthHash;
31 TPMI_SH_AUTH_SESSION SessionHandle;
57 IN TPMI_DH_OBJECT TpmKey,
58 IN TPMI_DH_ENTITY Bind,
61 IN TPM_SE SessionType,
63 IN TPMI_ALG_HASH AuthHash,
64 OUT TPMI_SH_AUTH_SESSION *SessionHandle,
71 UINT32 SendBufferSize;
72 UINT32 RecvBufferSize;
78 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_NO_SESSIONS);
79 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_StartAuthSession);
83 Buffer = (UINT8 *)&SendBuffer.NonceCaller;
86 Buffer +=
sizeof (UINT16);
87 CopyMem (Buffer, NonceCaller->buffer, NonceCaller->size);
88 Buffer += NonceCaller->size;
91 Buffer +=
sizeof (UINT16);
92 CopyMem (Buffer, Salt->secret, Salt->size);
95 *(TPM_SE *)Buffer = SessionType;
99 Buffer +=
sizeof (UINT16);
100 switch (Symmetric->algorithm) {
105 Buffer +=
sizeof (UINT16);
107 Buffer +=
sizeof (UINT16);
111 Buffer +=
sizeof (UINT16);
113 Buffer +=
sizeof (UINT16);
115 case TPM_ALG_SYMCIPHER:
117 Buffer +=
sizeof (UINT16);
119 Buffer +=
sizeof (UINT16);
123 Buffer +=
sizeof (UINT16);
127 DEBUG ((DEBUG_ERROR,
"Tpm2StartAuthSession - Symmetric->algorithm - %x\n", Symmetric->algorithm));
128 return EFI_UNSUPPORTED;
132 Buffer +=
sizeof (UINT16);
134 SendBufferSize = (UINT32)((
UINTN)Buffer - (
UINTN)&SendBuffer);
135 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
140 RecvBufferSize =
sizeof (RecvBuffer);
141 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
142 if (EFI_ERROR (Status)) {
147 DEBUG ((DEBUG_ERROR,
"Tpm2StartAuthSession - RecvBufferSize Error - %x\n", RecvBufferSize));
148 return EFI_DEVICE_ERROR;
151 if (
SwapBytes32 (RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
152 DEBUG ((DEBUG_ERROR,
"Tpm2StartAuthSession - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
153 return EFI_DEVICE_ERROR;
159 *SessionHandle =
SwapBytes32 (RecvBuffer.SessionHandle);
160 NonceTPM->size =
SwapBytes16 (RecvBuffer.NonceTPM.size);
161 if (NonceTPM->size > sizeof (
TPMU_HA)) {
162 DEBUG ((DEBUG_ERROR,
"Tpm2StartAuthSession - NonceTPM->size error %x\n", NonceTPM->size));
163 return EFI_DEVICE_ERROR;
166 CopyMem (NonceTPM->buffer, &RecvBuffer.NonceTPM.buffer, NonceTPM->size);
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define DEBUG(Expression)
#define TPM_ALG_XOR
XOR using the rolling nonces.
EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
EFI_STATUS EFIAPI Tpm2StartAuthSession(IN TPMI_DH_OBJECT TpmKey, IN TPMI_DH_ENTITY Bind, IN TPM2B_NONCE *NonceCaller, IN TPM2B_ENCRYPTED_SECRET *Salt, IN TPM_SE SessionType, IN TPMT_SYM_DEF *Symmetric, IN TPMI_ALG_HASH AuthHash, OUT TPMI_SH_AUTH_SESSION *SessionHandle, OUT TPM2B_NONCE *NonceTPM)