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


C# Asn1.DerOutputStream類代碼示例

本文整理匯總了C#中Org.BouncyCastle.Asn1.DerOutputStream的典型用法代碼示例。如果您正苦於以下問題:C# DerOutputStream類的具體用法?C# DerOutputStream怎麽用?C# DerOutputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DerOutputStream類屬於Org.BouncyCastle.Asn1命名空間,在下文中一共展示了DerOutputStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Encode

        internal override void Encode(
            DerOutputStream derOut)
        {
            if (derOut is Asn1OutputStream || derOut is BerOutputStream)
            {
                derOut.WriteByte(Asn1Tags.Constructed | Asn1Tags.OctetString);

                derOut.WriteByte(0x80);

                //
                // write out the octet array
                //
                foreach (DerOctetString oct in this)
                {
                    derOut.WriteObject(oct);
                }

                derOut.WriteByte(0x00);
                derOut.WriteByte(0x00);
            }
            else
            {
                base.Encode(derOut);
            }
        }
開發者ID:Noyabronok,項目名稱:itextsharpml,代碼行數:25,代碼來源:BerOctetString.cs

示例2: OpenStream

		/// <exception cref="System.IO.IOException"></exception>
		public virtual Stream OpenStream()
		{
            Stream output = new MemoryStream();
			DerOutputStream derOuput = new DerOutputStream(output);
			derOuput.WriteObject(Asn1Object.FromByteArray(signedData.GetEncoded()));
            output.Seek(0, SeekOrigin.Begin);
			return output;
		}
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:9,代碼來源:CMSSignedDocument.cs

示例3: Encode

		internal override void Encode(
			DerOutputStream derOut)
		{
			if (derOut is Asn1OutputStream || derOut is BerOutputStream)
			{
				derOut.WriteTag((byte)(Asn1Tags.Constructed | Asn1Tags.Tagged), tagNo);
				derOut.WriteByte(0x80);

				if (!IsEmpty())
				{
					if (!explicitly)
					{
						IEnumerable eObj;
						if (obj is Asn1OctetString)
						{
							if (obj is BerOctetString)
							{
								eObj = (BerOctetString) obj;
							}
							else
							{
								Asn1OctetString octs = (Asn1OctetString)obj;
								eObj = new BerOctetString(octs.GetOctets());
							}
						}
						else if (obj is Asn1Sequence)
						{
							eObj = (Asn1Sequence) obj;
						}
						else if (obj is Asn1Set)
						{
							eObj = (Asn1Set) obj;
						}
						else
						{
							throw Platform.CreateNotImplementedException(obj.GetType().Name);
						}

						foreach (Asn1Encodable o in eObj)
						{
							derOut.WriteObject(o);
						}
					}
					else
					{
						derOut.WriteObject(obj);
					}
				}

				derOut.WriteByte(0x00);
				derOut.WriteByte(0x00);
			}
			else
			{
				base.Encode(derOut);
			}
		}
開發者ID:MBrekhof,項目名稱:pleiobox-clients,代碼行數:57,代碼來源:BerTaggedObject.cs

示例4: BufferedBerOctetStream

			internal BufferedBerOctetStream(
				BerOctetStringGenerator	gen,
				byte[]					buf)
			{
				_gen = gen;
				_buf = buf;
				_off = 0;
				_derOut = new DerOutputStream(_gen.Out);
			}
開發者ID:MBrekhof,項目名稱:pleiobox-clients,代碼行數:9,代碼來源:BEROctetStringGenerator.cs

示例5: Encode

		internal override void Encode(
			DerOutputStream  derOut)
		{
			if (derOut is Asn1OutputStream || derOut is BerOutputStream)
			{
				derOut.WriteByte(Asn1Tags.Null);
			}
			else
			{
				base.Encode(derOut);
			}
		}
開發者ID:htlp,項目名稱:itextsharp,代碼行數:12,代碼來源:BerNull.cs

示例6: Encode

 internal override void Encode(
     DerOutputStream derOut)
 {
     if (derOut is Asn1OutputStream || derOut is BerOutputStream)
     {
         derOut.WriteEncoded(Asn1Tags.BitString, (byte)mPadBits, mData);
     }
     else
     {
         base.Encode(derOut);
     }
 }
開發者ID:KimikoMuffin,項目名稱:bc-csharp,代碼行數:12,代碼來源:BERBitString.cs

示例7: Encode

        internal override void Encode(
			DerOutputStream derOut)
        {
            if (parsed)
            {
                base.Encode(derOut);
            }
            else
            {
                derOut.WriteEncoded(Asn1Tags.Set | Asn1Tags.Constructed, encoded);
            }
        }
開發者ID:Noyabronok,項目名稱:itextsharpml,代碼行數:12,代碼來源:LazyDERSet.cs

示例8: Encode

		internal override void Encode(
			DerOutputStream derOut)
		{
			lock (this)
			{
				if (encoded == null)
				{
					base.Encode(derOut);
				}
				else
				{
					derOut.WriteEncoded(Asn1Tags.Sequence | Asn1Tags.Constructed, encoded);
				}
			}
		}
開發者ID:JohnMalmsteen,項目名稱:mobile-apps-tower-defense,代碼行數:15,代碼來源:LazyDERSequence.cs

示例9: GetEncoded

		public byte[] GetEncoded(
			string encoding)
		{
			if (encoding.Equals(Der))
			{
				MemoryStream bOut = new MemoryStream();
				DerOutputStream dOut = new DerOutputStream(bOut);

				dOut.WriteObject(this);

				return bOut.ToArray();
			}

			return GetEncoded();
		}
