本文整理汇总了C#中Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKey.GetSignatures方法的典型用法代码示例。如果您正苦于以下问题:C# PgpPublicKey.GetSignatures方法的具体用法?C# PgpPublicKey.GetSignatures怎么用?C# PgpPublicKey.GetSignatures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKey
的用法示例。
在下文中一共展示了PgpPublicKey.GetSignatures方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSigningKey
/// <summary>
/// Is key allowed for signing?
/// </summary>
/// <remarks>
/// Checks both key algorithm and also key flags.
/// </remarks>
/// <param name="key"></param>
/// <param name="strict"></param>
/// <returns></returns>
public bool IsSigningKey(PgpPublicKey key)
{
foreach (PgpSignature sig in key.GetSignatures())
{
var hashedSubPackets = sig.GetHashedSubPackets();
if (hashedSubPackets == null)
continue;
if (!hashedSubPackets.HasSubpacket(SignatureSubpacketTag.KeyFlags))
continue;
var keyFlags = hashedSubPackets.GetKeyFlags();
if ((keyFlags & KeyFlags.SignData) > 0)
return true;
return false;
}
// Only use alg if keyflags is missing
if (IsSigningAlg(key))
return true;
return false;
}
示例2: IsEncryptionKey
/// <summary>
/// Is key allowed for encryption?
/// </summary>
/// <remarks>
/// Checks both key algorithm and also key flags.
/// </remarks>
/// <param name="key"></param>
/// <returns></returns>
public bool IsEncryptionKey(PgpPublicKey key)
{
// First check key use flags
foreach (PgpSignature sig in key.GetSignatures())
{
var hashedSubPackets = sig.GetHashedSubPackets();
if (hashedSubPackets == null)
continue;
if (!hashedSubPackets.HasSubpacket(SignatureSubpacketTag.KeyFlags))
continue;
var keyFlags = hashedSubPackets.GetKeyFlags();
if ((keyFlags & KeyFlags.EncryptComms) > 0)
return true;
if ((keyFlags & KeyFlags.EncryptStorage) > 0)
return true;
return false;
}
// NOTE: Some keys do not have flags set. Instead use
// the alg type. But only those specific to encryption.
if (IsEncryptionAlg(key))
return true;
return false;
}
示例3: IsSigningKey
/// <summary>
/// Is key allowed for signing?
/// </summary>
/// <remarks>
/// Checks both key algorithm and also key flags.
/// </remarks>
/// <param name="key"></param>
/// <returns></returns>
public bool IsSigningKey(PgpPublicKey key)
{
foreach (PgpSignature sig in key.GetSignatures())
{
var hashedSubPackets = sig.GetHashedSubPackets();
if (hashedSubPackets == null)
continue;
var keyFlags = hashedSubPackets.GetKeyFlags();
if ((keyFlags & KeyFlags.SignData) > 0)
return true;
}
if (IsSigningAlg(key))
return true;
return false;
}