当前位置: 首页>>代码示例>>C#>>正文


C# Parameters.AddPrimitiveType方法代码示例

本文整理汇总了C#中Parameters.AddPrimitiveType方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.AddPrimitiveType方法的具体用法?C# Parameters.AddPrimitiveType怎么用?C# Parameters.AddPrimitiveType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parameters的用法示例。


在下文中一共展示了Parameters.AddPrimitiveType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMaxKeys

        /// <summary>
        /// The maximum number of keys the tpm can load at once
        /// </summary>
        /// <returns></returns>
        public uint GetMaxKeys()
        {
            Parameters parameters = new Parameters ();
            parameters.AddPrimitiveType ("capArea", CapabilityData.TPMCapabilityArea.TPM_CAP_PROPERTY);
            parameters.AddPrimitiveType ("subCap", CapabilityData.TPMSubCapProperty.TPM_CAP_PROP_MAX_KEYS);

            return this.BuildDoVerifyRequest (TPMCommandNames.TPM_CMD_GetCapability, parameters).Parameters.GetValueOf<uint> (CapabilityData.PARAM_PROP_MAX_KEYS);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:12,代码来源:TPMCapabilityClient.cs

示例2: Extend

        /// <summary>
        /// Extends the specified pcr by the specified digest
        /// </summary>
        /// <param name="pcrIndex">The pcr to be extended</param>
        /// <param name="digest"></param>
        /// <returns>Returns the new value of the extended pcr</returns>
        public byte[] Extend(uint pcrIndex, byte[] digest)
        {
            Parameters extendParameters = new Parameters();
            extendParameters.AddPrimitiveType("pcr", pcrIndex);
            extendParameters.AddPrimitiveType("digest", digest);

            return BuildDoVerifyRequest(TPMCommandNames.TPM_CMD_Extend, extendParameters)
                .Parameters.GetValueOf<byte[]>("pcr_value");
        }
开发者ID:deveck,项目名称:doTSS,代码行数:15,代码来源:TPMIntegrityClient.cs

示例3: Process

        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);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:29,代码来源:TPM_SaveContext.cs

示例4: PCRValue

        /// <summary>
        /// Retrieves the index of the specified pcr 
        /// </summary>
        /// <param name="pcrIndex"></param>
        /// <returns></returns>
        public byte[] PCRValue(uint pcrIndex)
        {
            Parameters pcrParams = new Parameters();
            pcrParams.AddPrimitiveType("pcrnum", pcrIndex);

            return BuildDoVerifyRequest(TPMCommandNames.TPM_CMD_PCRRead, pcrParams).Parameters.GetValueOf<byte[]>("value");
        }
开发者ID:deveck,项目名称:doTSS,代码行数:12,代码来源:TPMIntegrityClient.cs

示例5: Process

        public override TPMCommandResponse Process()
        {
            TPMBlob requestBlob = new TPMBlob ();
            requestBlob.WriteCmdHeader (TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_PcrRead);
            requestBlob.WriteUInt32 ((uint)_register);
            requestBlob.WriteCmdSize ();

            TPMBlob responseBlob = TransmitMe (requestBlob);
            Parameters responseParam = new Parameters();

            byte[] val = responseBlob.ReadBytes(20);

            responseParam.AddPrimitiveType("pcrnum", _register);
            responseParam.AddPrimitiveType("value", val);

            TPMCommandResponse response = new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_PCRRead, responseParam);

            return response;
        }
开发者ID:deveck,项目名称:doTSS,代码行数:19,代码来源:TPM_PCRRead.cs

示例6: CreateCounter

        /// <summary>
        /// Creates a new counter if possible.
        /// Creating a counter requires the owner password and also the secret_counter secret
        /// </summary>
        /// <param name="label">4 bytes to label the counter</param>
        /// <returns></returns>
        public CounterContext CreateCounter(byte[] label)
        {
            if(label.Length != 4)
                throw new ArgumentException("label needs to be of size 4");

            ProtectedPasswordStorage counterSecret = _tpmSession.RequestSecret(new HMACKeyInfo(HMACKeyInfo.HMACKeyType.CounterSecret, new Parameters()));

            if(counterSecret.Hashed == false)
                counterSecret.Hash();

            counterSecret.DecryptHash();

            Parameters createCounterParams = new Parameters();
            createCounterParams.AddPrimitiveType("secret", counterSecret.HashValue);
            createCounterParams.AddPrimitiveType("label", label);

            return new CounterContext(_tpmSession,
                _tpmSession.DoTPMCommandRequest(new TPMCommandRequest(TPMCommandNames.TPM_CMD_CreateCounter, createCounterParams))
                    .Parameters.GetValueOf<uint>("counter_id")
                );
        }
开发者ID:deveck,项目名称:doTSS,代码行数:27,代码来源:CounterClient.cs

