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


C# ISigner类代码示例

本文整理汇总了C#中ISigner的典型用法代码示例。如果您正苦于以下问题:C# ISigner类的具体用法?C# ISigner怎么用?C# ISigner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Decode

        public Challenge Decode(IdentifierPart ip, ChallengePart cp, ISigner signer)
        {
            if (cp.Type != AcmeProtocol.CHALLENGE_TYPE_HTTP)
                throw new InvalidDataException("unsupported Challenge type")
                    .With("challengeType", cp.Type)
                    .With("supportedChallengeTypes", AcmeProtocol.CHALLENGE_TYPE_HTTP);

            //var token = (string)cp["token"];
            var token = cp.Token;

            // This response calculation is described in:
            //    https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-7.2

            var keyAuthz = JwsHelper.ComputeKeyAuthorization(signer, token);
            var path = $"{AcmeProtocol.HTTP_CHALLENGE_PATHPREFIX}{token}";
            var url = $"http://{ip.Value}/{path}";


            var ca = new HttpChallengeAnswer
            {
                KeyAuthorization = keyAuthz,
            };

            var c = new HttpChallenge(cp.Type, ca)
            {
                Token = token,
                FileUrl = url,
                FilePath = path,
                FileContent = keyAuthz,
            };

            return c;
        }
开发者ID:bseddon,项目名称:ACMESharp,代码行数:33,代码来源:HttpChallengeDecoder.cs

示例2: GenerateScriptSig

		public override Script GenerateScriptSig(Script scriptPubKey, IKeyRepository keyRepo, ISigner signer)
		{
			var multiSigParams = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(scriptPubKey);
			TransactionSignature[] signatures = new TransactionSignature[multiSigParams.PubKeys.Length];
			var keys =
				multiSigParams
				.PubKeys
				.Select(p => keyRepo.FindKey(p.ScriptPubKey))
				.ToArray();

			int sigCount = 0;
			for(int i = 0 ; i < keys.Length ; i++)
			{
				if(sigCount == multiSigParams.SignatureCount)
					break;
				if(keys[i] != null)
				{
					var sig = signer.Sign(keys[i]);
					signatures[i] = sig;
					sigCount++;
				}
			}

			IEnumerable<TransactionSignature> sigs = signatures;
			if(sigCount == multiSigParams.SignatureCount)
			{
				sigs = sigs.Where(s => s != TransactionSignature.Empty && s != null);
			}
			return PayToMultiSigTemplate.Instance.GenerateScriptSig(sigs);
		}
开发者ID:knocte,项目名称:NBitcoin,代码行数:30,代码来源:P2MultiSigBuilderExtension.cs

示例3: DkimSignatureStream

		/// <summary>
		/// Initializes a new instance of the <see cref="MimeKit.Cryptography.DkimSignatureStream"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="DkimSignatureStream"/>.
		/// </remarks>
		/// <param name="signer">The digest signer.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="signer"/>is <c>null</c>.
		/// </exception>
		public DkimSignatureStream (ISigner signer)
		{
			if (signer == null)
				throw new ArgumentNullException ("signer");

			Signer = signer;
		}
开发者ID:ruffin--,项目名称:MimeKit,代码行数:17,代码来源:DkimSignatureStream.cs

示例4: DkimSigningRoutingAgent

        /// <summary>
        /// Initializes a new instance of the <see cref="DkimSigningRoutingAgent"/> class.
        /// </summary>
        /// <param name="dkimSigner">The object that knows how to sign messages.</param>
        public DkimSigningRoutingAgent(List<DomainElement> domainSettings, ISigner dkimSigner)
        {
            this.domainSettings = domainSettings;
            this.dkimSigner = dkimSigner;

            this.OnCategorizedMessage += this.WhenMessageCategorized;
        }
开发者ID:rconuser,项目名称:dkim-exchange,代码行数:11,代码来源:DkimSigningRoutingAgent.cs

示例5: Decode

        public Challenge Decode(IdentifierPart ip, ChallengePart cp, ISigner signer)
        {
            if (cp.Type != AcmeProtocol.CHALLENGE_TYPE_DNS)
                throw new InvalidDataException("unsupported Challenge type")
                    .With("challengeType", cp.Type)
                    .With("supportedChallengeTypes", AcmeProtocol.CHALLENGE_TYPE_DNS);

            //var token = (string)cp["token"];
            var token = cp.Token;

            // This response calculation is described in:
            //    https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-7.5

            var keyAuthz = JwsHelper.ComputeKeyAuthorization(signer, token);
            var keyAuthzDig = JwsHelper.ComputeKeyAuthorizationDigest(signer, token);

            var ca = new DnsChallengeAnswer
            {
                KeyAuthorization = keyAuthz,
            };

            var c = new DnsChallenge(cp.Type, ca)
            {
                Token = token,
                RecordName = $"{AcmeProtocol.DNS_CHALLENGE_NAMEPREFIX}{ip.Value}",
                RecordValue = keyAuthzDig,
            };

            return c;
        }
