Git Product home page Git Product logo

Comments (5)

sop avatar sop commented on August 19, 2024

Hi!

Thanks for the files that helped me to reproduce the problem. Great that you managed to fix a workaround as well! :)

It appears that constructed strings are a thing in BER encoding. I added rudimentary support for this in php72 branch. That's a development branch that will be merged in the near future. It does require PHP 7.2 however. Can you checkout and try it?

from asn1.

fantasya-pbem avatar fantasya-pbem commented on August 19, 2024

Thanks for your quick answer! Great that you have support for this in the php72 branch. Unfortunately I might have to support PHP 7.1 also, but I will have a look at the branch!

EDIT: In my PHP 7.2 version I can use your php72 branch successfully! What about backporting the ConstructedString into master? How much effort would this be?

from asn1.

sop avatar sop commented on August 19, 2024

Hi!

Good to hear. I'll add the functionality to old master. I've created a php70 branch and backported what i've done so far. Feel free to try it out.
I'll add a couple of features before publishing a tag though. Maybe tomorrow.

from asn1.

sop avatar sop commented on August 19, 2024

I've pushed some changes to php70 branch. Given your example data, here's how one could extract the payload as a concatenated string:

$data = file_get_contents(__DIR__ . '/constructed-octet-string.der');
$content_info = Element::fromDER($data)->asUnspecified()->asSequence();
$signed_data = $content_info->at(1)->asTagged()->asExplicit()->asSequence();
$encapsulated = $signed_data->at(2)->asSequence();
$content = $encapsulated->at(1)->asTagged()->asExplicit()->asConstructedString();
echo $content->string() . "\n";

Do you think this would be sufficient?

from asn1.

fantasya-pbem avatar fantasya-pbem commented on August 19, 2024

Thank you! I'm using branch php70 now. I ended up as this:

$encapContentInfo = $signedData->at(2)->asSequence();
$content = $encapContentInfo->getTagged(0)->asExplicit()->asElement();
if ($content instanceof Stringable) { return $content->string(); }

from asn1.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.