示例7: Process

        public override TPMCommandResponse Process()
        {
            using(TPMBlob requestBlob = new TPMBlob())
            {
                requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_GetRandom);
                requestBlob.WriteUInt32(_params.GetValueOf<uint>("bytes_requested"));
                _responseBlob = TransmitMe(requestBlob);
            }

            _responseBlob.SkipHeader();
            uint responseByteSize = _responseBlob.ReadUInt32();
            _responseParameters = new Parameters();
            _responseParameters.AddPrimitiveType("data", _responseBlob.ReadBytes((int)responseByteSize));

            return new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_GetRandom, _responseParameters);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:16,代码来源:TPM_GetRandom.cs

示例8: Process

        public override TPMCommandResponse Process()
        {
            using(TPMBlob requestBlob = new TPMBlob())
            {
                requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_ReadCounter);
                requestBlob.WriteUInt32(_params.GetValueOf<uint>("counter_id"));

                _responseBlob = TransmitMe(requestBlob);
            }

            _responseBlob.SkipHeader();
            _responseParameters = new Parameters();
            _responseParameters.AddPrimitiveType("counter_id", _params.GetValueOf<uint>("counter_id"));
            _responseParameters.AddValue("counter_value", TPMCounterValueCore.CreateFromTPMBlob(_responseBlob));

            return new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_ReadCounter, _responseParameters);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:17,代码来源:TPM_ReadCounter.cs

示例9: Process

        public override TPMCommandResponse Process()
        {
            if(_params.GetValueOf<string>("type", "") == "request_prefix")
            {

                TPMBoundDataCore boundData = TPMBoundDataCore.Encapsulate(new byte[0]);

                _responseParameters = new Parameters();
                using(TPMBlob blob = new TPMBlob())
                {
                    boundData.WriteToTpmBlob(blob);
                    _responseParameters.AddPrimitiveType("prefix", blob.ToArray());
                }

                return new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_Bind, _responseParameters);
            }
            else
                throw new ArgumentException("TPM_Bind: did not find valid type");
        }
开发者ID:deveck,项目名称:doTSS,代码行数:19,代码来源:TPM_Bind.cs

示例10: Process

        public override TPMCommandResponse Process()
        {
            using(TPMBlob requestBlob = new TPMBlob())
            {
                requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_Extend);
                requestBlob.WriteUInt32(_params.GetValueOf<uint>("pcr"));

                byte[] digest = _params.GetValueOf<byte[]>("digest");
                if(digest.Length != 20)
                    throw new ArgumentException("Digest needs to be of length '20'");

                requestBlob.Write(digest, 0, digest.Length);

                _responseBlob = TransmitMe(requestBlob);
            }

            _responseBlob.SkipHeader();
            _responseParameters = new Parameters();
            _responseParameters.AddPrimitiveType("pcr_value", _responseBlob.ReadBytes(20));
            return new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_Extend, _responseParameters);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:21,代码来源:TPM_Extend.cs

示例11: Sample

        protected override double Sample()
        {
            Parameters getRandomParameters = new Parameters();
            getRandomParameters.AddPrimitiveType("bytes_requested", (uint)4);
            byte[] randomBytes = _tpmSession.DoTPMCommandRequest(new TPMCommandRequest(TPMCommandNames.TPM_CMD_GetRandom, getRandomParameters))
                .Parameters.GetValueOf<byte[]>("data");

            byte[] realData;
            if(randomBytes.Length <4)
            {
                Console.WriteLine("Requested 4 received {0}", randomBytes.Length);
                realData = new byte[4];
                Array.Copy(randomBytes, 0, realData, 0, randomBytes.Length);
            }
            else
                realData = randomBytes;

            UInt32 randomVal = BitConverter.ToUInt32(realData, 0);

            return (double)randomVal/(double)UInt32.MaxValue;
        }
开发者ID:deveck,项目名称:doTSS,代码行数:21,代码来源:RNG.cs

