• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PublicKeyAlgorithmTag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetKeyCipher

		private static IBufferedCipher GetKeyCipher(
            PublicKeyAlgorithmTag algorithm)
        {
            try
            {
                switch (algorithm)
                {
                    case PublicKeyAlgorithmTag.RsaEncrypt:
                    case PublicKeyAlgorithmTag.RsaGeneral:
                        return CipherUtilities.GetCipher("RSA//PKCS1Padding");
                    case PublicKeyAlgorithmTag.ElGamalEncrypt:
                    case PublicKeyAlgorithmTag.ElGamalGeneral:
                        return CipherUtilities.GetCipher("ElGamal/ECB/PKCS1Padding");
                    default:
                        throw new PgpException("unknown asymmetric algorithm: " + algorithm);
                }
            }
            catch (PgpException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new PgpException("Exception creating cipher", e);
            }
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:26,代码来源:PgpPublicKeyEncryptedData.cs


示例2: PublicKeyPacket

 /// <summary>
 /// Construct a version 4 public key packet.
 /// </summary>
 /// <param name="algorithm">The algorithm.</param>
 /// <param name="time">The time.</param>
 /// <param name="key">The key.</param>
 public PublicKeyPacket(PublicKeyAlgorithmTag algorithm, DateTime time, IBcpgPublicKey key)
 {
     _version = 4;
     _time = DateTimeUtilities.DateTimeToUnixMs(time) / 1000L;
     _algorithm = algorithm;
     _key = key;
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:13,代码来源:PublicKeyPacket.cs


示例3: GetAlgorithm

        public static string GetAlgorithm(
            PublicKeyAlgorithmTag algId)
        {
            switch (algId)
            {
                case PublicKeyAlgorithmTag.RsaGeneral:
                    return "RsaGeneral";
                case PublicKeyAlgorithmTag.RsaEncrypt:
                    return "RsaEncrypt";
                case PublicKeyAlgorithmTag.RsaSign:
                    return "RsaSign";
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                    return "ElGamalEncrypt";
                case PublicKeyAlgorithmTag.Dsa:
                    return "DSA";
                case PublicKeyAlgorithmTag.EC:
                    return "EC";
                case PublicKeyAlgorithmTag.ECDsa:
                    return "ECDSA";
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                    return "ElGamalGeneral";
                case PublicKeyAlgorithmTag.DiffieHellman:
                    return "DiffieHellman";
            }

            return "unknown";
        }
开发者ID:randombit,项目名称:hacrypto,代码行数:27,代码来源:PublicKeyRingDump.cs


示例4: PublicKeyPacket

        internal PublicKeyPacket(
            BcpgInputStream bcpgIn)
        {
            version = bcpgIn.ReadByte();

            time = ((uint)bcpgIn.ReadByte() << 24) | ((uint)bcpgIn.ReadByte() << 16)
                | ((uint)bcpgIn.ReadByte() << 8) | (uint)bcpgIn.ReadByte();

            if (version <= 3)
            {
                validDays = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
            }

            algorithm = (PublicKeyAlgorithmTag) bcpgIn.ReadByte();

            switch ((PublicKeyAlgorithmTag) algorithm)
            {
                case PublicKeyAlgorithmTag.RsaEncrypt:
                case PublicKeyAlgorithmTag.RsaGeneral:
                case PublicKeyAlgorithmTag.RsaSign:
                    key = new RsaPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.Dsa:
                    key = new DsaPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                    key = new ElGamalPublicBcpgKey(bcpgIn);
                    break;
                default:
                    throw new IOException("unknown PGP public key algorithm encountered");
            }
        }
开发者ID:htlp,项目名称:itextsharp,代码行数:33,代码来源:PublicKeyPacket.cs


示例5: SignaturePacket

        public SignaturePacket(
            int version,
            int signatureType,
            long keyId,
            PublicKeyAlgorithmTag keyAlgorithm,
            HashAlgorithmTag hashAlgorithm,
            ISignatureSubpacket[] hashedData,
            ISignatureSubpacket[] unhashedData,
            byte[] fingerprint,
            MPInteger[] signature)
        {
            this._version = version;
            this._signatureType = signatureType;
            this._keyId = keyId;
            this._keyAlgorithm = keyAlgorithm;
            this._hashAlgorithm = hashAlgorithm;
            this._hashedData = hashedData;
            this._unhashedData = unhashedData;
            this._fingerprint = fingerprint;
            this._signature = signature;

            if (hashedData != null)
            {
                SetCreationTime();
            }
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:26,代码来源:SignaturePacket.cs


示例6: GetSignatureName

		public static string GetSignatureName(
            PublicKeyAlgorithmTag	keyAlgorithm,
            HashAlgorithmTag		hashAlgorithm)
        {
            string encAlg;
			switch (keyAlgorithm)
            {
				case PublicKeyAlgorithmTag.RsaGeneral:
				case PublicKeyAlgorithmTag.RsaSign:
					encAlg = "RSA";
					break;
				case PublicKeyAlgorithmTag.Dsa:
					encAlg = "DSA";
					break;
                case PublicKeyAlgorithmTag.ECDH:
                    encAlg = "ECDH";
                    break;
                case PublicKeyAlgorithmTag.ECDsa:
                    encAlg = "ECDSA";
                    break;
                case PublicKeyAlgorithmTag.ElGamalEncrypt: // in some malformed cases.
				case PublicKeyAlgorithmTag.ElGamalGeneral:
					encAlg = "ElGamal";
					break;
				default:
					throw new PgpException("unknown algorithm tag in signature:" + keyAlgorithm);
            }

			return GetDigestName(hashAlgorithm) + "with" + encAlg;
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:30,代码来源:PgpUtilities.cs


示例7: PublicKeyEncSessionPacket

		internal PublicKeyEncSessionPacket(
			BcpgInputStream bcpgIn)
		{
			version = bcpgIn.ReadByte();

			keyId |= (long)bcpgIn.ReadByte() << 56;
			keyId |= (long)bcpgIn.ReadByte() << 48;
			keyId |= (long)bcpgIn.ReadByte() << 40;
			keyId |= (long)bcpgIn.ReadByte() << 32;
			keyId |= (long)bcpgIn.ReadByte() << 24;
			keyId |= (long)bcpgIn.ReadByte() << 16;
			keyId |= (long)bcpgIn.ReadByte() << 8;
			keyId |= (uint)bcpgIn.ReadByte();

			algorithm = (PublicKeyAlgorithmTag) bcpgIn.ReadByte();

			switch ((PublicKeyAlgorithmTag) algorithm)
			{
				case PublicKeyAlgorithmTag.RsaEncrypt:
				case PublicKeyAlgorithmTag.RsaGeneral:
					data = new BigInteger[]{ new MPInteger(bcpgIn).Value };
					break;
				case PublicKeyAlgorithmTag.ElGamalEncrypt:
				case PublicKeyAlgorithmTag.ElGamalGeneral:
					data = new BigInteger[]
					{
						new MPInteger(bcpgIn).Value,
						new MPInteger(bcpgIn).Value
					};
					break;
				default:
					throw new IOException("unknown PGP public key algorithm encountered");
			}
		}
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:34,代码来源:PublicKeyEncSessionPacket.cs


示例8: PublicSubkeyPacket

		/// <summary>Construct a version 4 public subkey packet.</summary>
        public PublicSubkeyPacket(
            PublicKeyAlgorithmTag	algorithm,
            DateTime				time,
            IBcpgKey				key)
            : base(algorithm, time, key)
        {
        }
开发者ID:htlp,项目名称:itextsharp,代码行数:8,代码来源:PublicSubkeyPacket.cs


示例9: PgpKeyPair

		public PgpKeyPair(
            PublicKeyAlgorithmTag	algorithm,
            AsymmetricCipherKeyPair	keyPair,
            DateTime				time)
			: this(algorithm, keyPair.Public, keyPair.Private, time)
        {
        }
开发者ID:htlp,项目名称:itextsharp,代码行数:7,代码来源:PgpKeyPair.cs


示例10: 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


示例11: PublicKeyEncSessionPacket

 public PublicKeyEncSessionPacket(long keyId, PublicKeyAlgorithmTag algorithm, BigInteger[] data, byte[] extraData)
 {
     _version = 3;
     _keyId = keyId;
     _algorithm = algorithm;
     _data = (IBigInteger[])data.Clone();
     _extraData = extraData != null ? (byte[])extraData.Clone() : null;
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:8,代码来源:PublicKeyEncSessionPacket.cs


示例12: RevocationKey

        public RevocationKey(
			bool					isCritical,
			RevocationKeyTag		signatureClass,
			PublicKeyAlgorithmTag	keyAlgorithm,
			byte[]					fingerprint)
			: base(SignatureSubpacketTag.RevocationKey, isCritical, false,
				CreateData(signatureClass, keyAlgorithm, fingerprint))
		{
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:9,代码来源:RevocationKey.cs


示例13: PgpPublicKey

        /// <summary>
        /// Create a PgpPublicKey from the passed in lightweight one.
        /// </summary>
        /// <remarks>
        /// Note: the time passed in affects the value of the key's keyId, so you probably only want
        /// to do this once for a lightweight key, or make sure you keep track of the time you used.
        /// </remarks>
        /// <param name="algorithm">Asymmetric algorithm type representing the public key.</param>
        /// <param name="pubKey">Actual public key to associate.</param>
        /// <param name="time">Date of creation.</param>
        /// <exception cref="ArgumentException">If <c>pubKey</c> is not public.</exception>
        /// <exception cref="PgpException">On key creation problem.</exception>
        public PgpPublicKey(PublicKeyAlgorithmTag algorithm, IAsymmetricKeyParameter pubKey, DateTime time)
        {
            if (pubKey.IsPrivate)
                throw new ArgumentException(@"Expected a public key", "pubKey");

            IBcpgPublicKey bcpgKey;

            if (pubKey is RsaKeyParameters)
            {
                var rK = (RsaKeyParameters)pubKey;

                bcpgKey = new RsaPublicBcpgKey(rK.Modulus, rK.Exponent);
            }
            else if (pubKey is DsaPublicKeyParameters)
            {
                var dK = (DsaPublicKeyParameters)pubKey;
                var dP = dK.Parameters;

                bcpgKey = new DsaPublicBcpgKey(dP.P, dP.Q, dP.G, dK.Y);
            }
            else if (pubKey is ElGamalPublicKeyParameters)
            {
                var eK = (ElGamalPublicKeyParameters)pubKey;
                var eS = eK.Parameters;

                bcpgKey = new ElGamalPublicBcpgKey(eS.P, eS.G, eK.Y);
            }
            else if (pubKey is ECDHPublicKeyParameters)
            {
                var ecdh = (ECDHPublicKeyParameters)pubKey;

                bcpgKey = new ECDHPublicBcpgKey(ecdh.Q, ecdh.PublicKeyParamSet, ecdh.HashAlgorithm, ecdh.SymmetricKeyAlgorithm);
            }
            else if (pubKey is ECPublicKeyParameters)
            {
                var ecdsa = (ECPublicKeyParameters)pubKey;
                bcpgKey = new ECDSAPublicBcpgKey(ecdsa.Q, ecdsa.PublicKeyParamSet);
            }
            else
            {
                throw new PgpException("unknown key class");
            }

            _publicPk = new PublicKeyPacket(algorithm, time, bcpgKey);
            _ids = Platform.CreateArrayList();
            _idSigs = Platform.CreateArrayList<IList<IPgpSignature>>();

            try
            {
                Init();
            }
            catch (IOException e)
            {
                throw new PgpException("exception calculating keyId", e);
            }
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:68,代码来源:PgpPublicKey.cs


示例14: PublicKeyPacket

		/// <summary>Construct a version 4 public key packet.</summary>
        public PublicKeyPacket(
            PublicKeyAlgorithmTag	algorithm,
            DateTime				time,
            IBcpgKey				key)
        {
			this.version = 4;
            this.time = DateTimeUtilities.DateTimeToUnixMs(time) / 1000L;
            this.algorithm = algorithm;
            this.key = key;
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:11,代码来源:PublicKeyPacket.cs


示例15: PgpV3SignatureGenerator

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

            dig = DigestUtilities.GetDigest(PgpUtilities.GetDigestName(hashAlgorithm));
            sig = SignerUtilities.GetSigner(PgpUtilities.GetSignatureName(keyAlgorithm, hashAlgorithm));
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:11,代码来源:PgpV3SignatureGenerator.cs


示例16: CreateData

		private static byte[] CreateData(
			RevocationKeyTag		signatureClass,
			PublicKeyAlgorithmTag	keyAlgorithm,
			byte[]					fingerprint)
		{
			byte[] data = new byte[2 + fingerprint.Length];
			data[0] = (byte)signatureClass;
			data[1] = (byte)keyAlgorithm;
			Array.Copy(fingerprint, 0, data, 2, fingerprint.Length);
			return data;
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:11,代码来源:RevocationKey.cs


示例17: SignaturePacket

 /**
 * Generate a version 4 signature packet.
 *
 * @param signatureType
 * @param keyAlgorithm
 * @param hashAlgorithm
 * @param hashedData
 * @param unhashedData
 * @param fingerprint
 * @param signature
 */
 public SignaturePacket(
     int						signatureType,
     long					keyId,
     PublicKeyAlgorithmTag	keyAlgorithm,
     HashAlgorithmTag		hashAlgorithm,
     SignatureSubpacket[]	hashedData,
     SignatureSubpacket[]	unhashedData,
     byte[]					fingerprint,
     MPInteger[]				signature)
     : this(4, signatureType, keyId, keyAlgorithm, hashAlgorithm, hashedData, unhashedData, fingerprint, signature)
 {
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:23,代码来源:SignaturePacket.cs


示例18: OnePassSignaturePacket

		public OnePassSignaturePacket(
			int						sigType,
			HashAlgorithmTag		hashAlgorithm,
			PublicKeyAlgorithmTag	keyAlgorithm,
			long					keyId,
			bool					isNested)
		{
			this.version = 3;
			this.sigType = sigType;
			this.hashAlgorithm = hashAlgorithm;
			this.keyAlgorithm = keyAlgorithm;
			this.keyId = keyId;
			this.nested = (isNested) ? 0 : 1;
		}
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:14,代码来源:OnePassSignaturePacket.cs


示例19: PublicKeyEncSessionPacket

        public PublicKeyEncSessionPacket(
			long                    keyId,
			PublicKeyAlgorithmTag   algorithm,
			byte[][]                data)
		{
			this.version = 3;
			this.keyId = keyId;
			this.algorithm = algorithm;
            this.data = new byte[data.Length][];
            for (int i = 0; i < data.Length; ++i)
            {
                this.data[i] = Arrays.Clone(data[i]);
            }
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:14,代码来源:PublicKeyEncSessionPacket.cs


示例20: PgpSecretKey

 public PgpSecretKey(
     int certificationLevel,
     PublicKeyAlgorithmTag algorithm,
     IAsymmetricKeyParameter pubKey,
     IAsymmetricKeyParameter privKey,
     DateTime time,
     string id,
     SymmetricKeyAlgorithmTag encAlgorithm,
     char[] passPhrase,
     bool useSha1,
     PgpSignatureSubpacketVector hashedPackets,
     PgpSignatureSubpacketVector unhashedPackets,
     SecureRandom rand)
     : this(certificationLevel, new PgpKeyPair(algorithm, pubKey, privKey, time), id, encAlgorithm, passPhrase, useSha1, hashedPackets, unhashedPackets, rand)
 {
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:16,代码来源:PgpSecretKey.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PublishedFileId_t类代码示例发布时间:2022-05-24
下一篇:
C# Ptr类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap