示例#1
0
            public void ReadFromTpmBlob(TPMBlob blob)
            {
                /*uint responseSize = */blob.ReadUInt32 ();

                this._tag = blob.ReadUInt16 ();
                this._version = new TPMVersionCore (blob);
                this._specLevel = blob.ReadUInt16 ();
                this._errataRev = blob.ReadByte ();
                this._tpmVendorId = new byte[4];
                blob.Read (_tpmVendorId, 0, _tpmVendorId.Length);

                ushort vendorSize = blob.ReadUInt16 ();
                _vendorSpecific = blob.ReadBytes (vendorSize);
            }
示例#2
0
 public void ReadFromTpmBlob(TPMBlob blob)
 {
     uint size = blob.ReadUInt16();
     byte[] selectionBits = new byte[size];
     blob.Read(selectionBits, 0, (int)size);
     _pcrSelection = new BitMap(selectionBits);
 }
示例#3
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            UInt16 handleCount = blob.ReadUInt16 ();

            for (int i = 0; i < handleCount; i++)
                _handles.Add (blob.ReadUInt32());
        }
示例#4
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _algorithmId = (TPMAlgorithmId)blob.ReadUInt32 ();
            _encScheme = (TPMEncScheme)blob.ReadUInt16 ();
            _sigScheme = (TPMSigScheme)blob.ReadUInt16 ();

            UInt32 paramsSize = blob.ReadUInt32 ();
            byte[] paramsData = new byte[paramsSize];

            blob.Read (paramsData, 0, paramsData.Length);

            using (TPMBlob paramSrc = new TPMBlob (paramsData))
            {
                if (_algorithmId == TPMAlgorithmId.TPM_ALG_RSA)
                    _params = TPMRSAKeyParamsCore.CreateFromTPMBlob(paramSrc);
                else if (_algorithmId == TPMAlgorithmId.TPM_ALG_AES128 ||
                    _algorithmId == TPMAlgorithmId.TPM_ALG_AES192 ||
                    _algorithmId == TPMAlgorithmId.TPM_ALG_AES256)
                    //TODO
                    throw new NotImplementedException ("Symmetric key params not implemented");
            }
        }
示例#5
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _tag = (TPMStructureTag)blob.ReadUInt16();
            _resourceType = (TPMResourceType)blob.ReadUInt32();
            _handle = blob.ReadUInt32();
            _label = blob.ReadBytes(16);
            _contextCount = blob.ReadUInt32();
            _integrityDigest = blob.ReadBytes(20);

            uint additionalSize =  blob.ReadUInt32();
            _additionalData = blob.ReadBytes((int)additionalSize);

            uint sensitiveSize = blob.ReadUInt32();
            _sensitiveData = blob.ReadBytes((int)sensitiveSize);
        }
示例#6
0
        /// <summary>
        /// Transmit and check the given TPM blob.
        /// </summary>
        /// <param name="blob"></param>
        /// <returns></returns>
        public TPMBlob TransmitAndCheck(TPMBlob blob, bool writeSize)
        {
            ushort expected_rsp_tag;

            // Determine the expected RSP tag
            blob.Position = 0;
            switch (blob.ReadUInt16())
            {
                case TPMCmdTags.TPM_TAG_RQU_COMMAND:
                    expected_rsp_tag = TPMCmdTags.TPM_TAG_RSP_COMMAND;
                    break;

                case TPMCmdTags.TPM_TAG_RQU_AUTH1_COMMAND:
                    expected_rsp_tag = TPMCmdTags.TPM_TAG_RSP_AUTH1_COMMAND;
                    break;

                case TPMCmdTags.TPM_TAG_RQU_AUTH2_COMMAND:
                    expected_rsp_tag = TPMCmdTags.TPM_TAG_RSP_AUTH2_COMMAND;
                    break;

                default:
                throw new Exception();
                    //throw new TpmCommandException("Unsupported TPM request tag", blob);
            }

            // Do the actual transaction
            TPMBlob rsp = Transmit(blob, writeSize);

            // Check the response
            CheckTpmReponse(rsp, expected_rsp_tag);

            return rsp;
        }
示例#7
0
        /// <summary>
        /// Check a TPM reply blob
        /// </summary>
        /// <param name="reply">The tag type of this blob</param>
        public UInt16 CheckTpmReponse(TPMBlob reply)
        {
            if (reply.Length < 10)
                throw new Exception();
                //throw new TpmCommandException("Short TPM response", reply);

            // Start from position zero
            reply.Position = 0;

            // Check the reply tag
            ushort replyTag = reply.ReadUInt16();
            if (replyTag != TPMCmdTags.TPM_TAG_RSP_COMMAND &&
                replyTag != TPMCmdTags.TPM_TAG_RSP_AUTH1_COMMAND &&
                replyTag != TPMCmdTags.TPM_TAG_RSP_AUTH2_COMMAND)
            {
                throw new Exception();
                //throw new TpmCommandException("Invalid TPM response tag", reply);
            }

            // Check the parameter size
            uint paramSize = reply.ReadUInt32();
            if ((int)paramSize != reply.Length)
            {
                throw new Exception();
                //throw new TpmCommandException("Bad TPM response paramSize", reply);
            }

            // Finally check the TPM result
            uint tpmResult = reply.ReadUInt32();
            if (tpmResult != 0)
            {
                throw new TPMResponseException((Int64)tpmResult, TPMErrorCodeToMessage(tpmResult), reply);
            }

            return replyTag;
        }
示例#8
0
 public void ReadFromTpmBlob(TPMBlob blob)
 {
     _structureTag = (TPMStructureTag)blob.ReadUInt16();
     _label = blob.ReadBytes(4);
     _counterValue = blob.ReadUInt32();
 }
示例#9
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _version = CapabilityDataCore.TPMVersionCore.CreateFromTPMBlob (blob);
            _keyUsage = (TPMKeyUsage)blob.ReadUInt16 ();
            _keyFlags = (TPMKeyFlags)blob.ReadUInt32 ();
            _authDataUsage = (TPMAuthDataUsage)blob.ReadByte ();
            _algorithmParams = TPMKeyParamsCore.CreateFromTPMBlob (blob);

            uint pcrInfoSize = blob.ReadUInt32 ();
            /*byte[] pcrInfo =*/ blob.ReadBytes ((int)pcrInfoSize);

            _pubKey = TPMStorePubkeyCore.CreateFromTpmBlob (blob);

            uint encDataSize = blob.ReadUInt32 ();
            _encData = blob.ReadBytes ((int)encDataSize);
        }