示例#1
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _keyLength = blob.ReadUInt32 ();
            _numPrimes = blob.ReadUInt32 ();

            uint expoSize = blob.ReadUInt32 ();
            _exponent = new byte[expoSize];
            blob.Read (_exponent, 0, (int)expoSize);
        }
示例#2
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _versionStruct = CapabilityDataCore.TPMVersionCore.CreateFromTPMBlob(blob);

            _sealInfo = new byte[blob.ReadUInt32()];
            blob.Read(_sealInfo, 0, _sealInfo.Length);

            _encData = new byte[blob.ReadUInt32()];
            blob.Read(_encData, 0, _encData.Length);
        }
示例#3
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);
        }
示例#4
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            UInt16 handleCount = blob.ReadUInt16 ();

            for (int i = 0; i < handleCount; i++)
                _handles.Add (blob.ReadUInt32());
        }
示例#5
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _pcrSelection = TPMPCRSelectionCore.CreateFromTPMBlob(blob);

            uint valueSize = blob.ReadUInt32();
            _pcrValues = new byte[valueSize/20][];

            for(int i = 0; i<valueSize/20; i++)
                _pcrValues[i] = blob.ReadBytes(20);
        }
示例#6
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");
            }
        }
示例#7
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _authHandle = blob.ReadUInt32();

            _nonceEven = new byte[20];
            blob.Read(_nonceEven, 0, _nonceEven.Length);

            if(_authType == AuthHandle.AuthType.OSAP)
            {
                _nonceEvenOSAP = new byte[20];
                blob.Read(_nonceEvenOSAP, 0, _nonceEvenOSAP.Length);
            }
        }
示例#8
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);
            }
示例#9
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;
        }
示例#10
0
 public void ReadFromTpmBlob(TPMBlob blob)
 {
     _structureTag = (TPMStructureTag)blob.ReadUInt16();
     _label = blob.ReadBytes(4);
     _counterValue = blob.ReadUInt32();
 }
示例#11
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);
        }
示例#12
0
        private uint ReadUInt32Response(TPMBlob response)
        {
            uint responseSize = response.ReadUInt32 ();
            if (responseSize != 4)
                throw new TPMResponseException (string.Format ("Capability response size mismatch (should be 4, and is {0})", responseSize));

            return response.ReadUInt32 ();
        }
示例#13
0
 public void ReadFromTpmBlob(TPMBlob blob)
 {
     uint keyLength = blob.ReadUInt32 ();
     _pubkey = blob.ReadBytes ((int)keyLength);
 }