開發者ID:htlp,項目名稱:itextsharp,代碼行數:15,代碼來源:Asn1Encodable.cs

示例10: Encode

        /*
         * A note on the implementation:
         * <p>
         * As Der requires the constructed, definite-length model to
         * be used for structured types, this varies slightly from the
         * ASN.1 descriptions given. Rather than just outputing Set,
         * we also have to specify Constructed, and the objects length.
         */
        internal override void Encode(
            DerOutputStream derOut)
        {
            MemoryStream bOut = new MemoryStream();
            DerOutputStream dOut = new DerOutputStream(bOut);

            foreach (object obj in this)
            {
                dOut.WriteObject(obj);
            }

            dOut.Close();

            byte[] bytes = bOut.ToArray();

            derOut.WriteEncoded(Asn1Tags.Set | Asn1Tags.Constructed, bytes);
        }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:25,代碼來源:DerSet.cs

示例11: Encode

		/*
		 * A note on the implementation:
		 * <p>
		 * As Der requires the constructed, definite-length model to
		 * be used for structured types, this varies slightly from the
		 * ASN.1 descriptions given. Rather than just outputing Sequence,
		 * we also have to specify Constructed, and the objects length.
		 */
		internal override void Encode(
			DerOutputStream derOut)
		{
			// TODO Intermediate buffer could be avoided if we could calculate expected length
			MemoryStream bOut = new MemoryStream();
			DerOutputStream dOut = new DerOutputStream(bOut);

			foreach (Asn1Encodable obj in this)
			{
				dOut.WriteObject(obj);
			}

			dOut.Dispose();

			byte[] bytes = bOut.ToArray();

			derOut.WriteEncoded(Asn1Tags.Sequence | Asn1Tags.Constructed, bytes);
		}
開發者ID:JohnMalmsteen,項目名稱:mobile-apps-tower-defense,代碼行數:26,代碼來源:DerSequence.cs

示例12: Encode

        internal override void Encode(
            DerOutputStream derOut)
        {
            if (derOut is Asn1OutputStream || derOut is BerOutputStream)
            {
                derOut.WriteByte(Asn1Tags.Constructed | Asn1Tags.OctetString);

                derOut.WriteByte(0x80);

                //
                // write out the octet array
                //
                if (octs != null)
                {
                    for (int i = 0; i != octs.Count; i++)
                    {
                        derOut.WriteObject(octs[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < str.Length; i += MaxLength)
                    {
                        int end = System.Math.Min(str.Length, i + MaxLength);

                        byte[] nStr = new byte[end - i];

                        Array.Copy(str, i, nStr, 0, nStr.Length);

                        derOut.WriteObject(new DerOctetString(nStr));
                    }
                }

                derOut.WriteByte(0x00);
                derOut.WriteByte(0x00);
            }
            else
            {
                base.Encode(derOut);
            }
        }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:41,代碼來源:BerOctetString.cs

示例13: Encode

 internal override void Encode(DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.VideotexString, mString);
 }
開發者ID:KimikoMuffin,項目名稱:bc-csharp,代碼行數:4,代碼來源:DerVideotexString.cs

示例14: Encode

        /*
         * A note on the implementation:
         * <p>
         * As Der requires the constructed, definite-length model to
         * be used for structured types, this varies slightly from the
         * ASN.1 descriptions given. Rather than just outputing Set,
         * we also have to specify Constructed, and the objects length.
         */
        internal override void Encode(DerOutputStream derOut)
        {
            // TODO Intermediate buffer could be avoided if we could calculate expected length
            using (var bOut = new MemoryStream())
            {
                using (var dOut = new DerOutputStream(bOut))
                {
                    foreach (Asn1Encodable obj in this)
                    {
                        dOut.WriteObject(obj);
                    }
                }

                var bytes = bOut.ToArray();

                derOut.WriteEncoded(Asn1Tags.Set | Asn1Tags.Constructed, bytes);
            }
        }
開發者ID:sanyaade-iot,項目名稱:Schmoose-BouncyCastle,代碼行數:26,代碼來源:DerSet.cs

示例15: GetEncodedRecipient

        virtual public byte[] GetEncodedRecipient(int index) {
            //Certificate certificate = recipient.GetX509();
            PdfPublicKeyRecipient recipient = recipients[index];
            byte[] cms = recipient.Cms;
            
            if (cms != null) return cms;
            
            X509Certificate certificate  = recipient.Certificate;
            int permission =  recipient.Permission;//PdfWriter.AllowCopy | PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | PdfWriter.AllowAssembly;   
            int revision = 3;
            
            permission |= (int)(revision==3 ? (uint)0xfffff0c0 : (uint)0xffffffc0);
            permission &= unchecked((int)0xfffffffc);
            permission += 1;
          
            byte[] pkcs7input = new byte[24];
            
            byte one = (byte)(permission);
            byte two = (byte)(permission >> 8);
            byte three = (byte)(permission >> 16);
            byte four = (byte)(permission >> 24);

            System.Array.Copy(seed, 0, pkcs7input, 0, 20); // put this seed in the pkcs7 input
                                
            pkcs7input[20] = four;
            pkcs7input[21] = three;                
            pkcs7input[22] = two;
            pkcs7input[23] = one;

            Asn1Object obj = CreateDERForRecipient(pkcs7input, certificate);
                
            MemoryStream baos = new MemoryStream();
                
            DerOutputStream k = new DerOutputStream(baos);
                
            k.WriteObject(obj);  
            
            cms = baos.ToArray();

            recipient.Cms = cms;
            
            return cms;    
        }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:43,代碼來源:PdfPublicKeySecurityHandler.cs


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