protected void CheckResponseAuthInfo() { ResponseAuthHandleInfo[] responseAuthHandles = ResponseAuthHandleInfoCore.ReadAuthHandleInfos(this, _responseBlob); if (responseAuthHandles.Length != _currentAuthorizationInfos.Length) { throw new TPMResponseException( string.Format("Expected #{0} auth handles in response, but received #{1}", _currentAuthorizationInfos.Length, responseAuthHandles.Length)); } AuthorizationInfo[] responseAuthInfos = _commandAuthHelper.GenerateResponseAuthData(this); for (int i = 0; i < responseAuthHandles.Length; i++) { if (ByteHelper.CompareByteArrays(responseAuthHandles[i].TpmAuthData, responseAuthInfos[i].AuthData) == false) { throw new TPMResponseException("Received tpm authdata is not valid," + "maybe the response got modified!"); } } for (int i = 0; i < _currentAuthorizationInfos.Length; i++) { ResponseAuthHandleInfo current = responseAuthHandles[i]; if (current.ContinueAuthSession == false) { _commandAuthHelper.DestroyAuthorizationHandle(this, _currentAuthorizationInfos[i].Handle); } else { _currentAuthorizationInfos[i].Handle.UpdateNonceEven(current.NonceEven); } } }
/// <summary> /// Checks all used authorization handles if they should be localy destroyed or not /// </summary> /// <param name="forceRelease">true to force the deletion (on error) /// </param> protected void ReleaseAuthHandles(bool forceRelease, TPMBlob responseBlob) { if (forceRelease) { _commandAuthHelper.DestroyAuthorizationHandles(this); } else { ResponseAuthHandleInfo[] responseAuthHandles = ResponseAuthHandleInfoCore.ReadAuthHandleInfos(this, responseBlob); for (int i = 0; i < responseAuthHandles.Length; i++) { if (responseAuthHandles[i].ContinueAuthSession) { _currentAuthorizationInfos[i].Handle.UpdateNonceEven(responseAuthHandles[i].NonceEven); } else { _commandAuthHelper.RemoveAuthorizationHandle(this, _currentAuthorizationInfos[i].Handle); } } } }