开发者ID:bseddon,项目名称:ACMESharp,代码行数:30,代码来源:DnsChallengeDecoder.cs

示例6: SetSignatureParameters

		internal static void SetSignatureParameters(
			ISigner			signature,
			Asn1Encodable	parameters)
		{
			if (parameters != null && !derNull.Equals(parameters))
			{
				// TODO Put back in
//				AlgorithmParameters sigParams = AlgorithmParameters.GetInstance(signature.getAlgorithm());
//
//				try
//				{
//					sigParams.Init(parameters.ToAsn1Object().GetDerEncoded());
//				}
//				catch (IOException e)
//				{
//					throw new SignatureException("IOException decoding parameters: " + e.Message);
//				}
//
//				if (Platform.EndsWith(signature.getAlgorithm(), "MGF1"))
//				{
//					try
//					{
//						signature.setParameter(sigParams.getParameterSpec(PSSParameterSpec.class));
//					}
//					catch (GeneralSecurityException e)
//					{
//						throw new SignatureException("Exception extracting parameters: " + e.Message);
//					}
//				}
			}
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:31,代码来源:X509SignatureUtil.cs

示例7: GenerateHttpChallengeAnswer

 /// <summary>
 /// Returns a key-value pair that represents the HTTP resource path that
 /// needs to be configured (the key) and the resource content that should be returned
 /// for an HTTP request for this path on a server that the target DNS resolve to.
 /// </summary>
 /// <param name="dnsId"></param>
 /// <param name="signer"></param>
 /// <returns></returns>
 public KeyValuePair<string, string> GenerateHttpChallengeAnswer(string dnsId, ISigner signer)
 {
     var keyAuthz = JwsHelper.ComputeKeyAuthorization(signer, Token);
     
     return new KeyValuePair<string, string>(
             $"{HTTP_CHALLENGE_PATHPREFIX}{Token}", keyAuthz);
 }
开发者ID:jagbarcelo,项目名称:ACMESharp,代码行数:15,代码来源:AuthorizeChallenge.cs

示例8: GenerateScriptSig

		public override Script GenerateScriptSig(Script scriptPubKey, IKeyRepository keyRepo, ISigner signer)
		{
			var key = keyRepo.FindKey(scriptPubKey);
			if(key == null)
				return null;
			var sig = signer.Sign(key);
			return PayToPubkeyTemplate.Instance.GenerateScriptSig(sig);
		}
开发者ID:knocte,项目名称:NBitcoin,代码行数:8,代码来源:P2PKBuilderExtension.cs

示例9: SignerStream

		public SignerStream(
			Stream	stream,
			ISigner	readSigner,
			ISigner	writeSigner)
		{
			this.stream = stream;
			this.inSigner = readSigner;
			this.outSigner = writeSigner;
		}
开发者ID:htlp,项目名称:itextsharp,代码行数:9,代码来源:SignerStream.cs

示例10: GenerateScriptSig

		public override Script GenerateScriptSig(Script scriptPubKey, IKeyRepository keyRepo, ISigner signer)
		{
			var parameters = PayToPubkeyHashTemplate.Instance.ExtractScriptPubKeyParameters(scriptPubKey);
			var key = keyRepo.FindKey(parameters.ScriptPubKey);
			if(key == null)
				return null;
			var sig = signer.Sign(key);
			return PayToPubkeyHashTemplate.Instance.GenerateScriptSig(sig, key.PubKey);
		}
开发者ID:crowar,项目名称:NBitcoin,代码行数:9,代码来源:P2PKHBuilderExtension.cs

示例11: AcmeClient

        public AcmeClient(Uri rootUrl = null, AcmeServerDirectory dir = null,
                ISigner signer = null, AcmeRegistration reg = null)
        {
            RootUrl = rootUrl;
            Directory = dir;
            Signer = signer;
            Registration = reg;

            UserAgent = string.Format(AcmeProtocol.HTTP_USER_AGENT_FMT,
                    this.GetType().Assembly.GetName().Version);
        }
开发者ID:ezs-ebekker,项目名称:letsencrypt-win,代码行数:11,代码来源:AcmeClient.cs

示例12: SignerInf

            internal SignerInf(
				CmsSignedDataStreamGenerator	outer,
				AsymmetricKeyParameter			key,
				X509Certificate					cert,
				string							digestOID,
				string							encOID,
				CmsAttributeTableGenerator		sAttr,
				CmsAttributeTableGenerator		unsAttr,
				ISigner							signature)
			{
				this.outer = outer;

				_key = key;
				_cert = cert;
				_digestOID = digestOID;
				_encOID = encOID;
				_sAttr = sAttr;
				_unsAttr = unsAttr;
				_signature = signature;
			}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:20,代码来源:CMSSignedDataStreamGenerator.cs

示例13: GenerateDnsChallengeAnswer

        /// <summary>
        /// Returns a key-value pair that represents the DNS domain name that needs
        /// to be configured (the key) and the value that should be returned (the value)
        /// for a query against that domain name for a record of type TXT.
        /// </summary>
        /// <param name="dnsId"></param>
        /// <param name="signer"></param>
        /// <returns></returns>
        public KeyValuePair<string, string> GenerateDnsChallengeAnswer(string dnsId, ISigner signer)
        {
            var resp = new
            {
                type = "dns",
                token = Token
            };
            var json = JsonConvert.SerializeObject(resp);
            var hdrs = new { alg = signer.JwsAlg, jwk = signer.ExportJwk() };
            var signed = JwsHelper.SignFlatJsonAsObject(
                    signer.Sign, json, unprotectedHeaders: hdrs);

            /*
            // We format it as a set of lines broken on 100-character boundaries to make it
            // easier to copy and put into a DNS TXT RR which normally have a 255-char limit
            // so this result may need to be broken up into multiple smaller TXT RR entries
            var sigFormatted = Regex.Replace(signed.signature,
                    "(.{100,100})", "$1\r\n");
            */

            return new KeyValuePair<string, string>(
                    $"{DNS_CHALLENGE_NAMEPREFIX}{dnsId}",
                    signed.signature); /*sigFormatted);*/
        }
开发者ID:jozefizso,项目名称:letsencrypt-win,代码行数:32,代码来源:AuthorizeChallenge.cs

示例14: SetSignatureParameters

//        /// <summary>
//        /// Get the Der Encoded Pkcs10 Certification Request.
//        /// </summary>
//        /// <returns>A byte array.</returns>
//        public byte[] GetEncoded()
//        {
//        	return new CertificationRequest(reqInfo, sigAlgId, sigBits).GetDerEncoded();
//        }

		// TODO Figure out how to set parameters on an ISigner
		private void SetSignatureParameters(
			ISigner			signature,
			Asn1Encodable	asn1Params)
		{
			if (asn1Params != null && !(asn1Params is Asn1Null))
			{
//				AlgorithmParameters sigParams = AlgorithmParameters.GetInstance(signature.getAlgorithm());
//
//				try
//				{
//					sigParams.init(asn1Params.ToAsn1Object().GetDerEncoded());
//				}
//				catch (IOException e)
//				{
//					throw new SignatureException("IOException decoding parameters: " + e.Message);
//				}

				if (signature.AlgorithmName.EndsWith("MGF1"))
				{
					throw Platform.CreateNotImplementedException("signature algorithm with MGF1");

//					try
//					{
//						signature.setParameter(sigParams.getParameterSpec(PSSParameterSpec.class));
//					}
//					catch (GeneralSecurityException e)
//					{
//						throw new SignatureException("Exception extracting parameters: " + e.getMessage());
//					}
				}
			}
		}
开发者ID:justice501,项目名称:bc-csharp,代码行数:42,代码来源:Pkcs10CertificationRequest.cs

示例15: PgpSignatureGenerator

        /// <summary>Create a generator for the passed in keyAlgorithm and hashAlgorithm codes.</summary>
        public PgpSignatureGenerator(PublicKeyAlgorithmTag keyAlgorithm, HashAlgorithmTag hashAlgorithm)
        {
            _keyAlgorithm = keyAlgorithm;
            _hashAlgorithm = hashAlgorithm;

            _dig = DigestUtilities.GetDigest(PgpUtilities.GetDigestName(hashAlgorithm));
            _sig = SignerUtilities.GetSigner(PgpUtilities.GetSignatureName(keyAlgorithm, hashAlgorithm));
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:9,代码来源:PgpSignatureGenerator.cs


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