當前位置: 首頁>>代碼示例>>C#>>正文


C# PgpPublicKey.GetSignatures方法代碼示例

本文整理匯總了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;
		}
開發者ID:ALange,項目名稱:OutlookPrivacyPlugin,代碼行數:33,代碼來源:PgpCrypto.cs

示例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;
		}
開發者ID:ALange,項目名稱:OutlookPrivacyPlugin,代碼行數:39,代碼來源:PgpCrypto.cs

示例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;
		}
開發者ID:korusdipl,項目名稱:OutlookPrivacyPlugin,代碼行數:27,代碼來源:PgpCrypto.cs


注:本文中的Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKey.GetSignatures方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。