本文整理匯總了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;
}