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

C# Security.ASN1类代码示例

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

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



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

示例1: ProcessSpnegoInitialContextTokenRequest

		// Class(60) {
		//   OID(spnego),
		//   Class(A0) {
		//     Class(30) {
		//       Class(A0) {
		//         Class(30) { OID,OID,OID} },
		//       Class(A2) { OctetStream } } } }
		public byte [] ProcessSpnegoInitialContextTokenRequest ()
		{
			Type1Message type1 = new Type1Message (NtlmVersion.Version3);
			type1.Flags = unchecked ((NtlmFlags) 0xE21882B7);
			type1.Domain = "WORKGROUP"; // FIXME: remove it

			ASN1 asn = new ASN1 (0x60);
			ASN1 asn2 = new ASN1 (0xA0);
			ASN1 asn21 = new ASN1 (0x30);
			ASN1 asn211 = new ASN1 (0xA0);
			ASN1 asn2111 = new ASN1 (0x30);
			asn211.Add (asn2111);
			asn2111.Add (ASN1Convert.FromOid (Constants.OidNtlmSsp));
			asn2111.Add (ASN1Convert.FromOid (Constants.OidKerberos5));
			asn2111.Add (ASN1Convert.FromOid (Constants.OidMIT));
			ASN1 asn212 = new ASN1 (0xA2);
			ASN1 asn2121 = new ASN1 (0x4);
			asn2121.Value = type1.GetBytes ();
			asn212.Add (asn2121);
			asn21.Add (asn211);
			asn21.Add (asn212);
			asn2.Add (asn21);
			asn.Add (ASN1Convert.FromOid (Constants.OidSpnego));
			asn.Add (asn2);
			return asn.GetBytes ();
		}
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:SspiSession.cs