示例12: InternalProcess

        protected override TPMCommandResponse InternalProcess()
        {
            // Unencrypted authorization values, they need to be XOR-Encrypted with
            // XOR(auth, SHA-1(OSAP shared secret | session nonce))
            //
            // OSAP_shared_secret = HMAC(key=usage secret of key handle, nonce even osap | nonce odd osap)
            AuthHandle auth1OSAP = _commandAuthHelper.AssureOSAPSharedSecret(this, AuthSessionNum.Auth1);

            _usageAuth = _params.GetValueOf<byte[]> ("usage_auth");
            _migrationAuth = _params.GetValueOf<byte[]> ("migration_auth");
            byte[] xorKey = new HashProvider().Hash(
                    new HashByteDataProvider(auth1OSAP.SharedSecret),
                    new HashByteDataProvider(auth1OSAP.NonceEven));

            ByteHelper.XORBytes(_usageAuth, xorKey);
            ByteHelper.XORBytes(_migrationAuth, xorKey);

            //Load parent key if not loaded
            _keyManager.LoadKey(_params.GetValueOf<string>("parent"));

            TPMBlob requestBlob = new TPMBlob();
            requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_AUTH1_COMMAND, TPMOrdinals.TPM_ORD_CreateWrapKey);

            //parent key handle gets inserted later, it may be not available now
            requestBlob.WriteUInt32(0);
            requestBlob.Write(_usageAuth, 0, 20);
            requestBlob.Write(_migrationAuth, 0, 20);
            _tpmKey.WriteToTpmBlob(requestBlob);

            using(_keyManager.AcquireLock())
            {
                AuthorizeMe(requestBlob);
                requestBlob.SkipHeader();

                if(_params.GetValueOf<string>("parent") == KeyHandle.KEY_SRK)
                    requestBlob.WriteUInt32((uint)TPMKeyHandles.TPM_KH_SRK);
                else
                    requestBlob.WriteUInt32(_keyManager.IdentifierToHandle(_params.GetValueOf<string>("parent")).Handle);

                _responseBlob = TransmitMe(requestBlob);
            }

            CheckResponseAuthInfo();

            _responseBlob.SkipHeader();
            TPMKeyCore newKey = new TPMKeyCore(_responseBlob);
            _responseParameters = new Parameters();

            //Build and save the key identifier
            //The key identifier is the hex-string representation of the hash of the newly created key
            _responseParameters.AddPrimitiveType("key_identifier",
                ByteHelper.ByteArrayToHexString(
                    new HashProvider().Hash(
                            new HashByteDataProvider(
                                ByteHelper.SerializeToBytes(newKey)
                            )
                        ),
                    ""));

            _responseParameters.AddPrimitiveType("key_data", ByteHelper.SerializeToBytes(newKey));

            return new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_CreateWrapKey, _responseParameters);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:63,代码来源:TPM_CreateWrapKey.cs

示例13: GetKeyInfo

        public override HMACKeyInfo GetKeyInfo(AuthSessionNum authSessionNum)
        {
            if(authSessionNum != AuthSessionNum.Auth1)
                return null;

            string parentIdentifier = _params.GetValueOf<string>("parent");

            if(parentIdentifier == KeyHandle.KEY_SRK)
                return new HMACKeyInfo(HMACKeyInfo.HMACKeyType.SrkSecret, new Parameters());
            else
            {
                Parameters parameters = new Parameters();
                parameters.AddPrimitiveType("identifier", parentIdentifier);

                return new HMACKeyInfo(HMACKeyInfo.HMACKeyType.KeyUsageSecret, parameters);
            }
        }
开发者ID:deveck,项目名称:doTSS,代码行数:17,代码来源:TPM_CreateWrapKey.cs

示例14: InternalProcess

        protected override TPMCommandResponse InternalProcess()
        {
            using(TPMBlob requestBlob = new TPMBlob())
            {
                requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_AUTH1_COMMAND, TPMOrdinals.TPM_ORD_IncrementCounter);
                requestBlob.WriteUInt32(_params.GetValueOf<uint>("counter_id"));

                _responseBlob = AuthorizeMeAndTransmit(requestBlob);
            }

            _responseBlob.SkipHeader();
            _responseParameters = new Parameters();
            _responseParameters.AddPrimitiveType("counter_id", _responseBlob.ReadUInt32());
            _responseParameters.AddValue("counter_value", TPMCounterValueCore.CreateFromTPMBlob(_responseBlob));

            return new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_CreateCounter, _responseParameters);
        }
开发者ID:deveck,项目名称:doTSS,代码行数:17,代码来源:TPM_IncrementCounter.cs

示例15: Quote

        /// <summary>
        /// Cryptographically reports the selected PCR values and returns
        /// the TPMPCRComposite and the generated signature. If no
        /// external data is supplied a random nonce is generated on the server.
        /// The length of externalData is defined by the hashing algorithm used by the TPM
        /// </summary>
        /// <param name="pcrs"></param>
        /// <param name="externalData">Nonce used for the quoting operation, 
        /// use CreateCompatibleHashAlgorithm or CreateCompatibleHashProvider to generate a hash value
        /// with the correct length</param>
        /// <returns></returns>
        public QuoteResponse Quote(TPMPCRSelection pcrs, byte[] externalData)
        {
            Parameters quoteParameters = new Parameters();
            quoteParameters.AddPrimitiveType("key", _keyIdentifier);
            quoteParameters.AddValue("targetPCR", pcrs);

            if(externalData != null)
                quoteParameters.AddPrimitiveType("externalData", externalData);

            TPMCommandResponse response = BuildDoVerifyRequest(TPMCommandNames.TPM_CMD_Quote, quoteParameters);

            return new QuoteResponse(response.Parameters.GetValueOf<TPMPCRComposite>("pcrData"),
                                     response.Parameters.GetValueOf<byte[]>("sig"));
        }
开发者ID:deveck,项目名称:doTSS,代码行数:25,代码来源:TPMKeyClient.cs


注:本文中的Parameters.AddPrimitiveType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。