/// <summary> /// Calculates length of ASN.1 object /// </summary> /// <param name="value">Content of ASN.1 object.</param> /// <param name="asn1Type">Type of ASN.1 object. In some types there has to be an octet before content bytes.</param> /// <returns>Encoded length of ASN.1 object.</returns> internal static byte[] WriteLength(IEnumerable <byte> value, Asn1Type asn1Type) { var length = value.Count(); if (asn1Type == Asn1Type.BitString) { length++; // count unused bits in } byte[] lengthOctets = null; if (length <= 127) { lengthOctets = new byte[1] { (byte)length }; } else { var lengthValueOctets = BitConverter.GetBytes(length); // TODO: fix incorrect length computation lengthValueOctets = lengthValueOctets.Reverse().SkipWhile(p => p == 0x00).ToArray(); byte firstLengthByte = (byte)(0x80 | lengthValueOctets.Length); lengthOctets = new byte[lengthValueOctets.Length + 1]; lengthOctets[0] = firstLengthByte; Array.Copy(lengthValueOctets, 0, lengthOctets, 1, lengthValueOctets.Length); } return(lengthOctets); }
public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { var elemLength = explicitTagging ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength; Algorithm = null; Parameters = null; var context = new Asn1BerDecodeContext(buffer, elemLength); var parsedLen = new IntHolder(); if (!context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } Algorithm = new Asn1ObjectIdentifier(); Algorithm.Decode(buffer, true, parsedLen.Value); if (!context.Expired()) { Parameters = new Asn1OpenType(); Parameters.Decode(buffer, true, 0); } CheckAlg(true); }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNextAndExpectTags((Byte)Asn1Type.OBJECT_IDENTIFIER); Oid = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); asn.MoveNext(); Asn1Type[] types = { Asn1Type.IA5String, Asn1Type.PrintableString, Asn1Type.VisibleString, Asn1Type.UTF8String, Asn1Type.UniversalString, Asn1Type.BMPString, Asn1Type.TeletexString }; encodingTag = (Asn1Type)asn.Tag; Value = Asn1Utils.DecodeAnyString(asn.GetTagRawData(), types); RawData = rawData; }
public static void PrintCIsConstraintValid(Asn1Type pThis, PEREffectiveConstraint cns, StreamWriterLevel c, string errorCode, string typeName, string varName, int lev, int arrayDepth) { string varName2 = varName; if (!varName.Contains("->")) varName2 = "*" + varName; if (pThis.m_constraints.Count > 0) { c.P(lev); c.Write("if ( !("); for (int i = 0; i < pThis.m_constraints.Count; i++) { string ret = ((ISCConstraint)pThis.m_constraints[i]).PrintCIsConstraintValid(varName2, lev); c.Write(ret); if (i != pThis.m_constraints.Count - 1) c.Write(" && "); } c.WriteLine(") ) {"); c.P(lev + 1); c.WriteLine("*pErrCode = ERR_{0};", C.ID(errorCode)); c.P(lev + 1); c.WriteLine("return FALSE;"); c.P(lev); c.WriteLine("}"); } }
private void CheckAlg(bool decode) { AlgorithmId algorithmId = null; foreach (var alg in PkiConstants.SupportedAlgorithms) { if (alg.Id.Equals(Algorithm)) { algorithmId = alg; break; } } if ((algorithmId != null) && ((decode && (Parameters != null)) && (algorithmId.Type != null))) { try { var buffer = new Asn1BerDecodeBuffer(((Asn1OpenType)Parameters).Value); Parameters = (Asn1Type)Activator.CreateInstance(algorithmId.Type.GetType()); Parameters.Decode(buffer, true, 0); buffer.InvokeEndElement("parameters", -1); } catch (Exception exception) { Asn1Util.WriteStackTrace(exception, Console.Error); throw ExceptionUtility.CryptographicException(Resources.Asn1TableConstraint); } } }
public override bool Compatible(Asn1Type other) { ObjectIdentifier o = other.GetFinalType() as ObjectIdentifier; if (o == null) return false; return true; }
public ALGORITHM_ID( Asn1ObjectIdentifier id_, Asn1Type Type_ ) { id = id_; Type = Type_; }
public static CharSet FullSet(Asn1Type type) { IStringType strType = type as IStringType; if (strType == null) throw new Exception("Internal Error"); return new CharSet(new List<char>(strType.AllowedCharSet)); }
/// <summary> /// This constructor allows primitive data to be passed for all /// primitive elements. It will create new object wrappers for /// the primitive data and set other elements to references to /// the given objects /// </summary> public AlgorithmIdentifier(int[] algorithm_, Asn1Type parameters_ ) : base() { algorithm = new Asn1ObjectIdentifier(algorithm_); parameters = parameters_; }
void m_initizlie(Oid oid, String value, Asn1Type tag) { // dc -- IA5 String only // E -- IA5String only switch (oid.Value) { } }
public ATTRIBUTE_CLASS( Asn1Type Type_, Asn1ObjectIdentifier id_ ) { Type = Type_; id = id_; }
/// <summary> /// This constructor sets all elements to references to the /// given objects /// </summary> public AlgorithmIdentifier( Asn1ObjectIdentifier algorithm_, Asn1Type parameters_ ) : base() { algorithm = algorithm_; parameters = parameters_; }
public static List <Byte> GetAlphabet(Asn1Type type) { switch (type) { case Asn1Type.PrintableString: return(generatePrintableStringAlphabet()); } throw new ArgumentException("Invalid string type is specified."); }
/// <summary> /// Assert end of Constructed type of node, i.e. SEQUENCE, SET. Then move to next node. /// </summary> /// <param name="reader">BerReader instance.</param> /// <param name="level">Depth of node in ASN.1 structure.</param> /// <param name="type">Type of given node to assert.</param> private static void AssertReadEnd(BerReader reader, int level, Asn1Type type) { Assert.AreEqual(level, reader.Depth, "Depth"); Assert.AreEqual(Asn1NodeType.ConstructedEnd, reader.CurrentNode.NodeType, "Node Tag"); Assert.AreEqual(type, reader.CurrentNode.Identifier.Tag, "Tag"); Assert.AreEqual(0, reader.CurrentNode.Length, "Length"); Assert.IsTrue(reader.CurrentNode.IsConstructed, "IsConstructed"); Assert.IsFalse(reader.CurrentNode.NodeType == Asn1NodeType.DocumentEnd, "EndOfDocument"); reader.Read(); }
// Token: 0x0600014A RID: 330 RVA: 0x000045F0 File Offset: 0x000027F0 public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); Asn1Type objectType = this.ObjectType; switch (objectType) { case Asn1Type.Integer: foreach (byte b in this.ObjectData) { stringBuilder2.AppendFormat("{0:X2}", b); } stringBuilder.Append("\tINTEGER ").Append(stringBuilder2).AppendLine(); break; case Asn1Type.BitString: case Asn1Type.Null: break; case Asn1Type.OctetString: foreach (byte b2 in this.ObjectData) { stringBuilder2.AppendFormat("{0:X2}", b2); } stringBuilder.Append("\tOCTETSTRING ").AppendLine(stringBuilder2.ToString()); break; case Asn1Type.ObjectIdentifier: foreach (byte b3 in this.ObjectData) { stringBuilder2.AppendFormat("{0:X2}", b3); } stringBuilder.Append("\tOBJECTIDENTIFIER ").AppendLine(stringBuilder2.ToString()); break; default: if (objectType == Asn1Type.Sequence) { stringBuilder.AppendLine("SEQUENCE {"); } break; } foreach (Asn1Object asn1Object in this.Objects) { stringBuilder.Append(asn1Object.ToString()); } if (this.ObjectType == Asn1Type.Sequence) { stringBuilder.AppendLine("}"); } stringBuilder2.Remove(0, stringBuilder2.Length - 1); return(stringBuilder.ToString()); }
/// <summary> /// Calculates length of ASN.1 object /// </summary> /// <param name="value">Content of ASN.1 object.</param> /// <param name="asn1Type">Type of ASN.1 object. In some types there has to be an octet before content bytes.</param> /// <returns>Encoded length of ASN.1 object.</returns> internal static byte[] WriteLength(IEnumerable <byte> value, Asn1Type asn1Type) { var length = value.Count(); if (asn1Type == Asn1Type.BitString) { length++; // count in the unused bits } byte[] lengthOctets = DerWriterUtils.EncodeLength(length); return(lengthOctets); }
//Default implementation of PrintHtml for all types public static void PrintHtml(Asn1Type pThis, PEREffectiveConstraint cns, StreamWriterLevel o, int lev, List<string> comment, TypeAssigment tas, List<IConstraint> additonalConstraints) { o.WriteLine("<a name=\"{0}\"></a>", "ICD_" + tas.m_name.Replace("-", "_")); o.WriteLine("<table border=\"0\" width=\"100%\" >"); o.WriteLine("<tbody>"); o.WriteLine("<tr bgcolor=\"{0}\">", (tas.m_createdThroughTabulization ? "#379CEE" : "#FF8f00")); o.WriteLine("<td height=\"35\" colspan=\"2\" >"); o.WriteLine("<font face=\"Verdana\" color=\"#FFFFFF\" size=\"4\">{0}</font><font face=\"Verdana\" color=\"#FFFFFF\" size=\"2\">({1}) </font>", tas.m_name, pThis.Name); o.WriteLine("<font face=\"Verdana\" color=\"#FFFFFF\" size=\"2\"><a href=\"#{0}\">ASN.1</a></font>", "ASN1_" + tas.m_name.Replace("-", "_")); o.WriteLine("</td>"); o.WriteLine("<td height=\"35\" align=\"center\">"); o.WriteLine(" <font face=\"Verdana\" color=\"#FFFFFF\" size=\"2\">min = {0} bytes</font>", (pThis.MinBytesInPER == -1 ? "∞" : pThis.MinBytesInPER.ToString())); o.WriteLine("</td>"); o.WriteLine("<td height=\"35\" align=\"center\">"); o.WriteLine(" <font face=\"Verdana\" color=\"#FFFFFF\" size=\"2\">max = {0} bytes{1}</font>", (pThis.MaxBytesInPER == -1 ? "∞" : pThis.MaxBytesInPER.ToString()), pThis.MaxBitsInPER_Explained); o.WriteLine("</td>"); o.WriteLine("</tr>"); IInternalContentsInHtml pICIH = pThis as IInternalContentsInHtml; string tmp = string.Empty; if (pICIH != null) tmp = pICIH.InternalContentsInHtml(additonalConstraints); if (comment.Count > 0 || tmp.Length > 0) { o.WriteLine("<tr class=\"CommentRow\">"); o.WriteLine("<td class=\"comment2\" colspan=\"4\">" + o.BR(comment) + tmp + "</td>"); o.WriteLine("</tr>"); } o.WriteLine("<tr class=\"headerRow\">"); o.WriteLine("<td class=\"hrconstraint2\" colspan=\"2\">Constraints</td>"); o.WriteLine("<td class=\"hrMin2\">Min Length (bits)</td>"); o.WriteLine("<td class=\"hrMax2\">Max Length (bits)</td>"); o.WriteLine("</tr>"); o.WriteLine("<tr class=\"OddRow\">"); o.WriteLine(" <td class=\"constraint\" colspan=\"2\">{0}</td>", o.Constraint(pThis.Constraints + BaseConstraint.AsString(additonalConstraints))); o.WriteLine(" <td class=\"min\" >{0}</td>", pThis.MinBitsInPER); o.WriteLine(" <td class=\"max\" >{0}{1}</td>", pThis.MaxBitsInPER, pThis.MaxBitsInPER_Explained); o.WriteLine("</tr>"); o.WriteLine("</tbody>"); o.WriteLine("</table>"); }
void validateTag(Oid oid, Asn1Type tag) { List <Asn1Type> tags = new List <Asn1Type> { Asn1Type.TeletexString, Asn1Type.PrintableString, Asn1Type.UniversalString, Asn1Type.UTF8String, Asn1Type.BMPString, Asn1Type.IA5String, }; if (!tags.Contains(tag)) { throw new ArgumentException("Specified ASN.1 tag is not supported."); } encodingTag = tag; }
/// <summary> /// Needed by Tabularize() /// </summary> public TypeAssigment CreateNewTypeAssigment(string name, Asn1Type asn1Type, List<string> commenst) { string newName = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1); int i = 0; while (m_typeAssigments.ContainsKey(newName)) { i++; newName += i.ToString(); } TypeAssigment ret = DefaultBackend.Instance.Factory.CreateTypeAssigment(); ret.m_name = newName; ret.m_type = asn1Type; ret.m_comments = commenst; m_typeAssigments.Add(newName, ret); ret.m_createdThroughTabulization = true; return ret; }
public PDU(UdpDatagram datagram) { _udp = datagram; MemoryStream stream = new MemoryStream(datagram.UdpData); BasicEncodingReader _reader = new BasicEncodingReader(stream); Asn1Type seqType = _reader.ReadType(); int seqLength = _reader.ReadLength(); Version = _reader.ReadInteger(); Community = _reader.ReadOctetString(); Asn1Type t = _reader.ReadType(); PduType = (PduType)(t.Byte & 0x1F); if (PduType == Snmp.PduType.Trap) { throw new NotImplementedException("SNMP v1 traps are not yet implemented"); } int len = _reader.ReadLength(); RequestId = _reader.ReadInteger(); ErrorStatus = _reader.ReadInteger(); ErrorIndex = _reader.ReadInteger(); Asn1Type type = _reader.ReadType(); if (type.Class != Asn1Class.Universal && type.Tag != Asn1Tag.Sequence) { throw new Exception("Sequence expected"); } int length = _reader.ReadLength(); VarBinds = new SortedDictionary <string, object>(); var list = _reader.ReadConstructedType(length); foreach (List <object> seq in list) { string oid = (string)seq[0]; VarBinds.Add(oid, seq[1]); } }
/// <summary> /// Assert Primary type of node. Also read the value of the node and assert with given value. Then move to next node. /// </summary> /// <param name="reader">BerReader instance.</param> /// <param name="level">Depth of node in ASN.1 structure.</param> /// <param name="type">Type of given node to assert.</param> /// <param name="length">Length of given node to assert.</param> /// <param name="value">Value of the node to assert.</param> private static void AssertReadPri(BerReader reader, int level, Asn1Type type, int length, object value) { Assert.AreEqual(level, reader.Depth, "Depth"); Assert.AreEqual(Asn1NodeType.Primitive, reader.CurrentNode.NodeType, "Node Tag"); Assert.AreEqual(type, reader.CurrentNode.Identifier.Tag, "Tag"); Assert.AreEqual(length, reader.CurrentNode.Length, "Length"); Assert.IsFalse(reader.CurrentNode.IsConstructed, "IsConstructed"); Assert.IsFalse(reader.CurrentNode.NodeType == Asn1NodeType.DocumentEnd, "EndOfDocument"); reader.CurrentNode.RawValue = reader.ReadContentAsBuffer(); switch (reader.CurrentNode.Identifier.Tag) { case Asn1Type.ObjectIdentifier: Assert.AreEqual(value, reader.CurrentNode.ReadContentAsObjectIdentifier()); break; case Asn1Type.PrintableString: case Asn1Type.Ia5String: case Asn1Type.Utf8String: Assert.AreEqual(value, reader.CurrentNode.ReadContentAsString()); break; case Asn1Type.GeneralizedTime: case Asn1Type.UtcTime: Assert.AreEqual(value, reader.CurrentNode.ReadConventAsDateTimeOffset()); break; case Asn1Type.Integer: Assert.AreEqual(value, reader.CurrentNode.ReadContentAsBigInteger()); break; case Asn1Type.Boolean: Assert.AreEqual(value, reader.CurrentNode.ReadContentAsBoolean()); break; default: Assert.AreEqual(value, reader.CurrentNode.RawValue); break; } reader.Read(); }
public static UInt32 CalculateTag(Asn1Type.Tag tg) { UInt32 ret = (byte)((byte)tg.m_class << 6); uint tagNumber = (uint)tg.m_tag; if (tagNumber < 31) { ret |= (byte)tagNumber; return ret; } ret |= 0x1F; List<byte> encBytes = new List<byte>(); while (tagNumber > 0) { byte encTagPart = (byte)(tagNumber & 0x7F); tagNumber = tagNumber >> 7; if (encBytes.Count == 0) encBytes.Insert(0, encTagPart); else encBytes.Insert(0, (byte)(0x80 | encTagPart)); } if (encBytes.Count > 3) throw new SemanticErrorException("Tag is too big! :" + tg.m_tag.ToString()); foreach (byte b in encBytes) { ret <<= 8; ret |= b; } return ret; }
public override void Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { int llen = (explicitTagging) ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength; Init(); // decode SEQUENCE Asn1BerDecodeContext context = new Asn1BerDecodeContext(buffer, llen); IntHolder elemLen = new IntHolder(); // decode algorithm if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false)) { algorithm = new Asn1ObjectIdentifier(); algorithm.Decode(buffer, true, elemLen.Value); } else { throw new Exception("Asn1MissingRequiredException (buffer)"); } // decode parameters if (!context.Expired()) { parameters = new Asn1OpenType(); parameters.Decode(buffer, true, 0); } checkTC(true); }
public void checkTC(bool decode) { /* check algorithm */ ALGORITHM_ID _index = null; for (int i = 0; i < _PKIX1Explicit88Values.SupportedAlgorithms.Length; i++) { if (_PKIX1Explicit88Values.SupportedAlgorithms[i].id.Equals(algorithm)) { _index = _PKIX1Explicit88Values.SupportedAlgorithms[i]; break; } } if (null == _index) { return; } /* check parameters */ if (decode) { if (parameters != null && _index.Type != null) { try { Asn1BerDecodeBuffer buffer = new Asn1BerDecodeBuffer(((Asn1OpenType)parameters).Value); parameters = (Asn1Type)System.Activator.CreateInstance(_index.Type.GetType()); parameters.Decode(buffer, Asn1Tag.EXPL, 0); buffer.InvokeEndElement("parameters", -1); } catch (Exception e) { //Asn1Util.WriteStackTrace(e, Console.Error); //throw new Exception("Asn1Exception(table constraint: parameters decode failed)"); throw e; } } } }
public override EnumeratedValue CreateEnumeratedValue(long val, string id, Antlr.Runtime.Tree.ITree antlr, Module module, Asn1Type type) { return new SCCEnumeratedValue(val, id, antlr, module, type); }
/// <summary> /// Typed user-defined part. /// </summary> /// <param name="Identifier">Identifier</param> /// <param name="Name">Name</param> /// <param name="Type">Type</param> public UserDefinedSpecifiedPart(string Identifier, string Name, Asn1Type Type) : base(Identifier) { this.name = Name; this.type = Type; }
public _gostR341194DigestParams_Type(byte choiceId_, Asn1Type element_) : base() { SetElement(choiceId_, element_); }
public override bool Compatible(Asn1Type other) { SequenceOfType o = other.GetFinalType() as SequenceOfType; if (o == null) return false; return base.Compatible(other); }
public SequenceOfValue(ITree antlrNode, Module module, Asn1Type type) { m_TypeID = Asn1Value.TypeID.SEQUENCE_OF; this.antlrNode = antlrNode; m_module = module; m_type = type; if (antlrNode.Type == asn1Parser.VALUE_LIST || antlrNode.Type == asn1Parser.EMPTY_LIST) { for (int i = 0; i < antlrNode.ChildCount; i++) { Asn1Value val = Asn1Value.CreateFromAntlrAst(antlrNode.GetChild(i)); m_children.Add(val); } } else if (antlrNode.Type == asn1Parser.OBJECT_ID_VALUE) { //we expect only one child either INT or identifier if (antlrNode.ChildCount != 1) throw new SemanticErrorException("Error in line:" + antlrNode.Line + " col:" + antlrNode.CharPositionInLine + ". Expecting SEQUENCE OF value"); if (antlrNode.GetChild(0).ChildCount != 1) throw new SemanticErrorException("Error in line:" + antlrNode.Line + " col:" + antlrNode.CharPositionInLine + ". Expecting SEQUENCE OF value"); ITree grandChild = antlrNode.GetChild(0).GetChild(0); Asn1Value val; if (grandChild.Type == asn1Parser.INT) { val = Asn1Value.CreateFromAntlrAst(grandChild); } else if (grandChild.Type == asn1Parser.LID) { SemanticTreeNode nodeValue; nodeValue = new SemanticTreeNode(grandChild.CharPositionInLine, grandChild.Line, grandChild.Text, asn1Parser.VALUE_REFERENCE); nodeValue.AddChild(grandChild); val = Asn1Value.CreateFromAntlrAst(nodeValue); } else throw new Exception("Internal Error"); m_children.Add(val); } else throw new Exception("Internal Error: SequenceOfValue called with wrong antlr node type"); }
/// <summary> /// Initializes a new instance of the <strong>X500RdnAttribute</strong> class from attribute /// object identifier (OID), RDN attribute value and ASN encoding type to use for encoding. /// </summary> /// <param name="oid">RDN attribute object identifier.</param> /// <param name="value">RDN attribute value.</param> /// <param name="encodingTag">ASN string type used to encode RDN attribute.</param> X500RdnAttribute(Oid oid, String value, Asn1Type encodingTag) : this(oid, value) { Oid = oid; Value = value; }
public override PEREffectiveConstraint Compute(List<IConstraint> cons, Asn1Type type) { PERSizeEffectiveConstraint ret = PERSizeEffectiveConstraint.Full; foreach (IConstraint con in cons) { PERSizeEffectiveConstraint c = con.PEREffectiveSizeConstraint; if (c!=null) ret = Intersection(ret, c); } return ret; }
public virtual PEREffectiveConstraint Compute(List<IConstraint> cons, Asn1Type type) { throw new Exception("Abstract Method Called"); }
public static new PERAlphabetAndSizeEffectiveConstraint Full(Asn1Type type) { PERAlphabetAndSizeEffectiveConstraint ret = DefaultBackend.Instance.Factory.CreatePERAlphabetAndSizeEffectiveConstraint(); ret.m_size = PERIntegerEffectiveConstraint.UncostraintPosInteger; ret.m_from = null; return ret; }
// TODO void m_initizlie(Oid oid, String value, Asn1Type tag) { // dc -- IA5 String only // E -- IA5String only }
public AlgorithmIdentifier(Asn1ObjectIdentifier algorithm, Asn1OpenType parameters) { Algorithm = algorithm; Parameters = parameters; }
public override BitStringValue CreateBitStringValue(List<long> ids, Antlr.Runtime.Tree.ITree tree, Module mod, Asn1Type type) { return new SCCBitStringValue(ids, tree, mod, type); }
public ALGORITHM_ID() { id = null; Type = null; }
public override GeneralizedTimeValue CreateGeneralizedTimeValue(Antlr.Runtime.Tree.ITree antlrNode, Module module, Asn1Type type) { return new SCCGeneralizedTimeValue(antlrNode, module, type); }
public _gost94DHPubKey_Type(byte choiceId_, Asn1Type element_) : base() { SetElement(choiceId_, element_); }
public override IntegerValue CreateIntegerValue(Antlr.Runtime.Tree.ITree antlrNode, Module module, Asn1Type type) { return new SCCIntegerValue(antlrNode, module, type); }
private void Init() { Algorithm = null; Parameters = null; }
public IA5StringValue(ITree tree, Module mod, Asn1Type type) { m_TypeID = Asn1Value.TypeID.IA5String; m_module = mod; antlrNode = tree; m_type = type; if (antlrNode.Type == asn1Parser.StringLiteral) { m_value = antlrNode.Text; if (m_value == null) m_value = ""; m_value = m_value.Replace("\"\"", "\""); if (m_value.StartsWith("\"")) m_value = m_value.Substring(1); if (m_value.EndsWith("\"")) m_value = m_value.Substring(0, m_value.Length - 1); } else if (antlrNode.Type == asn1Parser.VALUE_LIST) { if (antlrNode.ChildCount == 2 && antlrNode.GetChild(0).Type == asn1Parser.INT && antlrNode.GetChild(1).Type == asn1Parser.INT) { try { int col = int.Parse(antlrNode.GetChild(0).Text); int row = int.Parse(antlrNode.GetChild(1).Text); if (col<0 || col>7) ErrorReporter.SemanticError(mod.m_file.m_fileName, antlrNode.Line, "column value in IA5String 2-turpe must be in 0..7 range"); if (row<0 || row>15) ErrorReporter.SemanticError(mod.m_file.m_fileName, antlrNode.Line, "row value in IA5String 2-turpe must be in 0..15 range"); byte value = (byte)(col * 16 + row); m_value = Convert.ToChar(value).ToString(); } catch (OverflowException) { ErrorReporter.SemanticError(mod.m_file.m_fileName, antlrNode.Line, "value in IA5String 2-turpe is too large"); } } else { for (int i = 0; i < antlrNode.ChildCount; i++) { IA5StringValue vc = m_type.ResolveVariable(Asn1Value.CreateFromAntlrAst(antlrNode.GetChild(i))) as IA5StringValue; if (vc != null) m_value += vc.m_value; } } } else throw new Exception("INTERNAL ERROR"); }
public override PEREffectiveConstraint Compute(List<IConstraint> cons, Asn1Type type) { PERIntegerEffectiveConstraint ret = PERIntegerEffectiveConstraint.UncostraintInteger; foreach (IConstraint con in cons) { ret = Intersection(ret, con.PEREffectiveIntegerRange); } return ret; }
public override bool Compatible(Asn1Type other) { return other.GetFinalType() is UTCTimeType; }
public X500RdnAttribute(Oid oid, String value, Asn1Type encodingTag) { Oid = oid; Value = value; }
public override bool Compatible(Asn1Type other) { return other.GetFinalType() is GeneralizedTimeType; }
public X500RdnAttribute(Oid oid, String value) { Oid = oid; Value = value; encodingTag = Asn1Type.PrintableString; }
public SCCBitStringValue(ITree antlrNode, Module module, Asn1Type type) : base(antlrNode, module, type) { }
public AlgorithmId(Asn1ObjectIdentifier id, Asn1Type type) { Id = id; Type = type; }
public override UTCTimeValue CreateUTCTimeValueValue(Antlr.Runtime.Tree.ITree antlrNode, Module module, Asn1Type type) { return new SCCUTCTimeValue(antlrNode, module, type); }
public OctetStringValue(ITree tree, Module mod, Asn1Type type) { m_TypeID = Asn1Value.TypeID.OCTECT_STRING; m_module = mod; antlrNode = tree; m_type = type; BitStringValue tmp = DefaultBackend.Instance.Factory.CreateBitStringValue(tree, mod, type); while (tmp.Value.EndsWith("0")) tmp.Value = tmp.Value.Substring(0, tmp.Value.Length - 1); m_value = ConvertToOctetArray(tmp, true); }
public override bool Compatible(Asn1Type other) { OctetStringType o = other.GetFinalType() as OctetStringType; if (o == null) return false; return true; }
public override IntegerValue CreateIntegerValue(long val, Module m, Antlr.Runtime.Tree.ITree antlr, Asn1Type type) { return new SCCIntegerValue(val, m, antlr, type); }
public SCCBitStringValue(List<Int64> ids, ITree tree, Module mod, Asn1Type type) : base(ids, tree, mod, type) { }
public override bool Compatible(Asn1Type other) { return other.GetFinalType() is NumericStringType; }
public override ObjectIdentifierValue CreateObjectIdentifierValue(Antlr.Runtime.Tree.ITree antlrNode, Module module, Asn1Type type) { return new SCCObjectIdentifierValue(antlrNode, module, type); }
public UTCTimeValue(ITree tree, Module mod, Asn1Type type) : base(tree, mod, type) { m_TypeID = Asn1Value.TypeID.UTCTime; List<Char> acs = new List<char>(AllowedCharSet); m_value = m_value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", ""); foreach (Char ch in Value.ToCharArray()) if (!acs.Contains(ch)) throw new SemanticErrorException("Error in line: " + antlrNode.Line + ", col: " + antlrNode.CharPositionInLine + ". Character: '" + ch + "' can not be contained in a UTCTimeValue string"); }
public override OctetStringValue CreateOctetStringValue(Antlr.Runtime.Tree.ITree antlrNode, Module module, Asn1Type type) { return new SCCOctetStringValue(antlrNode, module, type); }
public _gost2012_512DH_PubKey_Type(byte choiceId_, Asn1Type element_) : base() { SetElement(choiceId_, element_); }
public override SequenceOrSetValue CreateSequenceOrSetValue(Antlr.Runtime.Tree.ITree antlrNode, Module module, Asn1Type type) { return new SCCSequenceOrSetValue(antlrNode, module, type); }