示例2: ConvertDateTimeInvalidButExistingFormat

		[Test]
		public void ConvertDateTimeInvalidButExistingFormat () 
		{
			string nosecs = "9912312359Z"; 
			ASN1 dt = new ASN1 (0x18, Encoding.ASCII.GetBytes (nosecs));
			DateTime actual = ASN1Convert.ToDateTime (dt);
			AssertEquals ("DateTime", nosecs, actual.ToUniversalTime ().ToString ("yyMMddHHmm") + "Z");
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:ASN1ConvertTest.cs


示例3: ToOid

        // Convert a binary encoded OID to human readable string representation of 
        // an OID (IETF style). Based on DUMPASN1.C from Peter Gutmann.
        static public string ToOid(ASN1 asn1)
        {
            if (asn1 == null)
                throw new ArgumentNullException("asn1");

            byte[] aOID = asn1.Value;
            StringBuilder sb = new StringBuilder();
            // Pick apart the OID
            byte x = (byte)(aOID[0] / 40);
            byte y = (byte)(aOID[0] % 40);
            if (x > 2)
            {
                // Handle special case for large y if x = 2
                y += (byte)((x - 2) * 40);
                x = 2;
            }
            sb.Append(x.ToString(CultureInfo.InvariantCulture));
            sb.Append(".");
            sb.Append(y.ToString(CultureInfo.InvariantCulture));
            ulong val = 0;
            for (x = 1; x < aOID.Length; x++)
            {
                val = ((val << 7) | ((byte)(aOID[x] & 0x7F)));
                if (!((aOID[x] & 0x80) == 0x80))
                {
                    sb.Append(".");
                    sb.Append(val.ToString(CultureInfo.InvariantCulture));
                    val = 0;
                }
            }
            return sb.ToString();
        }
开发者ID:javierpuntonet,项目名称:FacturaE,代码行数:34,代码来源:ASN1Convert.cs


示例4: AlgorithmIdentifier

		static public ASN1 AlgorithmIdentifier (string oid)
		{
			ASN1 ai = new ASN1 (0x30);
			ai.Add (ASN1Convert.FromOid (oid));
			ai.Add (new ASN1 (0x05));	// NULL
			return ai;
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:7,代码来源:PKCS7.cs


示例5: Decode

		protected override void Decode () 
		{
			ASN1 sequence = new ASN1 (extnValue.Value);
			if (sequence.Tag != 0x04)
				throw new ArgumentException ("Invalid SubjectKeyIdentifier extension");
			ski = sequence.Value;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:SubjectKeyIdentifierExtension.cs


示例6: GeneralNames

		public GeneralNames (ASN1 sequence)
		{
			for (int i = 0; i < sequence.Count; i++) {
				switch (sequence[i].Tag) {
				case 0x81: // rfc822Name			[1]	IA5String
					if (rfc822Name == null)
						rfc822Name = new ArrayList ();
					rfc822Name.Add (Encoding.ASCII.GetString (sequence[i].Value));
					break;
				case 0x82: // dNSName				[2]     IA5String
					if (dnsName == null)
						dnsName = new ArrayList ();
					dnsName.Add (Encoding.ASCII.GetString (sequence[i].Value));
					break;
				case 0x84: // directoryName			[4]     Name
				case 0xA4:
					if (directoryNames == null)
						directoryNames = new ArrayList ();
					directoryNames.Add (X501.ToString (sequence[i][0]));
					break;
				case 0x86:  // uniformResourceIdentifier	[6]     IA5String
					if (uris == null)
						uris = new ArrayList ();
					uris.Add (Encoding.ASCII.GetString (sequence[i].Value));
					break;
				case 0x87: // iPAddress				[7]     OCTET STRING
					if (ipAddr == null)
						ipAddr = new ArrayList ();
					// TODO - Must find sample certificates
					break;
				default:
					break;
				}
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:35,代码来源:GeneralNames.cs


示例7: Attribute

		static public ASN1 Attribute (string oid, ASN1 value) 
		{
			ASN1 attr = new ASN1 (0x30);
			attr.Add (ASN1Convert.FromOid (oid));
			ASN1 aset = attr.Add (new ASN1 (0x31));
			aset.Add (value);
			return attr;
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:8,代码来源:PKCS7.cs


示例8: Encode

		protected override void Encode () 
		{
			if (extnValue == null) {
				extnValue = new ASN1 (0x30);
				foreach (string oid in keyPurpose) {
					extnValue.Add (ASN1Convert.FromOid (oid));
				}
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:ExtendedKeyUsageExtension.cs


示例9: Encode

		protected override void Encode ()
		{
			if (ski == null) {
				throw new InvalidOperationException ("Invalid SubjectKeyIdentifier extension");
			}

			var seq = new ASN1 (0x04, ski);
			extnValue = new ASN1 (0x04);
			extnValue.Add (seq);
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:10,代码来源:SubjectKeyIdentifierExtension.cs


示例10: Decode

		protected override void Decode () 
		{
			keyPurpose = new ArrayList ();
			ASN1 sequence = new ASN1 (extnValue.Value);
			if (sequence.Tag != 0x30)
				throw new ArgumentException ("Invalid ExtendedKeyUsage extension");
			// for every policy OID
			for (int i=0; i < sequence.Count; i++)
				keyPurpose.Add (ASN1Convert.ToOid (sequence [i]));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:ExtendedKeyUsageExtension.cs


示例11: ConvertDateTimeInvalidButExistingFormat

		public void ConvertDateTimeInvalidButExistingFormat () 
		{
			string nosecs = "9912312359Z"; 
			ASN1 dt = new ASN1 (0x18, Encoding.ASCII.GetBytes (nosecs));
			DateTime actual = ASN1Convert.ToDateTime (dt);
#if NET_2_0
			Assert.AreEqual (DateTimeKind.Utc, actual.Kind, "Kind");
#endif
			Assert.AreEqual (nosecs, actual.ToUniversalTime ().ToString ("yyMMddHHmm") + "Z", "DateTime");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:ASN1ConvertTest.cs


示例12: Encode

		protected override void Encode () 
		{
			ASN1 seq = new ASN1 (0x30);
			foreach (string oid in keyPurpose) {
				seq.Add (ASN1Convert.FromOid (oid));
			}

			extnValue = new ASN1 (0x04);
			extnValue.Add (seq);
		}
开发者ID:sesef,项目名称:mono,代码行数:10,代码来源:ExtendedKeyUsageExtension.cs


示例13: X509ExtensionCollection

		public X509ExtensionCollection (ASN1 asn1) : this ()
		{
			readOnly = true;
			if (asn1 == null)
				return;
			if (asn1.Tag != 0x30)
				throw new Exception ("Invalid extensions format");
			for (int i=0; i < asn1.Count; i++) {
				X509Extension extension = new X509Extension (asn1 [i]);
				InnerList.Add (extension);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:X509Extensions.cs


示例14: ToString

		static public string ToString (ASN1 seq) 
		{
			StringBuilder sb = new StringBuilder ();
			for (int i = 0; i < seq.Count; i++) {
				ASN1 entry = seq [i];
				AppendEntry (sb, entry, true);

				// separator (not on last iteration)
				if (i < seq.Count - 1)
					sb.Append (", ");
			}
			return sb.ToString ();
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:13,代码来源:X501Name.cs


示例15: Decode

		protected override void Decode () 
		{
			// default values
			cA = false;
			pathLenConstraint = 0; // no constraint

			ASN1 sequence = new ASN1 (extnValue.Value);
			if (sequence.Tag != 0x30)
				throw new ArgumentException ("Invalid BasicConstraints extension");
			int n = 0;
			ASN1 a = sequence [n++];
			if ((a != null) && (a.Tag == 0x01)) {
				cA = (a.Value [0] == 0xFF);
				a = sequence [n++];
			}
			if ((a != null) && (a.Tag == 0x02))
				pathLenConstraint = ASN1Convert.ToInt32 (a);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:18,代码来源:BasicConstraintsExtension.cs


示例16: Decode

		protected override void Decode () 
		{
			ASN1 sequence = new ASN1 (extnValue.Value);
			if (sequence.Tag != 0x30)
				throw new ArgumentException ("Invalid AuthorityKeyIdentifier extension");
			for (int i=0; i < sequence.Count; i++) {
				ASN1 el = sequence [i];
				switch (el.Tag) {
					case 0x80:
						aki = el.Value;
						break;
					default:
						// don't throw on stuff we don't yet support
						// e.g. authorityCertIssuer/authorityCertSerialNumber
						break;
				}
			}
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:18,代码来源:AuthorityKeyIdentifierExtension.cs


示例17: Decode

		protected override void Decode () 
		{
			ASN1 sequence = new ASN1 (extnValue.Value);
			if (sequence.Tag != 0x30)
				throw new ArgumentException ("Invalid AuthorityKeyIdentifier extension");
			for (int i=0; i < sequence.Count; i++) {
				ASN1 el = sequence [i];
				switch (el.Tag) {
					case 0x80:
						aki = el.Value;
						break;
					case 0x81:
					case 0x82:
					default:
						throw new ArgumentException ("Invalid AuthorityKeyIdentifier extension");
				}
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:18,代码来源:AuthorityKeyIdentifierExtension.cs


示例18: Decode

		protected override void Decode () 
		{
			ASN1 sequence = new ASN1 (extnValue.Value);
			if (sequence.Tag != 0x30)
				throw new ArgumentException ("Invalid PrivateKeyUsagePeriod extension");
			for (int i=0; i < sequence.Count; i++) {
				switch (sequence [i].Tag) {
					case 0x80:
						notBefore = ASN1Convert.ToDateTime (sequence [i]);
						break;
					case 0x81:
						notAfter = ASN1Convert.ToDateTime (sequence [i]);
						break;
					default:
						throw new ArgumentException ("Invalid PrivateKeyUsagePeriod extension");
				}
			}
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:18,代码来源:PrivateKeyUsagePeriodExtension.cs


示例19: Decode

		protected override void Decode () 
		{
			ASN1 seq = new ASN1 (extnValue.Value);
			if (seq.Tag != 0x30)
				throw new ArgumentException ("Invalid KeyAttributesExtension extension");
			int n = 0;
			// check for KeyIdentifier
			if (n < seq.Count) {
				ASN1 item = seq [n];
				if (item.Tag == 0x04) {
					n++;
					keyId = item.Value;
				}
			}
			// check for KeyUsage
			if (n < seq.Count) {
				ASN1 item = seq [n];
				if (item.Tag == 0x03) {
					n++;
					int i = 1; // byte zero has the number of unused bits (ASN1's BITSTRING)
					while (i < item.Value.Length)
						kubits = (kubits << 8) + item.Value [i++];
				}
			}
			// check for PrivateKeyValidity
			if (n < seq.Count) {
				ASN1 item = seq [n];
				if (item.Tag == 0x30) {
					int i = 0;
					if (i < item.Count) {
						ASN1 dt = item [i];
						if (dt.Tag == 0x81) {
							i++;
							notBefore = ASN1Convert.ToDateTime (dt);
						}
					}
					if (i < item.Count) {
						ASN1 dt = item [i];
						if (dt.Tag == 0x82)
							notAfter = ASN1Convert.ToDateTime (dt);
					}
				}
			}
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:44,代码来源:KeyAttributesExtension.cs


示例20: GeneralNames

		public GeneralNames (string[] rfc822s, string[] dnsNames, string[] ipAddresses, string[] uris)
		{
			// This is an extension
			asn = new ASN1 (0x30);

			if (rfc822s != null) {
				rfc822Name = new ArrayList ();
				foreach (string rfc822 in rfc822s) {
					asn.Add (new ASN1 (0x81, Encoding.ASCII.GetBytes (rfc822)));
					rfc822Name.Add (rfc822s);
				}
			}

			if (dnsNames != null) {
				dnsName = new ArrayList ();
				foreach (string dnsname in dnsNames) {
					asn.Add (new ASN1 (0x82, Encoding.ASCII.GetBytes (dnsname)));
					dnsName.Add(dnsname);
				}
			}

			if (ipAddresses != null) {
				ipAddr = new ArrayList ();
				foreach (string ipaddress in ipAddresses) {
					string[] parts = ipaddress.Split ('.', ':');
					byte[] bytes = new byte[parts.Length];
					for (int i = 0; i < parts.Length; i++) {
						bytes[i] = Byte.Parse (parts[i]);
					}
					asn.Add (new ASN1 (0x87, bytes));
					ipAddr.Add (ipaddress);
				}
			}

			if (uris != null) {
				this.uris = new ArrayList();
				foreach (string uri in uris) {
					asn.Add (new ASN1 (0x86, Encoding.ASCII.GetBytes (uri)));
					this.uris.Add (uri);
				}
			}
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:42,代码来源:GeneralNames.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Interface.MonoTlsSettings类代码示例发布时间:2022-05-26
下一篇:
C# Math.BigInteger类代码示例发布时间: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