Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do any PHP libraries exist for parsing ASN.1 or generating PHP code based on it?

I've already looked myself but it seems my Google-fu is not strong today.

I'm working to develop a standardized protocol for exchanging data structures over a TCP/IP connection between an Apache / PHP server and embedded C code on a microcontroller.

We are using ASN.1 notation, and what I would really like to do is to have a piece of PHP code that can parse the ASN.1 document and use it to interpret incoming data. It would produce a PHP object (or array) that is structured appropriately based on the ASN.1. The goal here would be for the PHP that parses the document and creates the objects to be agnostic of the document specifics (i.e. not hand-coded to match the document contents).

Alternatively, if this is not possible, does something exist that would let me generate simple PHP data transfer object classes that I could re-run each time the ASN.1 protocol document changed? This might actually be preferable from an efficiency perspective, as you wouldn't have to re-interpret the ASN.1 for each incoming request.

Thanks! Let me know if I can provide any additional clarification that would help to answer this question.

like image 206
Grekker Avatar asked Jun 07 '11 21:06

Grekker


1 Answers

Try this one: https://web.archive.org/web/20160305171509/http://phpkode.com/source/s/mistpark-server/library/asn1.php.

It's not so much a library as a script, but you can use it like one.

like image 187
Nik Avatar answered Sep 19 '22 12:09

Nik