Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public override TPMCommandResponse Process()
        {
            ITPMHandle handle = _params.GetValueOf <ITPMHandle> ("handle");

            TPMBlob requestBlob = new TPMBlob();

            requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_FlushSpecific);
            requestBlob.WriteUInt32(handle.Handle);
            requestBlob.WriteUInt32((uint)handle.ResourceType);

            requestBlob.WriteCmdSize();

            try
            {
                TransmitMe(requestBlob);
            }
            catch (Exception)
            {
                if (!_params.GetValueOf <bool>("ignore_tpm_error", false))
                {
                    throw;
                }
            }

            return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_FlushSpecific, new Parameters()));
        }
Ejemplo n.º 3
0
        public override TPMCommandResponse Process()
        {
            //We don't have any meaningful labeldata we could include,
            //so generate some random
            byte[] labelData = new byte[16];
            Random r         = new Random();

            r.NextBytes(labelData);


            if (_params.IsDefined <ITPMHandle>("handle") == false)
            {
                return(new TPMCommandResponse(false, TPMCommandNames.TPM_CMD_SaveContext, new Parameters()));
            }


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

            TPMBlob requestBlob = new TPMBlob();

            requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_SaveContext);
            requestBlob.WriteUInt32(handle.Handle);
            requestBlob.WriteUInt32((uint)handle.ResourceType);
            requestBlob.Write(labelData, 0, labelData.Length);

            TPMBlob responseBlob = TransmitMe(requestBlob);

            responseBlob.SkipHeader();

            uint blobSize = responseBlob.ReadUInt32();

            byte[] contextBlob = responseBlob.ReadBytes((int)blobSize);

            Parameters responseParams = new Parameters();

            responseParams.AddPrimitiveType("context_blob", contextBlob);
            return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_SaveContext, responseParams));
        }