-1

I have a valid encoded ASN1 binary blob, which I want to modify. Moreover, I don't have the encoded ASN1's definitions file, but I know it's structure (e.g. let's say it's a sequence that contains few integers and an octet string). Therefore I'd prefer to modify the encoded binary by iterating over the sequence and it's fields, modify them by setting new values and encoding the new modified binary blob.

How can i do that? i.e. How can I parse the encoded ASN1 binary, modify it and re-encode it in C language? Is there any library that is able to do that?

I'm developing a software module in C for Windows. This is important to note because (in general) many library are Linux oriented and had trouble with building them for Windows.

Thanks.

SammyKab
  • 1
  • 3

1 Answers1

0

I used asn1c for this in a past project. You do need the specification: asn1c generates a decoder and encoders based on it. Sounds like in your case it wouldn't be hard to write it.

It will work on Windows. The FAQ claims the compiler now requires GCC and cannot be compiled with MSVC though. You can get GCC for Windows from www.mingw.org or Cygwin.

Joni
  • 108,737
  • 14
  • 143
  • 193
  • Thanks for your answer, I've tried using asn1c but had problems. Part of the binary blob is a Kerberos (KRB5) data structure, but had problem with compiling the krb5.asn1 specification. Can you help with that? – SammyKab Jul 27 '18 at 17:28
  • Sorry, no, it's been 10 years. If you don't need to parse stuff from the KRB5 object, maybe you can replace it with an empty dummy SEQUENCE in your spec? IIRC there was a way to access to the encoded bytes for each object so you can implement a pass-through for the types you don't want to parse. – Joni Jul 27 '18 at 17:53