@@ -14,10 +14,7 @@ namespace SysadminsLV.Asn1Parser {
1414 public class Asn1Builder {
1515 readonly List < Byte > _rawData ;
1616
17- /// <summary>
18- /// Initializes a new instance of <strong>Asn1Builder</strong> class.
19- /// </summary>
20- public Asn1Builder ( ) {
17+ Asn1Builder ( ) {
2118 _rawData = new List < Byte > ( ) ;
2219 }
2320
@@ -264,7 +261,7 @@ public Asn1Builder AddVideotexString(String value) {
264261 if ( value == null ) {
265262 throw new ArgumentNullException ( nameof ( value ) ) ;
266263 }
267- _rawData . AddRange ( Asn1Utils . Encode ( Encoding . ASCII . GetBytes ( value ) , ( Byte ) Asn1Type . VideotexString ) ) ;
264+ _rawData . AddRange ( Asn1Utils . Encode ( Encoding . ASCII . GetBytes ( value ) , Asn1Type . VideotexString ) ) ;
268265 return this ;
269266 }
270267 /// <summary>
@@ -434,11 +431,12 @@ public Asn1Builder AddDerData(Byte[] value, Byte outerTag) {
434431 /// </exception>
435432 /// <returns>Current instance with added value.</returns>
436433 /// <remarks>
437- /// If <strong>mustEncode</strong> parameter is set to <strong>true</strong>, then data in <strong>value</strong> parameter
438- /// is untagged. If <strong>mustEncode</strong> parameter is set to <strong>false</strong>, then data in <strong>value</strong>
439- /// parameter is explicitly tagged and only tag name change is necessary. Caller must have knowledge in advance if value is tagged or not.
440- /// If <strong>mustEncode</strong> parameter is set to <strong>false</strong> and value passed in <strong>value</strong> parameter
441- /// is untagged, an exception will be thrown.
434+ /// If <strong>mustEncode</strong> parameter is set to <strong>true</strong>, then data in <strong>value</strong>
435+ /// parameter is untagged and this method will encode value with specified tag. If <strong>mustEncode</strong>
436+ /// parameter is set to <strong>false</strong>, then data in <strong>value</strong> parameter is considered
437+ /// encoded method will perform tag replacement. Caller must have knowledge in advance if value is tagged or
438+ /// not. If <strong>mustEncode</strong> parameter is set to <strong>false</strong> and value passed in
439+ /// <strong>value</strong> parameter is untagged, an exception will be thrown.
442440 /// </remarks>
443441 public Asn1Builder AddImplicit ( Byte implicitTag , Byte [ ] value , Boolean mustEncode ) {
444442 if ( value == null ) {
@@ -534,7 +532,7 @@ public Asn1Builder AddOctetString(Func<Asn1Builder, Asn1Builder> selector) {
534532 throw new ArgumentNullException ( nameof ( selector ) ) ;
535533 }
536534 Asn1Builder b = selector ( new Asn1Builder ( ) ) ;
537- _rawData . AddRange ( Asn1Utils . Encode ( b . _rawData . ToArray ( ) , ( Byte ) Asn1Type . OCTET_STRING ) ) ;
535+ _rawData . AddRange ( Asn1Utils . Encode ( b . _rawData . ToArray ( ) , Asn1Type . OCTET_STRING ) ) ;
538536 return this ;
539537 }
540538 /// <summary>
@@ -601,7 +599,7 @@ public Asn1Builder AddExplicit(Byte explicitTag, Func<Asn1Builder, Asn1Builder>
601599 /// A new instance of ASN.1 DER builder that contains the state of the current instance.
602600 /// </returns>
603601 public Asn1Builder Encode ( Byte outerType = 0x30 ) {
604- IEnumerable < Byte > encoded = GetEncoded ( outerType ) ;
602+ IEnumerable < Byte > encoded = Asn1Utils . Encode ( _rawData . ToArray ( ) , outerType ) ;
605603 _rawData . Clear ( ) ;
606604 _rawData . AddRange ( encoded ) ;
607605 return new Asn1Builder ( this ) ;
0 commit comments