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


C# Asn1InputStream.Close方法代碼示例

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


在下文中一共展示了Asn1InputStream.Close方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DecodeFromDer

        public static EcdsaSignature DecodeFromDer(byte[] bytes)
        {
            try
            {
                var decoder = new Asn1InputStream(bytes);
                var seq = (Asn1Sequence)decoder.ReadObject();
                DerInteger r, s;
                try
                {
                    r = (DerInteger)seq[0];
                    s = (DerInteger)seq[1];
                }
                catch (InvalidCastException)
                {
                    return null;
                }
                decoder.Close();

                // OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be
                // Thus, we always use the positive versions. See: http://r6.ca/blog/20111119T211504Z.html
                return new EcdsaSignature(r.PositiveValue, s.PositiveValue);
            }
            catch (IOException e)
            {
                throw new ApplicationException("Decoding form DER failed", e);
            }
        }
開發者ID:kueiwa,項目名稱:ripple-cs,代碼行數:27,代碼來源:EcdsaSignature.cs

示例2: Main

        public static void Main(string[] args)
        {
            FileStream fIn = File.OpenRead(args[0]);
            Asn1InputStream bIn = new Asn1InputStream(fIn);

			Asn1Object obj;
			while ((obj = bIn.ReadObject()) != null)
            {
                Console.WriteLine(Asn1Dump.DumpAsString(obj));
            }

			bIn.Close();
        }
開發者ID:htlp,項目名稱:itextsharp,代碼行數:13,代碼來源:Dump.cs

示例3: DumpDer

 public static string DumpDer(byte[] der)
 {
     StringBuilder builder = new StringBuilder();
     Asn1InputStream decoder = new Asn1InputStream(der);
     DerSequence seq = (DerSequence)decoder.ReadObject();
     builder.AppendLine("Version : " + Encoders.Hex.EncodeData(seq[0].GetDerEncoded()));
     builder.AppendLine("Private : " + Encoders.Hex.EncodeData(seq[1].GetDerEncoded()));
     builder.AppendLine("Params : " + Encoders.Hex.EncodeData(((DerTaggedObject)seq[2]).GetObject().GetDerEncoded()));
     builder.AppendLine("Public : " + Encoders.Hex.EncodeData(seq[3].GetDerEncoded()));
     decoder.Close();
     return builder.ToString();
 }
開發者ID:nikropht,項目名稱:NBitcoin,代碼行數:12,代碼來源:ECKey.cs

示例4: FromDER

        public static ECKey FromDER(byte[] der)
        {
            // To understand this code, see the definition of the ASN.1 format for EC private keys in the OpenSSL source
            // code in ec_asn1.c:
            //
            // ASN1_SEQUENCE(EC_PRIVATEKEY) = {
            //   ASN1_SIMPLE(EC_PRIVATEKEY, version, LONG),
            //   ASN1_SIMPLE(EC_PRIVATEKEY, privateKey, ASN1_OCTET_STRING),
            //   ASN1_EXP_OPT(EC_PRIVATEKEY, parameters, ECPKPARAMETERS, 0),
            //   ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1)
            // } ASN1_SEQUENCE_END(EC_PRIVATEKEY)
            //

            Asn1InputStream decoder = new Asn1InputStream(der);
            DerSequence seq = (DerSequence)decoder.ReadObject();
            CheckArgument(seq.Count == 4, "Input does not appear to be an ASN.1 OpenSSL EC private key");
            CheckArgument(((DerInteger)seq[0]).Value.Equals(BigInteger.One),
                    "Input is of wrong version");
            byte[] bits = ((DerOctetString)seq[1]).GetOctets();
            decoder.Close();
            return new ECKey(bits, true);
        }
開發者ID:nikropht,項目名稱:NBitcoin,代碼行數:22,代碼來源:ECKey.cs


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