private CertOrEncCert(Asn1TaggedObject tagged) { if (tagged.TagNo == 0) { certificate = CmpCertificate.GetInstance(tagged.GetObject()); } else if (tagged.TagNo == 1) { encryptedCert = EncryptedValue.GetInstance(tagged.GetObject()); } else { throw new ArgumentException("unknown tag: " + tagged.TagNo, "tagged"); } }
public static DirectoryString GetInstance( Asn1TaggedObject obj, bool isExplicit) { if (!isExplicit) throw new ArgumentException("choice item must be explicitly tagged"); return GetInstance(obj.GetObject()); }
public static RequestedCertificate GetInstance( Asn1TaggedObject obj, bool isExplicit) { if (!isExplicit) throw new ArgumentException("choice item must be explicitly tagged"); return GetInstance(obj.GetObject()); }
/** * return an OriginatorIdentifierOrKey object from a tagged object. * * @param o the tagged object holding the object we want. * @param explicitly true if the object is meant to be explicitly * tagged false otherwise. * @exception ArgumentException if the object held by the * tagged object cannot be converted. */ public static OriginatorIdentifierOrKey GetInstance( Asn1TaggedObject o, bool explicitly) { if (!explicitly) { throw new ArgumentException( "Can't implicitly tag OriginatorIdentifierOrKey"); } return GetInstance(o.GetObject()); }
private PkiArchiveOptions(Asn1TaggedObject tagged) { switch (tagged.TagNo) { case encryptedPrivKey: value = EncryptedKey.GetInstance(tagged.GetObject()); break; case keyGenParameters: value = Asn1OctetString.GetInstance(tagged, false); break; case archiveRemGenPrivKey: value = DerBoolean.GetInstance(tagged, false); break; default: throw new ArgumentException("unknown tag number: " + tagged.TagNo, "tagged"); } }
public static Time GetInstance( Asn1TaggedObject obj, bool explicitly) { return GetInstance(obj.GetObject()); }
public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit) { return new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged.GetObject())); }
private PkiBody(Asn1TaggedObject tagged) { tagNo = tagged.TagNo; body = GetBodyForType(tagNo, tagged.GetObject()); }
public static ResponderID GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(obj.GetObject())); // must be explicitly tagged }
public static AttCertIssuer GetInstance( Asn1TaggedObject obj, bool isExplicit) { return GetInstance(obj.GetObject()); // must be explictly tagged }
/** * dump a Der object as a formatted string with indentation * * @param obj the Asn1Object to be dumped out. */ private static void AsString( string indent, bool verbose, Asn1Object obj, StringBuilder buf) { if (obj is Asn1Sequence) { string tab = indent + Tab; buf.Append(indent); if (obj is BerSequence) { buf.Append("BER Sequence"); } else if (obj is DerSequence) { buf.Append("DER Sequence"); } else { buf.Append("Sequence"); } buf.Append(NewLine); foreach (Asn1Encodable o in ((Asn1Sequence)obj)) { if (o == null || o is Asn1Null) { buf.Append(tab); buf.Append("NULL"); buf.Append(NewLine); } else { AsString(tab, verbose, o.ToAsn1Object(), buf); } } } else if (obj is Asn1TaggedObject) { string tab = indent + Tab; buf.Append(indent); if (obj is BerTaggedObject) { buf.Append("BER Tagged ["); } else { buf.Append("Tagged ["); } Asn1TaggedObject o = (Asn1TaggedObject)obj; buf.Append(((int)o.TagNo).ToString()); buf.Append(']'); if (!o.IsExplicit()) { buf.Append(" IMPLICIT "); } buf.Append(NewLine); if (o.IsEmpty()) { buf.Append(tab); buf.Append("EMPTY"); buf.Append(NewLine); } else { AsString(tab, verbose, o.GetObject(), buf); } } else if (obj is BerSet) { string tab = indent + Tab; buf.Append(indent); buf.Append("BER Set"); buf.Append(NewLine); foreach (Asn1Encodable o in ((Asn1Set)obj)) { if (o == null) { buf.Append(tab); buf.Append("NULL"); buf.Append(NewLine); } else { AsString(tab, verbose, o.ToAsn1Object(), buf); } } } else if (obj is DerSet) { string tab = indent + Tab; buf.Append(indent); buf.Append("DER Set"); buf.Append(NewLine); foreach (Asn1Encodable o in ((Asn1Set)obj)) { if (o == null) { buf.Append(tab); buf.Append("NULL"); buf.Append(NewLine); } else { AsString(tab, verbose, o.ToAsn1Object(), buf); } } } else if (obj is DerObjectIdentifier) { buf.Append(indent + "ObjectIdentifier(" + ((DerObjectIdentifier)obj).Id + ")" + NewLine); } else if (obj is DerBoolean) { buf.Append(indent + "Boolean(" + ((DerBoolean)obj).IsTrue + ")" + NewLine); } else if (obj is DerInteger) { buf.Append(indent + "Integer(" + ((DerInteger)obj).Value + ")" + NewLine); } else if (obj is BerOctetString) { byte[] octets = ((Asn1OctetString)obj).GetOctets(); string extra = verbose ? dumpBinaryDataAsString(indent, octets) : ""; buf.Append(indent + "BER Octet String" + "[" + octets.Length + "] " + extra + NewLine); } else if (obj is DerOctetString) { byte[] octets = ((Asn1OctetString)obj).GetOctets(); string extra = verbose ? dumpBinaryDataAsString(indent, octets) : ""; buf.Append(indent + "DER Octet String" + "[" + octets.Length + "] " + extra + NewLine); } else if (obj is DerBitString) { DerBitString bt = (DerBitString)obj; byte[] bytes = bt.GetBytes(); string extra = verbose ? dumpBinaryDataAsString(indent, bytes) : ""; buf.Append(indent + "DER Bit String" + "[" + bytes.Length + ", " + bt.PadBits + "] " + extra + NewLine); } else if (obj is DerIA5String) { buf.Append(indent + "IA5String(" + ((DerIA5String)obj).GetString() + ") " + NewLine); } else if (obj is DerUtf8String) { buf.Append(indent + "UTF8String(" + ((DerUtf8String)obj).GetString() + ") " + NewLine); } else if (obj is DerPrintableString) { buf.Append(indent + "PrintableString(" + ((DerPrintableString)obj).GetString() + ") " + NewLine); } else if (obj is DerVisibleString) { buf.Append(indent + "VisibleString(" + ((DerVisibleString)obj).GetString() + ") " + NewLine); } else if (obj is DerBmpString) { buf.Append(indent + "BMPString(" + ((DerBmpString)obj).GetString() + ") " + NewLine); } else if (obj is DerT61String) { buf.Append(indent + "T61String(" + ((DerT61String)obj).GetString() + ") " + NewLine); } else if (obj is DerGraphicString) { buf.Append(indent + "GraphicString(" + ((DerGraphicString)obj).GetString() + ") " + NewLine); } else if (obj is DerVideotexString) { buf.Append(indent + "VideotexString(" + ((DerVideotexString)obj).GetString() + ") " + NewLine); } else if (obj is DerUtcTime) { buf.Append(indent + "UTCTime(" + ((DerUtcTime)obj).TimeString + ") " + NewLine); } else if (obj is DerGeneralizedTime) { buf.Append(indent + "GeneralizedTime(" + ((DerGeneralizedTime)obj).GetTime() + ") " + NewLine); } else if (obj is BerApplicationSpecific) { buf.Append(outputApplicationSpecific("BER", indent, verbose, (BerApplicationSpecific)obj)); } else if (obj is DerApplicationSpecific) { buf.Append(outputApplicationSpecific("DER", indent, verbose, (DerApplicationSpecific)obj)); } else if (obj is DerEnumerated) { DerEnumerated en = (DerEnumerated)obj; buf.Append(indent + "DER Enumerated(" + en.Value + ")" + NewLine); } else if (obj is DerExternal) { DerExternal ext = (DerExternal)obj; buf.Append(indent + "External " + NewLine); string tab = indent + Tab; if (ext.DirectReference != null) { buf.Append(tab + "Direct Reference: " + ext.DirectReference.Id + NewLine); } if (ext.IndirectReference != null) { buf.Append(tab + "Indirect Reference: " + ext.IndirectReference.ToString() + NewLine); } if (ext.DataValueDescriptor != null) { AsString(tab, verbose, ext.DataValueDescriptor, buf); } buf.Append(tab + "Encoding: " + ext.Encoding + NewLine); AsString(tab, verbose, ext.ExternalContent, buf); } else { buf.Append(indent + obj.ToString() + NewLine); } }
public static AttCertIssuer GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(obj.GetObject())); // must be explictly tagged }
public static Time GetInstance(Asn1TaggedObject obj, bool explicitly) => GetInstance(obj.GetObject());
public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit) { return(new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged.GetObject()))); }