Exemple #1
0
        public override TPMCommandResponse Process()
        {
            if (_params.IsDefined <ITPMHandle>("handle") == false ||
                _params.IsDefined <byte[]>("context_blob") == false)
            {
                return(new TPMCommandResponse(false, TPMCommandNames.TPM_CMD_LoadContext, new Parameters()));
            }

            ITPMHandle handle = _params.GetValueOf <ITPMHandle>("handle");


            TPMBlob blob = new TPMBlob();

            blob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_LoadContext);
            blob.WriteUInt32(handle.Handle);
            blob.WriteBool(handle.ForceHandle);
            blob.WriteUInt32((uint)handle.ContextBlob.Length);
            blob.Write(handle.ContextBlob, 0, handle.ContextBlob.Length);

            TPMBlob responseBlob = TransmitMe(blob);

            responseBlob.SkipHeader();
            handle.Handle = responseBlob.ReadUInt32();

            Parameters responseParameters = new Parameters();

            responseParameters.AddValue("handle", handle);

            return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_LoadContext, responseParameters));
        }
 public void WriteAuthorizationInfo(TPMBlob target, AuthorizationInfo authInfo)
 {
     target.WriteUInt32(authInfo.Handle.Handle);
     target.Write(authInfo.Handle.NonceOdd, 0, authInfo.Handle.NonceOdd.Length);
     target.WriteBool(authInfo.ContinueAuthSession);
     target.Write(authInfo.AuthData, 0, authInfo.AuthData.Length);
 }