Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SET OF ANY and SEQUENCE OF ANY encoding support #165

Merged
merged 1 commit into from
Jul 6, 2019

Conversation

etingof
Copy link
Owner

@etingof etingof commented Jul 5, 2019

Add SET|SEQUENCE OF ANY encoding support

For example:

      AttributeTypeAndValues ::= SEQUENCE {
        type OBJECT IDENTIFIER,
        values SET OF ANY DEFINED BY type
      }

This patch adds support of the above ASN.1 syntax to BER/DER/CER
codecs.

It appears that to implement this feature properly, SetOf/SequenceOf
pyasn1 types need to have .componentType wrapped into something
similar to NamedType that Set/Sequence have. That additional
layer would then carry the open type meta information. Without it,
Sequence/Set codec needs to signal SetOf/SequenceOf codec
of the open type being processed, which is a slight hack.

A other inconvenience is that when SetOf/SequenceOf deal with
an open type component, they should not verify types on component
assignment. Without open type property in SetOf/SequenceOf,
the code checks for Any component type which is another hack.

The above shortcomings should be addressed in the follow up patch.

@codecov-io
Copy link

codecov-io commented Jul 5, 2019

Codecov Report

Merging #165 into master will decrease coverage by 0.15%.
The diff coverage is 26.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #165      +/-   ##
=========================================
- Coverage   85.76%   85.6%   -0.16%     
=========================================
  Files          29      29              
  Lines        4172    4182      +10     
=========================================
+ Hits         3578    3580       +2     
- Misses        594     602       +8
Impacted Files Coverage Δ
pyasn1/codec/ber/decoder.py 86.01% <26.66%> (-0.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba30269...d0f4504. Read the comment docs.

For example:

  AttributeTypeAndValues ::= SEQUENCE {
    type OBJECT IDENTIFIER,
    values SET OF ANY DEFINED BY type
  }

This patch adds support of the above ASN.1 syntax to BER/DER/CER
codecs.

It appears that to implement this feature properly, `SetOf`/`SequenceOf`
pyasn1 types need to have `.componentType` wrapped into something
similar to `NamedType` that `Set`/`Sequence` have. That additional
layer would then carry the open type meta information. Without it,
`Sequence`/`Set` codec needs to signal `SetOf`/`SequenceOf` codec
of the open type being processed, which is a slight hack.

A other inconvenience is that when `SetOf`/`SequenceOf` deal with
an open type component, they should not verify types on component
assignment. Without open type property in `SetOf`/`SequenceOf`,
the code checks for `Any` component type which is another hack.

The above shortcomings should be addressed in the follow up patch.
@etingof etingof force-pushed the add-set-of-any-support branch from 0b01b36 to d0f4504 Compare July 6, 2019 11:41
@etingof etingof changed the title WIP: Add SET OF ANY and SEQUENCE OF ANY constructs support Add SET OF ANY and SEQUENCE OF ANY encoding support Jul 6, 2019
@etingof etingof merged commit b5e2eeb into master Jul 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants