freedsx / asn1 Goto Github PK
View Code? Open in Web Editor NEWAn ASN.1 Library for PHP.
License: MIT License
An ASN.1 Library for PHP.
License: MIT License
It would be very handy to have a compiler capable of parsing ASN.1 files to PHP classes. And then using those PHP classes to build the requisite ASN.1 data structures to be encoded. Or take an encoded ASN.1 data structure and translate that to the PHP classes that were built.
I also have a need for general ASN.1 parsing in the SNMP library for MIBs to pick apart the generated AST (a subset anyway). This requires a parser based off X.680, and several other components:
Hello,
I noticed that the BerEncoder::decodeOid()
and BerEncoder::encodeOid()
functions are not correctly implemented.
The formula "modulo 40" is only correct for the root OIDs 0 and 1. For 2, the procedure becomes more complex.
More information at: https://misc.daniel-marschall.de/asn.1/oid_facts.html
Example:
Your program is not able to handle th OID 2.999
Here is a tool that you can use to test if your implementation is correct:
https://misc.daniel-marschall.de/asn.1/oid-converter/online.php
Hi,
i use the ASN1 and LDAP lib to proxy between a Server and a Client. On both sides i had some Problems with some LDAP-Messages.
It seems the encoder/decoder did not continue with some messages because they were to short. It got stuck in BerEncoder.php in decodeLongDefiniteLength()
if (($lengthOfLength + 1) > ($this->maxLen - $this->pos)) {
throw new PartialPduException('Not enough data to decode the length.');
}
In Wireshark everything looks okay.
It works when i remove the "+ 1" from the code.
Tobias
When decoding a large ASN.1 structure the encoder seems to use an unusually large amount of memory which can completely exhaust the default memory limit in PHP. This is likely due to the use of the encoders substr usage while chunking up the binary data and not releasing it in certain spots. Need to take a closer look on how to improve this.
Currently validating an ASN.1 structure is quite a pain. It requires a lot of manual effort. There should be a object-oriented way to build up a list of requirements that the structure must adhere to, then evaluate an existing ASN.1 type against those rules. This would eliminate a lot of error-prone loops and individual checks after constructing a structure from binary form.
Sometimes SNMP oids gets prefixed with .1.3.6.1
and sometimes with 1.3.6.1
However https://github.com/FreeDSx/ASN1/blob/master/src/FreeDSx/Asn1/Encoder/BerEncoder.php#L725 can work only with the latter so calling it fails on Warning: A non-numeric value encountered
A lot of the work is already done in both the BER encoder and the CerDerTrait. The largest issue to implementation is the indefinite encoding and how to handle that in the encoding/decoding process.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.