Native encoder fails to convert object decoded by DER
See original GitHub issueHi. I would very much appreciate advice on how to move forward. When using the native encoder to obtain python built-ins from an object decoded with DER, I get the error: AttributeError: 'tuple' object has no attribute 'tagClass'
. My use of pyasn1 is straightforward:
from pyasn1.codec.der.decoder import decode
from pyasn1.codec.native.encoder import encode
dictionary = encode(decode(der)[0])
Stepping through the source code as it executes reveals that the call to tag.TagSet, below, is where the AttributeError is raised.
class Encoder:
try:
concreteEncoder = self.__typeMap[value.typeId]
except KeyError:
# use base type for codec lookup to recover untagged types
baseTagSet = tag.TagSet(value.tagSet.baseTag, value.tagSet.baseTag)
Below is the output from the pyasn1 debugger:
SetOf:
Sequence:
field-0=lbl1
field-1=
Sequence:
field-0=lbl2
field-1=0
Sequence:
field-0=lbl3
field-1=0
SequenceOf:
lbl4 gm Sequence:
field-0=lbl5
field-1=1718187085
SequenceOf:
lbl6 ZoneFit metadata SequenceOf:
lbl7 ZoneFit metadata SequenceOf:
lbl8 com.mygym.fit.metadata Sequence:
field-0=strt
field-1=20170410174341.023814Z
Sequence:
field-0=stop
field-1=20170410174341.023814Z
SequenceOf:
desc ipso facto presto change. SequenceOf:
lbla EC5DDE8E-B486-4FAE-AC27-95FE53AA5288 Sequence:
field-0=status
field-1=5681a7954094305bf604e2214479950496e693e94c69c0c71e7097115f0250a9+2fcae427f4bf8557cfff36110ea92bbdbdcc53fa8d88275ed2b6b8e5fecdaa85
...remaining substrate is: <none>
2018-06-08 14:26:08,142 pyasn1: decoder left scope , call completed
…and here is another, different example:
2018-06-08 14:14:58,340 pyasn1: codec SetOrSetOfDecoder yields type SetOf, value:
SetOf:
SequenceOf:
lbl1 SequenceOf:
lbl2 Sequence:
field-0=lbl3
field-1=
Sequence:
field-0=lbl4
field-1=0
Sequence:
field-0=lbl5
field-1=0
SequenceOf:
lbl6 gm SequenceOf:
lbl7 AnotherTransaction1234 Sequence:
field-0=lbl8
field-1=20170410181013.631371Z
Sequence:
field-0=lbl9
field-1=20170410181013.631371Z
SequenceOf:
lbla AnotherTransaction1234 SequenceOf:
lblb 006952772G.com.mygym.homegymfit0 Sequence:
field-0=UserID
field-1=98E0F442-E181-4C66-8126-1751D99F474E
...remaining substrate is: <none>
2018-06-08 14:14:58,340 pyasn1: decoder left scope , call completed
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
codecs — Codec registry and base classes — Python 3.11.1 ...
Decodes the object input and returns a tuple (output object, length consumed). For instance, for a text encoding, decoding converts a bytes object...
Read more >asn1crypto/universal_types.md at master - GitHub
Universal Types with BER/DER Decoder and DER Encoder. The asn1crypto library is a combination of universal type ... ObjectDescriptor, no native conversion.
Read more >How to encode and decode Base64 and Base64Url in Flutter ...
The dart:convert library contains an encoder and decoder for Base64 and Base64Url. However, they encode and decode Lists of integers, ...
Read more >Custom JSON encoder and decoder - Mathspp
This article explains how to extend the JSON format by using a custom encoder and a custom decoder to turn arbitrary Python objects...
Read more >Easier ArrayBuffer to String conversion with the Encoding API
The native Encoding API offers a straightforward way to convert between raw binary data and JavaScript strings.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your samples! I think this is indeed a bug which should be fixed in #132 . It would be awesome if you could re-test your application with this fix applied.
Forgive me, I am no expert in python. i pulled your latest commit:
To make this library available to my project, i ran these commands in the pyasn1 project folder, which concluded with debugging output:
… and now ‘pip list’ shows pyasn1 0.4.3