static private CreatePrimitiveDerObject ( int tagNo, |
||
tagNo | int | |
defIn | ||
tmpBuffers | byte | |
리턴 |
internal static Asn1Object CreatePrimitiveDerObject(
int tagNo,
DefiniteLengthInputStream defIn,
byte[][] tmpBuffers)
{
switch (tagNo)
{
case Asn1Tags.Boolean:
return new DerBoolean(GetBuffer(defIn, tmpBuffers));
case Asn1Tags.Enumerated:
return new DerEnumerated(GetBuffer(defIn, tmpBuffers));
case Asn1Tags.ObjectIdentifier:
return DerObjectIdentifier.FromOctetString(GetBuffer(defIn, tmpBuffers));
}
byte[] bytes = defIn.ToArray();
switch (tagNo)
{
case Asn1Tags.BitString:
return DerBitString.FromAsn1Octets(bytes);
case Asn1Tags.BmpString:
return new DerBmpString(bytes);
case Asn1Tags.GeneralizedTime:
return new DerGeneralizedTime(bytes);
case Asn1Tags.GeneralString:
return new DerGeneralString(bytes);
case Asn1Tags.IA5String:
return new DerIA5String(bytes);
case Asn1Tags.Integer:
return new DerInteger(bytes);
case Asn1Tags.Null:
return DerNull.Instance; // actual content is ignored (enforce 0 length?)
case Asn1Tags.NumericString:
return new DerNumericString(bytes);
case Asn1Tags.OctetString:
return new DerOctetString(bytes);
case Asn1Tags.PrintableString:
return new DerPrintableString(bytes);
case Asn1Tags.T61String:
return new DerT61String(bytes);
case Asn1Tags.UniversalString:
return new DerUniversalString(bytes);
case Asn1Tags.UtcTime:
return new DerUtcTime(bytes);
case Asn1Tags.Utf8String:
return new DerUtf8String(bytes);
case Asn1Tags.VisibleString:
return new DerVisibleString(bytes);
default:
return new DerUnknownTag(false, tagNo, bytes);
}
}
}
private Asn1Object BuildObject(int tag, int tagNo, int length) { bool flag = (tag & 32) != 0; DefiniteLengthInputStream definiteLengthInputStream = new DefiniteLengthInputStream(this.s, length); if ((tag & 64) != 0) { return(new DerApplicationSpecific(flag, tagNo, definiteLengthInputStream.ToArray())); } if ((tag & 128) != 0) { return(new Asn1StreamParser(definiteLengthInputStream).ReadTaggedObject(flag, tagNo)); } if (!flag) { return(Asn1InputStream.CreatePrimitiveDerObject(tagNo, definiteLengthInputStream, this.tmpBuffers)); } if (tagNo == 4) { return(new BerOctetString(this.BuildDerEncodableVector(definiteLengthInputStream))); } if (tagNo == 8) { return(new DerExternal(this.BuildDerEncodableVector(definiteLengthInputStream))); } switch (tagNo) { case 16: return(this.CreateDerSequence(definiteLengthInputStream)); case 17: return(this.CreateDerSet(definiteLengthInputStream)); default: throw new IOException("unknown tag " + tagNo + " encountered"); } }