本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
// }
// }
}
}
示例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);
}
示例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);
}
示例9: SignerStream
public SignerStream(
Stream stream,
ISigner readSigner,
ISigner writeSigner)
{
this.stream = stream;
this.inSigner = readSigner;
this.outSigner = writeSigner;
}
示例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);
}
示例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);
}
示例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;
}
示例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);*/
}
示例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());
// }
}
}
}
示例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));
}