Home > Articles > Programming > C/C++

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Integer Parser

Listing 3 illustrates the parsing code for an integer type.

Listing 3 Integer Parser

    case INT_CLASS:
      for (i = *offset + 2; i <= *offset + elementLength + 1; i++)
        printf("%x", dataSet[i]);

      *offset += 4;
      parseAsnElement(dataSet, offset, elementLength, overallLength);

The first four lines of Listing 3 extract the integer data from the ASN.1 encoding. Next, I move the offset along past the integer element and this is then followed by a recursive call to a containing method called parseAsnElement(). We’ll see the overall picture in a few moments!

  • + Share This
  • 🔖 Save To Your Account