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

C# Cryptography.Oid类代码示例

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

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



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

示例1: DecodePublicKey

        public AsymmetricAlgorithm DecodePublicKey(Oid oid, byte[] encodedKeyValue, byte[] encodedParameters)
        {
            int algId = OidInfo.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, oid.Value, OidGroup.PublicKeyAlgorithm, fallBackToAllGroups: true).AlgId;
            switch (algId)
            {
                case AlgId.CALG_RSA_KEYX:
                case AlgId.CALG_RSA_SIGN:
                    {
                        byte[] keyBlob = DecodeKeyBlob(CryptDecodeObjectStructType.RSA_CSP_PUBLICKEYBLOB, encodedKeyValue);
                        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
                        rsa.ImportCspBlob(keyBlob);
                        return rsa;
                    }

                case AlgId.CALG_DSS_SIGN:
                    {
                        byte[] keyBlob = ConstructDSSPublicKeyCspBlob(encodedKeyValue, encodedParameters);
                        DSACryptoServiceProvider dsa = new DSACryptoServiceProvider();
                        dsa.ImportCspBlob(keyBlob);
                        return dsa;
                    }

                default:
                    throw new NotSupportedException(SR.NotSupported_KeyAlgorithm);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:26,代码来源:X509Pal.PublicKey.cs


示例2: AnnotationBase

 public AnnotationBase(Oid id, object value)
 {
     if(null == id) { throw new ArgumentNullException(); }
     this.Id = id;
     this.Value = value;
     return;
 }
开发者ID:BlueSkeye,项目名称:ApkRe,代码行数:7,代码来源:AnnotationBase.cs


示例3: Oid

 public Oid(Oid oid) {
     if (oid == null)
         throw new ArgumentNullException("oid");
     m_value = oid.m_value;
     m_friendlyName = oid.m_friendlyName;
     m_group = oid.m_group;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:Oid.cs


示例4: ConstructorNonPkcs7Oid

		public void ConstructorNonPkcs7Oid ()
		{
			Oid o = new Oid ("1.2.3.4");
			ContentInfo ci = new ContentInfo (o, asnNull);
			Assert.AreEqual (asnNull, ci.Content, "Content");
			Assert.AreEqual ("1.2.3.4", ci.ContentType.Value, "ContentType.Value");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:ContentInfoTest.cs


示例5: HasEKU

 public static bool HasEKU(this X509Certificate2 self, Oid requiredEku)
 {
     return self.Extensions
         .OfType<X509EnhancedKeyUsageExtension>()
         .SelectMany(ext => ext.EnhancedKeyUsages.Cast<Oid>())
         .Any(eku => string.Equals(requiredEku.Value, eku.Value, StringComparison.OrdinalIgnoreCase));
 }
开发者ID:hishamco,项目名称:Signing,代码行数:7,代码来源:CryptoExtensions.cs


示例6: X509Extension

 public X509Extension (Oid oid, byte[] rawData, bool critical) : base (oid, rawData) {
     if (base.Oid == null || base.Oid.Value == null)
         throw new ArgumentNullException("oid");
     if (base.Oid.Value.Length == 0)
         throw new ArgumentException(SR.GetString(SR.Arg_EmptyOrNullString), "oid.Value");
     m_critical = critical;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:X509Extension.cs


示例7: SignaturePayload

 internal SignaturePayload(int version, string contentIdentifier, Oid digestAlgorithm, byte[] digest)
 {
     Version = version;
     ContentIdentifier = contentIdentifier;
     DigestAlgorithm = digestAlgorithm;
     Digest = digest;
 }
开发者ID:hishamco,项目名称:Signing,代码行数:7,代码来源:SignaturePayload.cs


示例8: DecodePublicKey

        public AsymmetricAlgorithm DecodePublicKey(Oid oid, byte[] encodedKeyValue, byte[] encodedParameters, ICertificatePal certificatePal)
        {
            if (oid.Value == Oids.Ecc)
            {
                return DecodeECDsaPublicKey((CertificatePal)certificatePal);
            }

            int algId = OidInfo.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, oid.Value, OidGroup.PublicKeyAlgorithm, fallBackToAllGroups: true).AlgId;
            switch (algId)
            {
                case AlgId.CALG_RSA_KEYX:
                case AlgId.CALG_RSA_SIGN:
                    {
                        byte[] keyBlob = DecodeKeyBlob(CryptDecodeObjectStructType.CNG_RSA_PUBLIC_KEY_BLOB, encodedKeyValue);
                        CngKey cngKey = CngKey.Import(keyBlob, CngKeyBlobFormat.GenericPublicBlob);
                        return new RSACng(cngKey);
                    }

#if !NETNATIVE
                case AlgId.CALG_DSS_SIGN:
                    {
                        byte[] keyBlob = ConstructDSSPublicKeyCspBlob(encodedKeyValue, encodedParameters);
                        DSACryptoServiceProvider dsa = new DSACryptoServiceProvider();
                        dsa.ImportCspBlob(keyBlob);
                        return dsa;
                    }
#endif

                default:
                    throw new NotSupportedException(SR.NotSupported_KeyAlgorithm);
            }
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:32,代码来源:X509Pal.PublicKey.cs


示例9: IsMatch

        public static bool IsMatch(this TimeStampToken tst, Stream data)
        {
            //check if we can verify the time-stamp
            if (tst.TimeStampInfo.HashAlgorithm.Parameters != DerNull.Instance)
            {
                trace.TraceEvent(TraceEventType.Error, 0, "The time-stamp {0} contains hash parameters {1} which isn't supported", tst.TimeStampInfo.SerialNumber, tst.TimeStampInfo.HashAlgorithm.Parameters);
                throw new NotSupportedException("Only hash algorithms without parameters are currently supported for timestamps");
            }
            if (tst.TimeStampInfo.Nonce != null)
            {
                trace.TraceEvent(TraceEventType.Error, 0, "The time-stamp {0} contains a Nonce which isn't supported", tst.TimeStampInfo.SerialNumber, tst.TimeStampInfo.HashAlgorithm.Parameters);
                throw new NotSupportedException("Time-stamp with a nonce isn't supported");
            }

            //create the hash according to the specs of the time-stamp
            var hashAlogOid = new Oid(tst.TimeStampInfo.HashAlgorithm.ObjectID.Id);
            var hashAlgo = (HashAlgorithm)CryptoConfig.CreateFromName(hashAlogOid.FriendlyName);
            byte[] signatureValueHashed = hashAlgo.ComputeHash(data);

            //verify the hash value
            byte[] timestampHash = tst.TimeStampInfo.TstInfo.MessageImprint.GetHashedMessage();

            trace.TraceEvent(TraceEventType.Verbose, 0, "Comparing the calculated hash ({3}) {1} with {2} for TST {0}", tst.TimeStampInfo.SerialNumber,
                Convert.ToBase64String(signatureValueHashed), Convert.ToBase64String(timestampHash), hashAlogOid.FriendlyName);
            return ((IStructuralEquatable)signatureValueHashed).Equals(timestampHash, StructuralComparisons.StructuralEqualityComparer);
        }
开发者ID:svn2github,项目名称:ehi,代码行数:26,代码来源:TimeStampTokenHelper.cs


示例10: One_CryptographicAttributeObject

		public void One_CryptographicAttributeObject () 
		{
			Oid o = new Oid (defaultOid);
			CryptographicAttributeObject cao = new CryptographicAttributeObject (o);
			coll = new CryptographicAttributeObjectCollection (cao);
			Count (1);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:CryptographicAttributeObjectEnumeratorTest.cs


示例11: CommonStuff

		private void CommonStuff (CryptographicAttributeObjectCollection coll)
		{
			Assert.IsFalse (coll.IsSynchronized, "IsSynchronized");
			Assert.AreSame (coll, coll.SyncRoot, "SyncRoot");
			Assert.IsNotNull (coll.GetEnumerator (), "GetEnumerator");

			int i = coll.Count;
			Oid o1 = new Oid ("1.2.840.113549.1.7.3");
			AsnEncodedData aed = new AsnEncodedData (o1, new byte[] { 0x05, 0x00 });
			Assert.AreEqual (i, coll.Add (aed), "Add(AsnEncodedData)");
			Assert.IsTrue ((coll[i++] is CryptographicAttributeObject), "converted");

			Oid o2 = new Oid ("1.2.840.113549.1.7.2");
			CryptographicAttributeObject cao = new CryptographicAttributeObject (o2);
			Assert.AreEqual (i, coll.Add (cao), "Add(CryptographicAttributeObject)");

			CryptographicAttributeObject[] array = new CryptographicAttributeObject [coll.Count];
			coll.CopyTo (array, 0);

			Array a = (Array) new object [coll.Count];
			ICollection c = (ICollection) coll;
			c.CopyTo (a, 0);

			IEnumerable e = (IEnumerable) coll;
			Assert.IsNotNull (e.GetEnumerator (), "GetEnumerator");

			coll.Remove (cao);
			Assert.AreEqual (i, coll.Count, "Remove(CryptographicAttributeObject)");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:CryptographicAttributeObjectCollectionTest.cs


示例12: Oid

		public Oid (Oid oid) 
		{
			if (oid == null)
				throw new ArgumentNullException ("oid");

			_value = oid.Value;
			_name = oid.FriendlyName;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:Oid.cs


示例13: ConstructorOidContent

		public void ConstructorOidContent () 
		{
			Oid o = new Oid (defaultOid);
			ContentInfo ci = new ContentInfo (o, asnNull);
			Assert.AreEqual (asnNull, ci.Content, "Content");
			Assert.AreEqual (defaultName, ci.ContentType.FriendlyName, "ContentType.FriendlyName");
			Assert.AreEqual (defaultOid, ci.ContentType.Value, "ContentType.Value");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:ContentInfoTest.cs


示例14: Oid

 public Oid(Oid oid)
 {
     if (oid == null)
         throw new ArgumentNullException(nameof(oid));
     _value = oid._value;
     _friendlyName = oid._friendlyName;
     _group = oid._group;
 }
开发者ID:Corillian,项目名称:corefx,代码行数:8,代码来源:Oid.cs


示例15: ConstructorOidKeyLength

		public void ConstructorOidKeyLength ()
		{
			Oid o = new Oid (validOid);
			AlgorithmIdentifier ai = new AlgorithmIdentifier (o, 128);
			Assert.AreEqual (128, ai.KeyLength, "KeyLength");
			Assert.AreEqual (validOid, ai.Oid.Value, "Oid");
			Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:AlgorithmIdentifierTest.cs


示例16: CryptographicAttributeObject

		// constructors

		public CryptographicAttributeObject (Oid oid) 
		{
			if (oid == null)
				throw new ArgumentNullException ("oid");

			_oid = new Oid (oid);
			_list = new AsnEncodedDataCollection ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CryptographicAttribute.cs


示例17: AsnEncodedData

		public AsnEncodedData (AsnEncodedData asnEncodedData)
		{
			if (asnEncodedData == null)
				throw new ArgumentNullException ("asnEncodedData");

			Oid = new Oid (asnEncodedData._oid);
			RawData = asnEncodedData._raw;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:AsnEncodedData.cs


示例18: CopyToOid

		public void CopyToOid () 
		{
			OidCollection oc = new OidCollection ();
			oc.Add (new Oid ("1.0"));
			Oid[] array = new Oid [1];
			oc.CopyTo (array, 0);
			Assert.AreEqual ("1.0", array [0].Value, "CopyTo(Oid)");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:OidCollectionTest.cs


示例19: ConstructorOidObject

		public void ConstructorOidObject () 
		{
			Oid o = new Oid (defaultOid);
			CryptographicAttribute ca = new CryptographicAttribute (o, o);
			Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
			Assert.AreEqual (1, ca.Values.Count, "Values");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:CryptographicAttributeTest.cs


示例20: ConstructorOidArray

		public void ConstructorOidArray () 
		{
			Oid o = new Oid (defaultOid);
			Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, new byte[0]);
			Assert.AreEqual (defaultName, a.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (defaultOid, a.Oid.Value, "Oid.Value");
			Assert.AreEqual (0, a.RawData.Length, "RawData");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:Pkcs9AttributeTest.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Cryptography.OidCollection类代码示例发布时间:2022-05-26
下一篇:
C# Cryptography.MD5CryptoServiceProvider类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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