Code Monkey home page Code Monkey logo

Comments (4)

vanrein avatar vanrein commented on August 23, 2024

Not completely sure how nested tags in constructions like [0] [1] INTEGER work under IMPLICIT TAGS?!?

Not sure it ever happens (that is, if it is permitted by ASN.1) but our DER_PIMP_ definitions may lead to strange things when they start with [1] and are called with the [0] as their implicit_tag parameter.

Ignoring this for now, who knows if we'll discover a bug due to it... unlikely to ever be used though.

from quick-der.

vanrein avatar vanrein commented on August 23, 2024

Solved in 5056727, albeit with the remark above this one.

For what it's worth:

#define DER_PACK_rfc4511_BindRequest \
        DER_PACK_ENTER | DER_TAG_APPLICATION(0), \
        DER_PACK_STORE | DER_TAG_INTEGER, \
        DER_PACK_rfc4511_LDAPDN, \
        DER_PACK_rfc4511_AuthenticationChoice, \
        DER_PACK_LEAVE

#define DER_PACK_rfc4511_AuthenticationChoice \
        DER_PACK_CHOICE_BEGIN, \
        DER_PACK_STORE | DER_TAG_CONTEXT(0), \
        DER_PIMP_rfc4511_SaslCredentials(DER_TAG_CONTEXT(3))/* ...ASN.1 extensio
ns... */, \
        DER_PACK_CHOICE_END

So it looks like the requested change has been made.

from quick-der.

vanrein avatar vanrein commented on August 23, 2024

An extension to the latter / closing remarks...

In addition, note how the call to DER_PIMP_rfc4511_SaslCredentials is now parameterised with the implicit tag (which is pushed down into the definition) where it is used to replace the DER_PIMP_ definition's outer tag:

#define DER_PIMP_rfc4511_SaslCredentials(implicit_tag) \
        DER_PACK_rfc4511_LDAPString, \
        DER_PACK_OPTIONAL, \
        DER_PACK_STORE | DER_TAG_OCTETSTRING

This, however, is wrong. It lacks the SEQUENCE around these statements, which it should have replaced. Confusing, because we've also made initial code that used the DER_PIMP_ for COMPONENTS OF.

This seems like good grounds to re-open the issue.

from quick-der.

vanrein avatar vanrein commented on August 23, 2024

We still generate

#define DER_PACK_rfc4511_AuthenticationChoice \
        DER_PACK_CHOICE_BEGIN, \
        DER_PACK_STORE | DER_TAG_CONTEXT(0), \
        DER_PIMP_rfc4511_SaslCredentials(DER_TAG_CONTEXT(3))/* ...ASN.1 extensions... */, \
        DER_PACK_CHOICE_END

so storing the [0] tagged whatever-it-is, and we still push the implied [3] tag into the DER_PIMP_rfc4511_SaslCredentials, but now we generate a proper wrapper in the latter:

#define DER_PIMP_rfc4511_SaslCredentials(implicit_tag) \
        DER_PACK_ENTER | implicit_tag, \
        DER_PACK_rfc4511_LDAPString, \
        DER_PACK_OPTIONAL, \
        DER_PACK_STORE | DER_TAG_OCTETSTRING, \
        DER_PACK_LEAVE

Nice.

Note that the reference from DER_PACK_ to DER_PIMP_ is where you can see IMPLICIT TAGS. For Kerberos, you won't find that.

Something else worth noting is this distinction:

#define DER_PIMP_rfc4511_AuthenticationChoice(implicit_tag) \
        DER_PACK_ENTER | implicit_tag, \
        DER_PACK_CHOICE_BEGIN, \
        DER_PACK_STORE | DER_TAG_CONTEXT(0), \
        DER_PIMP_rfc4511_SaslCredentials(DER_TAG_CONTEXT(3))/* ...ASN.1 extensions... */, \
        DER_PACK_CHOICE_END, \
        DER_PACK_LEAVE

#define DER_PACK_rfc4511_AuthenticationChoice \
        DER_PACK_CHOICE_BEGIN, \
        DER_PACK_STORE | DER_TAG_CONTEXT(0), \
        DER_PIMP_rfc4511_SaslCredentials(DER_TAG_CONTEXT(3))/* ...ASN.1 extensions... */, \
        DER_PACK_CHOICE_END

Here the DER_PIMP_ has a CHOICE on the outside, which must never take over a tag; this is probably avoided by ASN.1 but in cases where it isn't we generate the extra outside wrapper for the pushed-down implicit_tag.

from quick-der.

Related Issues (20)

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.