Code Monkey home page Code Monkey logo

pyasn1's People

Contributors

ashafer01 avatar bwalks avatar etingof avatar harrisongregg avatar hugovk avatar janpipek avatar jdufresne avatar mindw avatar mmattice avatar nekolyanich avatar rockwelln avatar vincentbernat avatar viraptor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyasn1's Issues

Iteration is broken in Set in 0.2.2

Reproducer Version 0.2.2

from pyasn1.type import univ
my_set = univ.Set()

i1 = univ.Integer(123)
i2 = univ.Integer(456)
my_set[0] = i1
my_set[1] = i2
for k in abc:
... print(k)

and nothing happens

In 0.1.9:

from pyasn1.type import univ
my_set = univ.Set()

i1 = univ.Integer(123)
i1 = univ.Integer(123)
i2 = univ.Integer(456)
my_set[0] = i1
my_set[1] = i2
for k in abc:
... print(k)
...
123
456

PER

Hi Ilya.

Thank you for your work! What do you think about PER coding?

The extremely compact PER encoding is expected to be introduced in the upcoming pyasn1 release.

I wonder when this might be cuz I am currently working on a project that uses PER ..

Thank you,
Marwan

I have asn data structure file and .dat file. How can i decode asn?

You have mentioned this
With pyasn1 you can build Python objects from ASN.1 data structures. For example, the following ASN.1 data structure:

Record ::= SEQUENCE {
id INTEGER,
room [0] INTEGER OPTIONAL,
house [1] INTEGER DEFAULT 0
}
Could be expressed in pyasn1 like this:

"my question is , how can i generate code from a data structure"

Uninstalling pyasn1==0.2.2 throws an apparently spurious exception

Hi there!

I ran pip install -U . in a clone of the repo checked out at tag 0.2.2 and, though the upgrade appeared to cause the correct transformation, the process raised an OSError.

I believe the cause is a bug in the uninstall logic

Replication:

  1. check that pyasn1==0.2.2 is installed:
root@REDACTED:/home/jenkins# pip freeze | grep pyasn1
pyasn1==0.2.2
  1. check that /usr/local/lib/python2.7/dist-packages/pyasn1-0.2.2-py2.7.egg exists (and that other versions do not):
root@REDACTED:/home/jenkins# ls -la /usr/local/lib/python2.7/dist-packages/pyasn1*
-rw-r--r-- 1 root staff 119738 Sep 20 17:18 /usr/local/lib/python2.7/dist-packages/pyasn1-0.2.2-py2.7.egg
  1. uninstall pyasn1:
root@REDACTED:/home/jenkins# pip uninstall pyasn1
Uninstalling pyasn1-0.2.2:
  /usr/local/lib/python2.7/dist-packages/pyasn1-0.2.2-py2.7.egg
Proceed (y/n)? y
  Successfully uninstalled pyasn1-0.2.2
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/__init__.py", line 233, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 252, in main
    pip_version_check(session)
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/utils/outdated.py", line 102, in pip_version_check
    installed_version = get_installed_version("pip")
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 838, in get_installed_version
    working_set = pkg_resources.WorkingSet()
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 644, in __init__
    self.add_entry(entry)
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 700, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 1949, in find_eggs_in_zip
    if metadata.has_metadata('PKG-INFO'):
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 1463, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 1823, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 1703, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 1643, in load
    mtime = os.stat(path).st_mtime
OSError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/pyasn1-0.2.2-py2.7.egg'
  1. check the state of '/usr/local/lib/python2.7/dist-packages/pyasn1*`:
root@REDACTED:/home/jenkins# ls -la /usr/local/lib/python2.7/dist-packages/pyasn1*
ls: cannot access '/usr/local/lib/python2.7/dist-packages/pyasn1*': No such file or directory

My belief is that the uninstall command is correctly removing the referenced .egg and then incorrectly asserting that it expects the .egg to exist. Since the uninstall logic is a component of the pip install --upgrade process, this causes my upgrade-dependent infrastructure to fail.

Thanks for your software!

not in asn1Spec: TagMap() when using version > 0.2.3

Hi!

I'm using pyasn1 in androguard to parse X509 certificates. I noticed that travis uses now Version 0.3.2 of pyasn1 and the decoding of the DER encoded file throws an exception. This was not the case in Version 0.2.3. where everything worked just fine.

Here is a short programm to test it:

import binascii
from pyasn1.codec.der.decoder import decode

certhex  = b"3082039506092a864886f70d010702a082038630820382020101310b300906052b0e03021a0500300b06092a864886f70d010701a08202d0308202cc30820289a003020102020466eda548300b06072a8648ce380403050030363110300e06035504061307736961766173683110300e060355040a1307736961766173683110300e06035504031307736961766173683020170d3136303132353037323533305a180f32303534303532353037323533305a30363110300e06035504061307736961766173683110300e060355040a1307736961766173683110300e0603550403130773696176617368308201b83082012c06072a8648ce3804013082011f02818100fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c70215009760508f15230bccb292b982a2eb840bf0581cf502818100f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a0381850002818100e9b46a500aabcbb7b42e93477db9f8ac7c819eadd392f4fa2dd7c10973c399d00d45796052bfb376567a518cfe1432a0f845e4be75aa76462335bf7f84b6c634bb6c884b6ae2e7b6f1cc78c3be6f98b65980832c40d9da3d2b047cba98b24c877b2ace7908b0af56fd62367df355e011a0482c9b8751c373a8d131076cd01421a321301f301d0603551d0e04160414eeac32e5f08781bb6f2f392814951b328868ae4c300b06072a8648ce3804030500033000302d0215009209eb12e966aafae281620e7da9743774d7846302144bf36a9634967ca47639bbc10712571b036e13d531818e30818b020101303e30363110300e06035504061307736961766173683110300e060355040a1307736961766173683110300e0603550403130773696176617368020466eda548300906052b0e03021a0500300b06072a8648ce3804010500042e302c02145de23a86f0c2e45dcad93ef8cab675ec56a6ff4b021404c1a9f7f791631ae00d61fe8ae23f502c33fe84"

pkcs7message = binascii.unhexlify(certhex)

message, _ = decode(pkcs7message)
Traceback (most recent call last):
  File "D:\bla.py", line 8, in <module>
    message, _ = decode(pkcs7message)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 71, in valueDecoder
    value, _ = decodeFun(head, asn1Spec, tagSet, length)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\decoder.py", line 1015, in __call__
    '%s not in asn1Spec: %r' % (tagSet, asn1Spec)
pyasn1.error.PyAsn1Error: [0:32:16] not in asn1Spec: TagMap()

using the old version (<= 0.2.3 and I tested up to 0.1.8) everything works,

I tried to understand the problem and read the changelog but I can not see anything obvious there.
I read in the documentation, that you can give the decoder an asn1Spec but until now it worked without it.
Because the behavior of the function changed without any note in the changelog, I suspect this is actually a bug.

With 0.3.1 all ldap3 tests fail

Hi Ilya, with version 0.3.1 I get the following error on every test:

...
  File "C:\Python\OpenSource\ldap3\ldap3\operation\bind.py", line 124, in bind_response_to_dict
    'saslCreds': bytes(response['serverSaslCreds']) if response['serverSaslCreds'] is not None else None}
  File "C:\Python\Python36\lib\site-packages\pyasn1\type\univ.py", line 965, in __bytes__
    return bytes(self._value)
TypeError: cannot convert 'NoValue' object to bytes
  File "C:\Python\Python36\lib\site-packages\pyasn1\type\univ.py", line 965, in __bytes__
    return bytes(self._value)
TypeError: cannot convert 'NoValue' object to bytes

All tests were ok with version 0.2.3.

no longer able to parse cert created with openssl

Test example works with pyasn1 0.1.8.
Stops working after upgrading to 0.3.2

โ†’ openssl req -new -sha1 -x509 \
-days 3650 -extensions v3_ca \
-keyout ca.key \
-out ca_public_cert.pem \
-passout env:CAPASS
> > > > Generating a 2048 bit RSA private key
..............................................+++
............................................................................................................+++
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:NYC
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:1
Common Name (e.g. server FQDN or YOUR name) []:ASD
Email Address []:
โ†’ VE/bin/python test.py
โ†’ VE/bin/pip install --upgrade pyasn1
Collecting pyasn1
  Downloading pyasn1-0.3.2-py2.py3-none-any.whl (63kB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 71kB 2.6MB/s 
Installing collected packages: pyasn1
  Found existing installation: pyasn1 0.1.8
    Uninstalling pyasn1-0.1.8:
      Successfully uninstalled pyasn1-0.1.8
Successfully installed pyasn1-0.3.2
โ†’ VE/bin/python test.py
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    encaps_seq = der_decoder.decode(base64.b64decode(cert))
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 382, in valueDecoder
    component, head = decodeFun(head, asn1Spec)
  File "/usr/local/google/home/maximermilov/tmp/2/VE/local/lib/python2.7/site-packages/pyasn1/codec/ber/decoder.py", line 1015, in __call__
    '%s not in asn1Spec: %r' % (tagSet, asn1Spec)
pyasn1.error.PyAsn1Error: [0:32:16] not in asn1Spec: TagMap()
import base64
from pyasn1.codec.der import decoder as der_decoder

cert = """MIIDsDCCApigAwIBAgIJAM/gviWR8zldMA0GCSqGSIb3DQEBBQUAMG0xCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMQwwCgYDVQQHDANOWUMxITAfBgNV
BAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEKMAgGA1UECwwBMTEMMAoGA1UE
AwwDQVNEMB4XDTE3MDgyMzE1MTA0OVoXDTI3MDgyMTE1MTA0OVowbTELMAkGA1UE
BhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxDDAKBgNVBAcMA05ZQzEhMB8GA1UE
CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQowCAYDVQQLDAExMQwwCgYDVQQD
DANBU0QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDArjzLvlWXAApZ
t0qXdNHT1Xn19ik8r33ioqDD2dFALUOkbSeMds10A7b6lGHb3e0nfYm84i+EbWvu
eDzzydkj+DvkFkx7xVdz/MPukA0LGd/uoEW25mI3ZLScECVsdX5ZPiV8DigPV/Hn
e/2sT7SVpLsUBxwyEsUBcnnDRKMx3FvmrCn/ZdfcvkarPIuHXPF+t+3gOvyWXwQ1
yrWo9eYczMNJ82Mm6GxVIp5UsWtMhHHMpLeSu/uudB4fkzdaBtEx20eMe9ZPBjYI
5q+i0VECuUUVAQoo9PI7tTkvOBRACvZ1WAgf3gFj/XsHLVXxr7zRweYLkj+MxSP4
8nJF0o71AgMBAAGjUzBRMB0GA1UdDgQWBBTkWG/uEpxWU2VI3O0dcawxxEoatTAf
BgNVHSMEGDAWgBTkWG/uEpxWU2VI3O0dcawxxEoatTAPBgNVHRMBAf8EBTADAQH/
MA0GCSqGSIb3DQEBBQUAA4IBAQAtMLyDdCvllyI6hM+XPWb4RmyivNtuaisVIZiP
tYa0/lD1K3w/jq29TPqYjS7p7ophuVL+AgtmomfrGnQHEEwch6ApBVc+rHUEXfcm
AY4n81mHWOTgHrjCYNmqQ7CAGed5YVRPI+g+2zdxnrNUO4u9GWD5g/UrN0NWur+k
V3PqKtZwzLqXCPYpArLeNkburFopFXCQOhMnR/E9BOTM1/50In09dC9uOSbg+p2x
4BD7Xg4Li9i+ypysTtoBOwc5xD3C2I7Z6Arlx++t4UIXPGuUYpIUJSWdJEqzMoXT
MvH09gS0d33qCxiO9BYqyEH7Bmp6Z4Zz7ZCxkWhZab+XNPVx"""

encaps_seq = der_decoder.decode(base64.b64decode(cert))

ImportError: cannot import name 'opentype'

Since the last update of 4 hours ago my CI broke because a module is using your pyasn1 module.
I received the following in my stack trace:

  File "/usr/local/lib/python3.5/dist-packages/oauth2client/_pure_python_crypt.py", line 24, in <module>
    from pyasn1_modules.rfc2459 import Certificate
  File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <module>
    from pyasn1.type import opentype
ImportError: cannot import name 'opentype'

Is this anything related to the last changes made in this module and a way this is fixable on my side or with a new release of this module?

Empty value is constructed instead of None in pyasn1 0.3.1

Hi! again. thanks for the fix #51. That specific issue was resolved. However pyasn1==0.3.1 and pyasn1-modules==0.0.10 doesn't work for https://github.com/snowflakedb/snowflake-connector-python due to changed behavior. Here is an test code. Please try this with:

  • pyasn1==0.3.1 and pyasn1-modules==0.0.10
  • pyasn1==0.2.3 and pyasn1-modules==0.0.9
from pyasn1.codec.der import decoder as der_decoder
from pyasn1.type import (univ, namedtype, tag, namedval, useful)
from pyasn1_modules import (rfc2459)


class Version(univ.Integer):
    namedValues = namedval.NamedValues(
        ('v1', 0)
    )


class CertID(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('hashAlgorithm', rfc2459.AlgorithmIdentifier()),
        namedtype.NamedType('issuerNameHash', univ.OctetString()),
        namedtype.NamedType('issuerKeyHash', univ.OctetString()),
        namedtype.NamedType('serialNumber', rfc2459.CertificateSerialNumber()))


class Request(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('reqCert', CertID()),
        namedtype.OptionalNamedType(
            'singleRequestExtensions',
            rfc2459.Extensions().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    0))))


class TBSRequest(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType(
            'version', Version(0).subtype(
                explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple,
                                    0))),
        namedtype.OptionalNamedType(
            'requestorName',
            rfc2459.GeneralName().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    1)
            )),
        namedtype.NamedType('requestList',
                            univ.SequenceOf(componentType=Request())),
        namedtype.OptionalNamedType(
            'requestExtensions',
            rfc2459.Extensions().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    2)
            ))
    )


class Certs(univ.SequenceOf):
    componentType = rfc2459.Certificate()


class Signature(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('signatureAlgorithm',
                            rfc2459.AlgorithmIdentifier()),
        namedtype.NamedType('signature', univ.BitString()),
        namedtype.NamedType(
            'certs', Certs().subtype(
                explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)
            )
        )
    )


class OCSPRequest(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('tbsRequest', TBSRequest()),
        namedtype.OptionalNamedType(
            'optionalSignature', Signature().subtype(
                explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple,
                                    0)))
    )


# OCSP Response
class OCSPResponseStatus(univ.Enumerated):
    namedValues = namedval.NamedValues(
        ('successful', 0),
        ('malformedRequest', 1),
        ('internalError', 2),
        ('tryLater', 3),
        # ('not-used', 4),
        ('sigRequired', 5),
        ('unauthorized', 6)
    )


class ResponseBytes(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('responseType', univ.ObjectIdentifier()),
        namedtype.NamedType('response', univ.OctetString())
    )


class OCSPResponse(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('responseStatus', OCSPResponseStatus()),
        namedtype.OptionalNamedType('responseBytes', ResponseBytes().subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)
        ))
    )


KeyHash = univ.OctetString
UnknownInfo = univ.Null


class RevokedInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('revocationTime', useful.GeneralizedTime()),
        namedtype.OptionalNamedType(
            'revocationReason',
            rfc2459.CRLReason().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    0)
            ))
    )


class CertStatus(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('good', univ.Null().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)
        )),
        namedtype.NamedType('revoked', RevokedInfo().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)
        )),
        namedtype.NamedType('unknown', UnknownInfo().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)
        ))
    )


class SingleResponse(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('certID', CertID()),
        namedtype.NamedType('certStatus', CertStatus()),
        namedtype.NamedType('thisUpdate', useful.GeneralizedTime()),
        namedtype.OptionalNamedType(
            'nextUpdate',
            useful.GeneralizedTime().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    0)
            )),
        namedtype.OptionalNamedType(
            'singleExtensions',
            rfc2459.Extensions().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    2)
            ))
    )


class ResponderID(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('byName', rfc2459.Name().subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.NamedType('byKey', KeyHash().subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    )


class ResponseData(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType('version', Version(0).subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.NamedType('responderID', ResponderID()),
        namedtype.NamedType('producedAt', useful.GeneralizedTime()),
        namedtype.NamedType('responses',
                            univ.SequenceOf(componentType=SingleResponse())),
        namedtype.OptionalNamedType(
            'responseExtensions',
            rfc2459.Extensions().subtype(
                explicitTag=tag.Tag(tag.tagClassContext,
                                    tag.tagFormatSimple,
                                    1)
            ))
    )


class BasicOCSPResponse(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('tbsResponseData', ResponseData()),
        namedtype.NamedType('signatureAlgorithm',
                            rfc2459.AlgorithmIdentifier()),
        namedtype.NamedType('signature', univ.BitString()),
        namedtype.OptionalNamedType('certs', Certs().subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)
        ))
    )


s = bytearray.fromhex('308202b630819fa21604145379bf5aaa2b4acf5480e1d89bc09df2b20366cb180f32303137303732363130303533355a30743072304a300906052b0e03021a05000414cd30d24c343a82ab1f0570158ad7a107762992e904145379bf5aaa2b4acf5480e1d89bc09df2b20366cb021100c3dedf76cfd786bea1af8befefa4dd388000180f32303137303732363130303533355aa011180f32303137303830323130303533355a300d06092a864886f70d01010c050003820201005346aa8492bf8fd2df4d6fb7ca070ef7c66b0654236de4007ec4609dea96344fd819e7154b3912d91b513da18f3a562cb839a448e36954f48ddbfda5b5a113e3ee148f1d1fcbee4a343981f342bde9dbc7ef894c59bd38938e05b8d6fd5cbc99f5a6bb1ee403e04c69f32a5179ee3829c9700c3ce7c39967f19d927c5738d17c73e6c10f2705d47220c43c2f6705f56520a24bfe3c160c725940233d8ca3046e89fc78fa185d7fe26c35f464df1733f1db61589ed2b05c3c87426ca144fde600aef2fd3d0ab648f764e1664820be7f4455a781e1eca65dddbda439e2aaacf12dc3ff6c1c5b222698319db9e8e6b6c220db4fc34938d98f46aa2bec68735e9d539daeafaff0fcd1c02aba002cdfcfcf499715bb8787d5432f7b2288fd51e0c8621294d5c0629037cf21cd0c5c42da18eaea386bef9a8b7e5b54b7dc96956d876f7a5458d91b2d47f5e7714e14700143b66c97bf039ce93807810513ec8c1b4db17f5f2f4e407aa2183e87a0ec459448e45f35a92d05878c6585e84736bdc61cede75504cda95431ce6a61bdcb63eec016c4bcfd75530f1c0104da5bac47855a3638f496874ae7ae30f77774fe5e9f399b30f63110453ab544f4edf6faa8fa7674ec079823be3b01fb5d08e4c581e107620fb7c54db6dcf941db1ebf7086e0edadd240a83aefaeef4e851592dab3c0833d328658082b418ec6cb1d0435b9c923f9')
st = univ.OctetString(value=bytes(s))

basic_ocsp_response, _ = der_decoder.decode(st, BasicOCSPResponse())
print(basic_ocsp_response['certs'])

As you notice, the first case returns:

Certs(tagSet=TagSet((), Tag(tagClass=0, tagFormat=32, tagId=16), Tag(tagClass=128, tagFormat=32, tagId=0)))

but the second case returns:

None

Is this an expected change? If so, how should I check if the value exists? hasValue()?

DER encoding produces constructed form of encoding

from pyasn1.codec.der import encoder
from pyasn1.type import univ

o = univ.OctetString('\xaa' * 1001)
encoder.emcode(o)

Results in '$\x82\x03\xef\x04\x82\x03\xe8\xaa\xaa .. \xaa\x04\0x01\xaa'

According to X.690 $10.2 the constructed form of encoding should not be used for DER encoding.
Expected value would be: '\x04\x82\x03\xe9\xaa\xaa..\xaa'

return negative value from from_bytes

Hi guys, I am new in ASN.1 coding and try handle snmp trap and have some problems with some equipment

Most of trap working good, but some crash with error:

 Traceback (most recent call last):
  File "./broken_test.py", line 17, in <module>
    a, b = pyasn_decoder.decode(whole_msg, asn1Spec = proto.Message())
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 496, in valueDecoder
    component, head = decodeFun(head, asn1Spec, **options)
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 686, in valueDecoder
    tagSet, length, state, **options
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 496, in valueDecoder
    component, head = decodeFun(head, asn1Spec, **options)
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 523, in valueDecoder
    component, head = decodeFun(head, asn1Spec, **options)
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 496, in valueDecoder
    component, head = decodeFun(head, asn1Spec, **options)
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 686, in valueDecoder
    tagSet, length, state, **options
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 686, in valueDecoder
    tagSet, length, state, **options
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 686, in valueDecoder
    tagSet, length, state, **options
  File "/root/pyasn1/codec/ber/decoder.py", line 1160, in __call__
    **options
  File "/root/pyasn1/codec/ber/decoder.py", line 109, in valueDecoder
    return self._createComponent(asn1Spec, tagSet, value), tail
  File "/root/pyasn1/codec/ber/decoder.py", line 45, in _createComponent
    return asn1Spec.clone(value)
  File "/root/pyasn1/type/univ.py", line 273, in clone
    return base.AbstractSimpleAsn1Item.clone(self, value, **kwargs)
  File "/root/pyasn1/type/base.py", line 311, in clone
    return self.__class__(value, **initilaizers)
  File "/root/pyasn1/type/univ.py", line 72, in __init__
    base.AbstractSimpleAsn1Item.__init__(self, value, **kwargs)
  File "/root/pyasn1/type/base.py", line 209, in __init__
    raise exType('%s at %s' % (exValue, self.__class__.__name__))
pyasn1.type.error.ValueConstraintError: ConstraintsIntersection(ValueRangeConstraint(0, 4294967295)) failed at: ValueConstraintError('ValueRangeConstraint(0, 4294967295) failed at: ValueConstraintError(-112878092,)',) at TimeTicks

Reading code I find in pyasn1-0.3.7-py2.7.egg/pyasn1/compat/integer.py

29   if signed and oct2int(octets[0]) & 0x80:
30       return value - (1 << len(octets) * 8)

Can you explain me please, what means "oct2int(octets[0]) & 0x80"?
When me code crash: oct2int(octets[0]) = 249

Thanks!

ImportError: cannot import name opentype

Breaks with pyasn1==0.1.9 when the pyasn1-modules > 0.0.8

  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
    self._setup(name)
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/django/conf/__init__.py", line 99, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/opt/python/2.7.10/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/travis/build/bkvirendra/voltbe2/voltbe2/settings/__init__.py", line 9, in <module>
    from .travis_settings import *
  File "/home/travis/build/bkvirendra/voltbe2/voltbe2/settings/travis_settings.py", line 1, in <module>
    from base import *
  File "/home/travis/build/bkvirendra/voltbe2/voltbe2/settings/base.py", line 15, in <module>
    import firebase_admin
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/firebase_admin/__init__.py", line 22, in <module>
    from firebase_admin import credentials
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/firebase_admin/credentials.py", line 23, in <module>
    from google.oauth2 import service_account
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/google/oauth2/service_account.py", line 77, in <module>
    from google.auth import _service_account_info
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/google/auth/_service_account_info.py", line 22, in <module>
    from google.auth import crypt
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/google/auth/crypt/__init__.py", line 39, in <module>
    from google.auth.crypt import rsa
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/google/auth/crypt/rsa.py", line 17, in <module>
    from google.auth.crypt import _python_rsa
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/google/auth/crypt/_python_rsa.py", line 29, in <module>
    from pyasn1_modules.rfc2459 import Certificate
  File "/home/travis/virtualenv/python2.7.10/lib/python2.7/site-packages/pyasn1_modules/rfc2459.py", line 20, in <module>
    from pyasn1.type import opentype
ImportError: cannot import name opentype

Fixed when I set the pyasn1-modules==0.0.8 in requirements

there is a INTEGER in Sequence

hi guys,

i am new in ASN.1 coding, but there is a mission for me, to encode some data to a bin file, so i find this outstanding repo to do the job.

my data is like:

<!-- message 1 -->
<APPLICATION_1>
   <APPLICATION_33>
      <APPLICATION_50>0A</APPLICATION_50>
      <APPLICATION_53>30303633</APPLICATION_53>
      <APPLICATION_54>3230313630343239313533303030</APPLICATION_54>
      <APPLICATION_55>0A</APPLICATION_55>
   </APPLICATION_33>
   <APPLICATION_32></APPLICATION_32>
   <APPLICATION_34>
      <APPLICATION_50>5A</APPLICATION_50>
      <APPLICATION_53>30303633</APPLICATION_53>
      <APPLICATION_57>00</APPLICATION_57>
      <APPLICATION_63>00</APPLICATION_63>
   </APPLICATION_34>
</APPLICATION_1>

i wrote a script like this:

# -*- coding: utf-8 -*-
from pyasn1.type import univ, namedtype, tag
from pyasn1.codec.der import encoder
import struct


class Header(univ.Sequence):
    tagSet = univ.Integer.tagSet.tagExplicitly(
        tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 33)
    )
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'APPLICATION_50',
            univ.Integer().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 50)
            )
        ),
        namedtype.NamedType(
            'APPLICATION_53',
            univ.OctetString().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 53)
            )
        ),
        namedtype.NamedType(
            'APPLICATION_54',
            univ.OctetString().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 54)
            )
        ),
        namedtype.NamedType(
            'APPLICATION_55',
            univ.Integer().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 55)
            )
        ),
    )


class Tail(univ.Sequence):
    tagSet = univ.Integer.tagSet.tagExplicitly(
        tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 34)
    )
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'APPLICATION_50',
            univ.Integer().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 50)
            )
        ),
        namedtype.NamedType(
            'APPLICATION_53',
            univ.OctetString().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 53)
            )
        ),
        namedtype.NamedType(
            'APPLICATION_57',
            univ.OctetString().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 57)
            )
        ),
        namedtype.NamedType(
            'APPLICATION_63',
            univ.Integer().subtype(
                implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 63)
            )
        ),
    )


class Record(univ.Sequence):
    tagSet = univ.Integer.tagSet.tagExplicitly(
        tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 1)
    )
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'APPLICATION_33',
            Header()
        ),
        namedtype.NamedType(
            'APPLICATION_34',
            Tail()
        )
    )


def trans():

    header = Header()
    header.setComponentByName('APPLICATION_50', 10)
    header.setComponentByName('APPLICATION_53', "0063")
    header.setComponentByName('APPLICATION_54', "20160429153000")
    header.setComponentByName('APPLICATION_55', 10)

    tail = Tail()
    tail.setComponentByName("APPLICATION_50", 10)
    tail.setComponentByName("APPLICATION_53", "0063")
    tail.setComponentByName("APPLICATION_57", "00")
    tail.setComponentByName("APPLICATION_63", 10)

    record = Record()
    record.setComponentByName("APPLICATION_33", header)
    record.setComponentByName("APPLICATION_34", tail)

    print(record.prettyPrint())
    asn1 = encoder.encode(record)
    with open("dist.der","wb") as f:
        f.write(asn1)
    print(asn1.encode("hex"))


if __name__ == "__main__":
    trans()

the coder works fine, but the result seems not good, a INTEGER is appears unexpected, i decoded the result to XML, which is:

<!-- message 1 -->
<APPLICATION_1>
   <INTEGER>
      <APPLICATION_33>
         <INTEGER>
            <APPLICATION_50>0A</APPLICATION_50>
            <APPLICATION_53>30303633</APPLICATION_53>
            <APPLICATION_54>3230313630343239313533303030</APPLICATION_54>
            <APPLICATION_55>0A</APPLICATION_55>
         </INTEGER>
      </APPLICATION_33>
      <APPLICATION_34>
         <INTEGER>
            <APPLICATION_50>0A</APPLICATION_50>
            <APPLICATION_53>30303633</APPLICATION_53>
            <APPLICATION_57>3030</APPLICATION_57>
            <APPLICATION_63>0A</APPLICATION_63>
         </INTEGER>
      </APPLICATION_34>
   </INTEGER>
</APPLICATION_1>

i think there is something wrong in the define of Header and Tail class, but i cannot figure out them.

any help is greatly appreciated!

Regards.

Aether WANG

Including uninitialized, optional, SetOf?

Hi,

After 6fa0e31 I observe that an uninitialized, and optional, SetOf is being included in the encoded data.

In my case it's a PrivateKeyInfo structure (https://github.com/etingof/pyasn1-modules/blob/master/pyasn1_modules/rfc5208.py#L49) and before the change the attributes was not being included:

    0:d=0  hl=4 l=1213 cons: SEQUENCE          
    4:d=1  hl=2 l=   1 prim:  INTEGER           :00
    7:d=1  hl=2 l=  13 cons:  SEQUENCE          
    9:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
   20:d=2  hl=2 l=   0 prim:   NULL              
   22:d=1  hl=4 l=1191 prim:  OCTET STRING      [HEX DUMP]:308204A3...

But after they are:

    0:d=0  hl=4 l=1215 cons: SEQUENCE          
    4:d=1  hl=2 l=   1 prim:  INTEGER           :00
    7:d=1  hl=2 l=  13 cons:  SEQUENCE          
    9:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
   20:d=2  hl=2 l=   0 prim:   NULL              
   22:d=1  hl=4 l=1191 prim:  OCTET STRING      [HEX DUMP]:308204A...
 1217:d=1  hl=2 l=   0 cons:  cont [ 0 ]  

I can get rid of it if I include attributes with an empty attribute, but it seems weird to me that I have to.

Is this how it's supposed to be? Thanks.

Hexa Value Constraint

Hi guys,

I think it is a new issue, it is regarding to the size constraint:
file : constraint.py
function : ValueSizeConstraint
line 106 : l = len(value)

If ASN1 file define a variable with the terms : "fileID OCTET STRING (SIZE(2))"
That means,it has to be an octet string of length 2 Octets

eg: fileID = '0102'

or in the function ValueSizeConstraint (in constraint.py)
in line 106 we count the number of string characters and not octets

to day : line 106 : l = len(value)
I corrected by : line 106 : l = len(value)/2
to count the number of OCTETs and not the string characters

in my case it correct the problem

Regards

Mourad

PyAsn1Error when decoding explicitly tagged subtypes

I've got a little wrapper library at https://github.com/jfinkhaeuser/bran that goes a little beyond the ASN.1 specs to providing a canonical presentation.

Since upgrading to pyasn1 0.3.x my builds fail, and I'm having a hard time figuring out what if anything I'm doing wrong.

Summarized, I do the following:

  • Encode more complex types as sequences:
    self.MAPPING = univ.Sequence(
      tagSet = univ.Sequence.tagSet.tagExplicitly(
        tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0x04)
      )
    )
  • In the mapping case, it's actually a sequence of two item sequences, representing the key and value.
  • When decoding, there's now a PyAsn1Error when the sequence end is reached. Previously iteration would just stop.

I can circumvent that by catching the error, but that might hide other issues. I can explicitly add the length of the sequence, but my understanding of ASN.1 is that this shouldn't be necessary.

The error is "Compontent type not defined".

Do you have any pointers for me?

Cannot get the size of NoValue object

In previous versions, doing sys.getsizeof(NoValue()) worked properly. In 0.2.2, the following exception is thrown:

>>> import sys
>>> sys.getsizeof(NoValue())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pyasn1/type/base.py", line 145, in plug
    raise error.PyAsn1Error('Uninitialized ASN.1 value ("%s" attribute looked up)' % name)
pyasn1.error.PyAsn1Error: Uninitialized ASN.1 value ("__sizeof__" attribute looked up)

Wrong constraint verification

Constraints (eg ValueSizeConstraint) ignores multibyte encodings

How to reproduce:

from pyasn1.type import char, constraint

char.UTF8String("ั„").subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 1))
>>> 'ั„'.encode('utf-8')
b'\xd1\x84'

0.4.1: Attempted "__bool__" operation on ASN.1 schema object

Just observed an error with pyasn 0.4.1:

...
File "/opt/mesosphere/lib/python3.6/site-packages/ldap3/core/connection.py", line 1205, in start_tls
if self.server.tls.start_tls(self) and self.strategy.sync:  # for async connections _start_tls is run by the strategy
File "/opt/mesosphere/lib/python3.6/site-packages/ldap3/core/tls.py", line 244, in start_tls
result = connection.extended('1.3.6.1.4.1.1466.20037')
File "/opt/mesosphere/lib/python3.6/site-packages/ldap3/core/connection.py", line 1169, in extended
response = self.post_send_single_response(self.send('extendedReq', request, controls))
File "/opt/mesosphere/lib/python3.6/site-packages/ldap3/strategy/base.py", line 298, in send
self.connection.request = BaseStrategy.decode_request(message_type, request, controls)
File "/opt/mesosphere/lib/python3.6/site-packages/ldap3/strategy/base.py", line 623, in decode_request
result = extended_request_to_dict(component)
File "/opt/mesosphere/lib/python3.6/site-packages/ldap3/operation/extended.py", line 58, in extended_request_to_dict
return {'name': str(request['requestName']), 'value': bytes(request['requestValue']) if request['requestValue'] else None}
File "/opt/mesosphere/lib/python3.6/site-packages/pyasn1/type/base.py", line 290, in __bool__
return self._value and True or False
File "/opt/mesosphere/lib/python3.6/site-packages/pyasn1/type/base.py", line 199, in plug
raise error.PyAsn1Error('Attempted "%s" operation on ASN.1 schema object' % name)
pyasn1.error.PyAsn1Error: Attempted "__bool__" operation on ASN.1 schema object

Right now I unfortunately can't provide more context / more parts of the traceback.

pyasn1 0.3.1 doesn't work with pyasn1-module 0.0.9

pyasn1 0.3.1 caused a regression with pyasn1-module 0.0.9:

virtualenv-3.4 /tmp/a
source /tmp/a/bin/activate
pip install pyasn1 pyasn1-modules
python -c 'from pyasn1_modules import (rfc2560)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/a/lib/python3.4/site-packages/pyasn1_modules/rfc2560.py", line 137, in <module>
    class ResponseData(univ.Sequence):
  File "/tmp/a/lib/python3.4/site-packages/pyasn1_modules/rfc2560.py", line 143, in ResponseData
    namedtype.NamedType('responses', univ.SequenceOf(SingleResponse())),
TypeError: __init__() takes 1 positional argument but 2 were given

Is this combination of library supported?

A workaround is

pip install -U pyasn1==0.2.3

TagSet object not in asn1Spec

At least 0.3.7 was working fine, now there is an error while trying to access a resource. Looks like that this is related to the encoder optimization.

pyasn1.error.PyAsn1Error: <TagSet object at 0x7f6b9803f160 tags 0:32:16> not in asn1Spec: <OctetString schema object at 0x7f6b78414ac8 tagSet <TagSet object at 0x7f6b981e8cf8 tags 0:0:4> encoding iso-8859-1>
$ pip3 freeze | grep pyasn1
pyasn1==0.4.2
pyasn1-modules==0.2.1

IndexError: tuple index out of range when encoding X509 Cert

I think this one was not reported yet :)

I used pyasn1 to extract the X509 certificate part of an PKCS#7 Message, here is an example:

import binascii
from pyasn1.codec.der.decoder import decode
from pyasn1.codec.der.encoder import encode

certhex  = b"3082039506092a864886f70d010702a082038630820382020101310b300906052b0e03021a0500300b06092a864886f70d010701a08202d0308202cc30820289a003020102020466eda548300b06072a8648ce380403050030363110300e06035504061307736961766173683110300e060355040a1307736961766173683110300e06035504031307736961766173683020170d3136303132353037323533305a180f32303534303532353037323533305a30363110300e06035504061307736961766173683110300e060355040a1307736961766173683110300e0603550403130773696176617368308201b83082012c06072a8648ce3804013082011f02818100fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c70215009760508f15230bccb292b982a2eb840bf0581cf502818100f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a0381850002818100e9b46a500aabcbb7b42e93477db9f8ac7c819eadd392f4fa2dd7c10973c399d00d45796052bfb376567a518cfe1432a0f845e4be75aa76462335bf7f84b6c634bb6c884b6ae2e7b6f1cc78c3be6f98b65980832c40d9da3d2b047cba98b24c877b2ace7908b0af56fd62367df355e011a0482c9b8751c373a8d131076cd01421a321301f301d0603551d0e04160414eeac32e5f08781bb6f2f392814951b328868ae4c300b06072a8648ce3804030500033000302d0215009209eb12e966aafae281620e7da9743774d7846302144bf36a9634967ca47639bbc10712571b036e13d531818e30818b020101303e30363110300e06035504061307736961766173683110300e060355040a1307736961766173683110300e0603550403130773696176617368020466eda548300906052b0e03021a0500300b06072a8648ce3804010500042e302c02145de23a86f0c2e45dcad93ef8cab675ec56a6ff4b021404c1a9f7f791631ae00d61fe8ae23f502c33fe84"

pkcs7message = binascii.unhexlify(certhex)

message, _ = decode(pkcs7message)
cert = encode(message[1][3])
print(cert)

With version 0.3.3 this fails due to the following error, it worked fine with the versions before 0.3.1:

Traceback (most recent call last):
  File "bla.py", line 12, in <module>
    cert = encode(message[1][3])
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\der\encoder.py", line 56, in __call__
    return encoder.Encoder.__call__(self, value, defMode, maxChunkSize, ifNotEmpty=ifNotEmpty)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\cer\encoder.py", line 208, in __call__
    return encoder.Encoder.__call__(self, value, defMode, maxChunkSize, ifNotEmpty)
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\encoder.py", line 483, in __call__
    self, value, defMode, maxChunkSize, ifNotEmpty=ifNotEmpty
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\ber\encoder.py", line 61, in encode
    encodeFun, value, defMode, maxChunkSize, ifNotEmpty=ifNotEmpty
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\codec\cer\encoder.py", line 156, in encodeValue
    substrate = encodeFun(value[idx], defMode, maxChunkSize, namedTypes[idx].isOptional) + substrate
  File "C:\Program Files\Anaconda3\lib\site-packages\pyasn1\type\namedtype.py", line 155, in __getitem__
    return self.__namedTypes[idx]
IndexError: tuple index out of range

Maybe, it has to do how I use it, maybe it is a real bug.

By the way, this is how I use it:
https://github.com/androguard/androguard/blob/master/androguard/core/bytecodes/apk.py#L836
I also need to remove the first identifier in the DER Coded sequence, which does not look right, but I did not found another way.
(If you know a better way to extract the cert from the message please tell me :))

BER encoding output not full

Hi ,
I got this sequence that i am trying to ber encode , however the last element is not output from the encoder. I wonder what may be the reason for ber encoder to ignore this element !?

this is the prettyPrint of the object right before ber encoding:

CBCINFOMSGREQRESULT:
cbccberequesthandle=4
cbccbestatuscode=0
messageclass=0
messagetext=Success
area=AREADATALIST:
coordinatesystem=
nrofcoordinatepair=
coordinatepair=SequenceOf:

repetitioninterval=1
messageid=2
messageinfolist=MESSAGEINFOLIST:
nrofintervals=2
intervalinfo=SequenceOf:

INTERVALINFO:
 updatenr=0
 messagestatus=0
 starttime=<no value>
 endtime=<no value>
 pagelist=PAGELISTDATA:
  nrofpages=1
  page=SequenceOf:
   PAGEDATA:
    pagecontents=0x0a
    pagelength=1

INTERVALINFO:
 updatenr=1
 messagestatus=0
 starttime=<no value>
 endtime=<no value>
 pagelist=PAGELISTDATA:
  nrofpages=1
  page=SequenceOf:
   PAGEDATA:
    pagecontents=0x68656c6c6f20776f726c640a
    pagelength=12

and this is the ber encoder output, you will notice that area element is removed since its value is none. the messageinfolist, however, has values but you can not find it in the output:

b'`\x1a\xa4\x18\x81\x01\x04\x82\x01\x00\x83\x01\x00\x84\x07Success\x87\x01\x01\x88\x01\x02'

prettyPrint after ber decoding:

CBCINFOMSGREQRESULT:
cbccberequesthandle=4
cbccbestatuscode=0
messageclass=0
messagetext=Success
repetitioninterval=1
messageid=2

and this is the pyasn1 sequence class :

class CBCINFOMSGREQRESULT(univ.Sequence):
    pass


CBCINFOMSGREQRESULT.tagSet = univ.Sequence.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 0))
CBCINFOMSGREQRESULT.componentType = namedtype.NamedTypes(
    namedtype.NamedType('cbccberequesthandle', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.NamedType('cbccbestatuscode', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.NamedType('messageclass', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('messagetext', char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
    namedtype.OptionalNamedType('area', AREADATALIST().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
    namedtype.OptionalNamedType('areaidlist', AREAIDLIST().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
    namedtype.OptionalNamedType('repetitioninterval', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
    namedtype.OptionalNamedType('messageid', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8))),
    namedtype.OptionalNamedType('datacodingscheme', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 9))),
    namedtype.OptionalNamedType('warningtype', univ.BitString().subtype(subtypeSpec=constraint.ValueSizeConstraint(16, 16)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 10))),
    namedtype.OptionalNamedType('messageinfolist', MESSAGEINFOLIST().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 11)))

Thanks,

hasValue() is erroneous when member is optional and is a Sequence() (maybe with other types as well)

Hello,

When running the code below, we get different results from the function hasValue():

from binascii import hexlify
from pyasn1.type import univ, namedtype
from pyasn1.codec.der import encoder, decoder

print ">>> Sample 1"

class Sample(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('a', univ.Integer()),
        namedtype.OptionalNamedType('b', univ.Integer())
        )
s1 = Sample()
s1['a'] = univ.Integer(1)

print 'hasvalue s1=', s1['b'].hasValue()

e_s1 = encoder.encode(s1)
print hexlify(e_s1)
s2 = decoder.decode(e_s1, asn1Spec=Sample())[0]

e_s2 = encoder.encode(s2)
print hexlify(e_s2)

print 'hasvalue s2=', s2['b'].hasValue()

print ">>> Sample 2"

class Sample(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('a', univ.Integer()),
        namedtype.OptionalNamedType('b', univ.Sequence())
        )
s1 = Sample()
s1['a'] = univ.Integer(1)

print 'hasvalue s1=', s1['b'].hasValue()

e_s1 = encoder.encode(s1)
print hexlify(e_s1)
s2 = decoder.decode(e_s1, asn1Spec=Sample())[0]

e_s2 = encoder.encode(s2)
print hexlify(e_s2)

print 'hasvalue s2=', s2['b'].hasValue()

Returns:

Sample 1
hasvalue s1= False
3003020101
3003020101
hasvalue s2= False
Sample 2
hasvalue s1= True
3003020101
3003020101
hasvalue s2= True

Could you please fix this?
Thanks in advance

DER encoding error

Hi

Cannot encode with version 0.2.4

How to reproduce

>>> from pyasn1.codec.der import encoder
>>> from pyasn1.type import univ
>>> seq = univ.Sequence()
>>> seq.setComponentByPosition(0, univ.ObjectIdentifier("1.2.643.2.2.35.1"))
Sequence().setComponentByPosition(0, ObjectIdentifier('1.2.643.2.2.35.1'))
>>> encoder.encode(seq)
Traceback (most recent call last):
  File "<pyshell#489>", line 1, in <module>
    encoder.encode(seq)
  File "C:\Python36\lib\site-packages\pyasn1\codec\der\encoder.py", line 40, in __call__
    return encoder.Encoder.__call__(self, client, defMode, maxChunkSize)
  File "C:\Python36\lib\site-packages\pyasn1\codec\cer\encoder.py", line 149, in __call__
    return encoder.Encoder.__call__(self, client, defMode, maxChunkSize)
  File "C:\Python36\lib\site-packages\pyasn1\codec\ber\encoder.py", line 474, in __call__
    self, value, defMode, maxChunkSize
  File "C:\Python36\lib\site-packages\pyasn1\codec\ber\encoder.py", line 61, in encode
    encodeFun, value, defMode, maxChunkSize
  File "C:\Python36\lib\site-packages\pyasn1\codec\ber\encoder.py", line 347, in encodeValue
    if namedTypes[idx].isOptional and not value[idx].isValue:
TypeError: 'NoneType' object is not subscriptable

deepcopy of `pyasn1.type.useful.FixedOffset` instance raises exception

Hi, here is how to reproduce it:

from copy import deepcopy

import pyasn1
from pyasn1.type.useful import GeneralizedTime

pyasn1.__version__
# '0.3.6'

dt = GeneralizedTime("20170916234254+0130").asDateTime
deepcopy(dt)

rises TypeError: __init__() takes exactly 3 arguments (1 given) in Python 2.7 or TypeError: __init__() missing 2 required positional arguments: 'offset' and 'name' in Python 3.5

Missing doc/source/conf.py in pyasn1-0.2.3.tar.gz hosted by pypi

When trying to build the documentation using the source from pypi's pyasn1-0.2.3.tar.gz, it fails as follows because doc/source/conf.py is missing from the tarball:

$ python ./setup.py build_sphinx
running build_sphinx
creating ~/pyasn1-0.2.3/build
creating ~/pyasn1-0.2.3/build/sphinx
creating ~/pyasn1-0.2.3/build/sphinx/doctrees
creating ~/pyasn1-0.2.3/build/sphinx/html
Running Sphinx v1.3.1
error: [Errno 2] No such file or directory: 'conf.py'

Will you include doc/source/conf.py in the future? Thanks!

save objects

Hi,
Is there a way to save asn1 schema objects? i tried pickle put it is not working for some reason. it does not allow __reduce__ operation !
Thanks

0.4.2 - optional univ.Null value is lost.

It had been fixed on 0.3.7 with manually applied PR #92 , but since 0.4.2 the same problem returned back.

RFC 4210/4210 PKIMessage - PKIBody - CertReqMessages - CertReqMsg has an optional popo field which looses 'raVerified' univ.Null().subtype(...) value on encoding.

Example (just an empty PKIMessage for 'cr' with popo = raVerified):
from pyasn1.type.char import IA5String
from pyasn1.type.univ import Integer, Null
from pyasn1.type.tag import TagSet, Tag
from pyasn1_modules.rfc4210 import PKIMessage, PKIHeader, PKIBody
from pyasn1_modules.rfc4211 import CertReqMsg, CertRequest, CertTemplate, ProofOfPossession
from pyasn1_modules.rfc2459 import GeneralName
from pyasn1.codec.der import encoder, decoder

header = PKIHeader()\
.setComponentByPosition(0, 'cmp2000')\
.setComponentByPosition(1, GeneralName().setComponentByPosition(1, IA5String('no@no', tagSet=TagSet((), Tag(tagClass=128, tagFormat=0, tagId=1)))))\
.setComponentByPosition(2, GeneralName().setComponentByPosition(1, IA5String('no@no', tagSet=TagSet((), Tag(tagClass=128, tagFormat=0, tagId=1)))))
body = PKIBody()
crms = body.getComponentByName('cr')
crms.setComponentByPosition(0, CertReqMsg().setComponentByPosition(0, CertRequest().setComponentByPosition(0, Integer(0)).setComponentByPosition(1, CertTemplate())).setComponentByPosition(1, ProofOfPossession().setComponentByPosition(0, Null(tagSet=TagSet((), Tag(tagClass=128, tagFormat=0, tagId=0))))))
msg = PKIMessage().setComponentByPosition(0, header).setComponentByPosition(1, body)
print(msg.prettyPrint())

data = encoder.encode(msg)
structure, _ = decoder.decode(data, asn1Spec=PKIMessage())
print('Output')
print(structure.prettyPrint())

Output for 0.3.7 with PR #92:
...
certTemplate=CertTemplate:

pop=ProofOfPossession:
 raVerified=

Output for 0.4.2:
...
certTemplate=CertTemplate:

And that's all.

DER and CER encoding not canonical

DER/CER encoding is supposed to be canonical, i.e., there is only one valid substrate for a value.

However:

>>> from pyasn1.type import univ
>>> from pyasn1.codec.der import der_encoder, der_decoder

>>> substrate1 = der_encoder.encode(univ.OctetString("long string"))
>>> substrate2 = der_encoder.encode(univ.OctetString("long string"), maxChunkSize=2)

>>> substrate1 != substrate2
True

>>> der_decoder.decode(substrate1)
(OctetString(b'long string', tagSet=TagSet((), Tag(tagClass=0, tagFormat=32, tagId=4))), b'')

>>> der_decoder.decode(substrate2)
(OctetString(b'long string', tagSet=TagSet((), Tag(tagClass=0, tagFormat=32, tagId=4))), b'')

The same happens with CER.

The problem here is that BER encoding actually forbids chunked strings, and CER exactly specifies when they are allowed. (See 9.2 and 10.2 in the X.690 spec)

Filters are not decoded correctly

I am using Python 3.6 and pyasn1 version 0.4.2 for receiving and decoding LDAP messages. The issue is that the client application generates filters, which cannot be decoded by pyasn1.

I decode LDAP messages in this way:

...
from ldap3.protocol.rfc4511 import LDAPMessage
from ldap3.strategy.sync import SyncStrategy
from pyasn1.codec.ber.decoder import decode
...
raw_messages = SyncStrategy(ldap_connection=conn).receiving()
ldap_resp, _ = decode(raw_message, asn1Spec=LDAPMessage())
...

Raw LDAP message:

b'0\x82\x01I\x02\x01\x05c\x81\xff\x04\x0fdc=arl,dc=local\n\x01\x02\n\x01\x03\x02\x01\x00\x02\x01\x00\x01\x01\x00\xa0W\xa3\x13\x04\x0bobjectClass\x04\x04user\xa1@\xa3\x1b\x04\rpostOfficeBox\x04\n01107ECBA2\xa3!\x04\x13extensionAttribute1\x04\n01107ECBA20\x81\x83\x04\rpostOfficeBox\x04\tgivenName\x04\x02sn\x04\x04mail\x04\rhomeDirectory\x04\x08memberOf\x04\nobjectGUID\x04\rpostOfficeBox\x04\x13extensionAttribute1\x04\x04mail\x04\x0esAMAccountName\xa0B0%\x04\x161.2.840.113556.1.4.319\x01\x01\xff\x04\x080\x06\x02\x02\x03\xe7\x04\x000\x19\x04\x172.16.840.1.113730.3.4.2'

Decoded LDAP message:

 messageID=5
 protocolOp=ProtocolOp:
  searchRequest=SearchRequest:
   baseObject=dc=arl,dc=local
   scope=wholeSubtree
   derefAliases=derefAlways
   sizeLimit=0
   timeLimit=0
   typesOnly=False
   filter=Filter:
    and=And:
     objectClass     postOfficeBox

   attributes=AttributeSelection:
    postOfficeBox    givenName    sn    mail    homeDirectory    memberOf    objectGUID    postOfficeBox    extensionAttribute1    mail    sAMAccountName

Message captured and decoded by Wireshark. See the complex filter and compare to the output from decoding in Python:

Lightweight Directory Access Protocol
    LDAPMessage searchRequest(5) "dc=server,dc=local" wholeSubtree
        messageID: 5
        protocolOp: searchRequest (3)
            searchRequest
                baseObject: dc=server,dc=local
                scope: wholeSubtree (2)
                derefAliases: derefAlways (3)
                sizeLimit: 0
                timeLimit: 0
                typesOnly: False
                Filter: (&(objectClass=user)(|(postOfficeBox=1234567890)(extensionAttribute1=1234567890)))
                    filter: and (0)
                        and: (&(objectClass=user)(|(postOfficeBox=1234567890)(extensionAttribute1=1234567890)))
                            and: 2 items
                                Filter: (objectClass=user)
                                    and item: equalityMatch (3)
                                        equalityMatch
                                            attributeDesc: objectClass
                                            assertionValue: user
                                Filter: (|(postOfficeBox=1234567890)(extensionAttribute1=1234567890))
                                    and item: or (1)
                                        or: (|(postOfficeBox=1234567890)(extensionAttribute1=1234567890))
                                            or: 2 items
                                                Filter: (postOfficeBox=1234567890)
                                                    or item: equalityMatch (3)
                                                        equalityMatch
                                                            attributeDesc: postOfficeBox
                                                            assertionValue: 1234567890
                                                Filter: (extensionAttribute1=1234567890)
                                                    or item: equalityMatch (3)
                                                        equalityMatch
                                                            attributeDesc: extensionAttribute1
                                                            assertionValue: 1234567890
                attributes: 11 items
        [Response In: 30]
        controls: 2 items
			Control
				controlType: 1.2.840.113556.1.4.319 (pagedResultsControl)
				criticality: True
				SearchControlValue
					size: 999
					cookie: <MISSING>
			Control
				controlType: 2.16.840.1.113730.3.4.2 (Manage DSA IT LDAPv3 control)

Could you please suggest if my code is wrong or it is a bug in decoding?

Thank you.

DER encoder doesn't sort SET by tags

The DER specification specifies that the contents of a SET must be ordered by their tags. This doesn't seem to be happening, the ordering is random.

pyasn1-0.3.5: can only concatenate tuple (not "str") to tuple

Hey there:

First of all, thanks for this library. We use it extensively in our impacket repository.

While investigating this issue, I came up with the following code not working:

from pyasn1.codec.der import encoder
from pyasn1.type import univ, namedtype, tag

class KERB_PA_PAC_REQUEST(univ.Sequence):
    componentType = namedtype.NamedTypes(
    namedtype.NamedType('include-pac', univ.Boolean().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    )

pacRequest = KERB_PA_PAC_REQUEST()
pacRequest['include-pac'] = True
print pacRequest.prettyPrint()
encodedPacRequest = encoder.encode(pacRequest)

print repr(encodedPacRequest)

Under pyasn1-0.3.5 I get the following traceback error:

Traceback (most recent call last):
  File "tt.py", line 12, in <module>
    encodedPacRequest = encoder.encode(pacRequest)
  File "/Users/beto/src/pyasn1-0.3.5/pyasn1/codec/ber/encoder.py", line 505, in __call__
    substrate = concreteEncoder.encode(value, self, **options)
  File "/Users/beto/src/pyasn1-0.3.5/pyasn1/codec/ber/encoder.py", line 73, in encode
    value, encodeFun, **options
  File "/Users/beto/src/pyasn1-0.3.5/pyasn1/codec/cer/encoder.py", line 145, in encodeValue
    substrate = encodeFun(value[idx], **options) + substrate
  File "/Users/beto/src/pyasn1-0.3.5/pyasn1/codec/ber/encoder.py", line 505, in __call__
    substrate = concreteEncoder.encode(value, self, **options)
  File "/Users/beto/src/pyasn1-0.3.5/pyasn1/codec/ber/encoder.py", line 89, in encode
    substrate = ints2octs(header + substrate)
TypeError: can only concatenate tuple (not "str") to tuple

while it works just fine with previous version.

Can you point out what are we doing wrong?

thanks.

0.3.1 no longer supports 0.1.x interface to GeneralizedTime/UTCTime

I hadn't pinned my version of pyasn1 yet on a new project, and got surprised by fresh installs into docker images. 0.3.1 gives the error:

'Uninitialized ASN.1 value ("__nonzero__" attribute looked up)'

when invoked by a library originally from Google Code (see this note for history). Some brief pdb work showed it related to GeneralizedTime() objects.

STR:

  1. ``git clone -b pyasn1_regression https://github.com/hwine/fx-sig-verify
  2. cd fx-sig-verify
  3. Setup and activate venv
    1. pip install -r requirements.txt # this will use pyasn1>=0.3.1
    2. pip install -e .
  4. Show issue
    1. fx-sig-verify tests/data/32bit.exe # throws exception
      $ pip freeze | grep pyasn1
      pyasn1==0.3.1
      $ fx-sig-verify tests/data/32bit.exe
      verbose 1 based on True
      Processing tests/data/32bit.exe
      Processing file of size 246056 (at 0)
      fail for tests/data/32bit.exe
      errors:
          failed to process local file tests/data/32bit.exe 'PyAsn1Error('Uninitialized ASN.1 value ("__nonzero__" attribute looked up)',)'
      
    2. pip install --upgrade pyasn1==0.2.3 # rollback to working verision
    3. fx-sig-verify tests/data/32bit.exe # no exception
      $ pip freeze | grep pyasn1
      pyasn1==0.2.3
      $ fx-sig-verify tests/data/32bit.exe
      verbose 1 based on True
      Processing tests/data/32bit.exe
      Processing file of size 246056 (at 0)
      pass for tests/data/32bit.exe
      

DER decoder is not thread-safe.

This causes problems for upstream oauth2client and GoogleCloudPlatform/gsutil#446.

The global pyasn1.codec.der.decoder.decode() function cannot be called safely by multiple threads, since it mutates shared state as it's decoding. This should either be documented or fixed.

Example stack traces look like:

Traceback (most recent call last):
  File "repro.py", line 40, in doit
    pyasn1.codec.der.decoder.decode(key_bytes, asn1Spec=_PKCS8_SPEC)
  File "/home/rmmh/pyasn1/pyasn1/codec/ber/decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "/home/rmmh/pyasn1/pyasn1/codec/ber/decoder.py", line 384, in valueDecoder
    asn1Object, component.effectiveTagSet, idx
  File "/home/rmmh/pyasn1/pyasn1/codec/ber/decoder.py", line 478, in _getComponentPositionByType
    return asn1Object.getComponentPositionNearType(tagSet, idx)
  File "/home/rmmh/pyasn1/pyasn1/type/univ.py", line 2294, in getComponentPositionNearType
    return self.componentType.getPositionNearType(tagSet, idx)
  File "/home/rmmh/pyasn1/pyasn1/type/namedtype.py", line 378, in getPositionNearType
    raise error.PyAsn1Error('Type position out of range')
PyAsn1Error: Type position out of range
Traceback (most recent call last):
  File "repro.py", line 40, in doit
    pyasn1.codec.der.decoder.decode(key_bytes, asn1Spec=_PKCS8_SPEC)
  File "/home/rmmh/pyasn1/pyasn1/codec/ber/decoder.py", line 1008, in __call__
    stGetValueDecoder, self, substrateFun
  File "/home/rmmh/pyasn1/pyasn1/codec/ber/decoder.py", line 384, in valueDecoder
    asn1Object, component.effectiveTagSet, idx
  File "/home/rmmh/pyasn1/pyasn1/codec/ber/decoder.py", line 478, in _getComponentPositionByType
    return asn1Object.getComponentPositionNearType(tagSet, idx)
  File "/home/rmmh/pyasn1/pyasn1/type/univ.py", line 2294, in getComponentPositionNearType
    return self.componentType.getPositionNearType(tagSet, idx)
  File "/home/rmmh/pyasn1/pyasn1/type/namedtype.py", line 375, in getPositionNearType
    return idx + self.__ambigiousTypes[idx].getPositionByType(tagSet)
  File "/home/rmmh/pyasn1/pyasn1/type/namedtype.py", line 268, in getPositionByType
    raise error.PyAsn1Error('Type %s not found' % (tagSet,))
PyAsn1Error: Type [0:0:2] not found

Here's a test script to reproduce the problem. Run it like while :; do python repro.py; done. This broke starting with v0.2.3, and is still broken in v0.3.1 (the current head):

import StringIO
import thread
import threading
import time
import traceback

##### reduced from oauth2client/_pure_python_crypt.py
import pyasn1.codec.der
from pyasn1_modules import pem
from pyasn1_modules.rfc5208 import PrivateKeyInfo

# openssl genrsa 128 | openssl pkcs8 -topk8 -nocrypt
private_key = '''
-----BEGIN PRIVATE KEY-----
MHkCAQAwDQYJKoZIhvcNAQEBBQAEZTBjAgEAAhEA21r9c7vaSvSGeMdxqwd1gwID
AQABAhEAqYVwSnjrAvD4lPq/wukgAQIJAO15hoI6gaODAgkA7HedWRHwRgECCHIw
Ik6ShW2zAghg3FpSqttuAQIJAOzQGuAR1uhh
-----END PRIVATE KEY-----
'''

_PKCS1_MARKER = ('-----BEGIN RSA PRIVATE KEY-----',
                 '-----END RSA PRIVATE KEY-----')
_PKCS8_MARKER = ('-----BEGIN PRIVATE KEY-----',
                 '-----END PRIVATE KEY-----')
_PKCS8_SPEC = PrivateKeyInfo()

marker_id, key_bytes = pem.readPemBlocksFromFile(
    StringIO.StringIO(private_key), _PKCS1_MARKER, _PKCS8_MARKER)

assert marker_id == 1  # PCKS_8
#########################

THREADS = 10
event = threading.Event()
out_lock = threading.Lock()

def doit():
    event.wait()
    try:
        pyasn1.codec.der.decoder.decode(key_bytes, asn1Spec=_PKCS8_SPEC)
    except:
        with out_lock:
            traceback.print_exc()

for _ in range(THREADS):
    thread.start_new_thread(doit, ())

event.set()
time.sleep(.02)

Infinite recursion when importing asn1ate output

After upgrading from pyasn1 0.2.3 to 0.3.2, importing asn1ate output takes about 1 minute, and allocates ~6 GB memory. Same with current master. I would guess it is due to some (almost) infinite recursion. It completes importing instantly with versions 0.2.3 and 0.3.1.

Here, I interrupted execution:

(hostcom) C:\Users\Per\code\zforce-application-simulator\hostcom\neonode_hostcom>python -m nn_parser
Traceback (most recent call last):
  File "c:\users\per\anaconda2\Lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\users\per\anaconda2\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\neonode_hostcom\nn_parser.py", line 585, in <module>
    namedtype.OptionalNamedType('errorThresholds', ErrorThresholds().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 34)))
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 115, in __init__
    self.__ambiguousTypes = self.__computeAmbiguousTypes()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 232, in __computeAmbiguousTypes
    ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes)
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 114, in __init__
    self.__tagToPosMap = self.__computeTagToPosMap()
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\namedtype.py", line 200, in __computeTagToPosMap
    tagMap = namedType.asn1Object.tagMap
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\base.py", line 69, in tagMap
    return tagmap.TagMap({self.tagSet: self})
  File "C:\Users\Per\code\zforce-application-simulator\hostcom\hostcom\lib\site-packages\pyasn1\type\tagmap.py", line 35, in __init__
    def __init__(self, presentTypes=None, skipTypes=None, defaultType=None):
KeyboardInterrupt

References

asn1ate command:

(hostcom) C:\Users\Per\code\zforce-application-simulator\hostcom\neonode_hostcom>python -m asn1ate.pyasn1gen ..\protocol\zforce_pdu_def.asn > nn_parser.py

Python:

(hostcom) C:\Users\Per\code\zforce-application-simulator\hostcom\neonode_hostcom>python
Python 2.7.13 |Continuum Analytics, Inc.| (default, May 11 2017, 13:17:26) [MSC v.1500 64 bit (AMD64)] on win32

Modules:

(hostcom) C:\Users\Per\code\zforce-application-simulator\hostcom\neonode_hostcom>pip freeze
asn1ate==0.5
future==0.16.0
hidapi==0.7.99.post20
-e git+ssh://git@bitbucket.neonode.local:7999/~per.rosengren/hostcom-py.git@4cf1e6b04fa0d4eb5d3951afd87724eedb4cf3c0#egg=neonode_hostcom&subdirectory=..\..\hostcom
numpy==1.13.1
pyasn1==0.3.3
pyparsing==2.2.0

The ASN.1 PDU definition:

-- Neonode zForce Communication Protocol ASN.1 PDU definition
-- Protocol ASN.1 PDU Definition for Platform Version 7
-- Status: Draft
-- Definition version: 1.5-WIP
-- Last update: 2016-06-13
-- See end of document for changelog

ProtocolMessage DEFINITIONS IMPLICIT TAGS EXTENSIBILITY IMPLIED ::=
BEGIN

	-- General notes;
	-- items typed as INTEGER are unsigned, unless
	-- explicitly using the SignedInteger datatype
	
	-- -------------------------------------------- --
	-- Top level PDU								--
	-- -------------------------------------------- --

	-- Top level container of choice type, to be able to
	-- give implicit tag identifier. To replicate old protocol
	-- PRIVATE 14 generates id EE using DER encoding
	ProtocolMessage ::= CHOICE {
		request [PRIVATE 14] Message,
		response [PRIVATE 15] Message,
		notification [PRIVATE 16] Notification
	}

	-- General top level info:
	-- Request is sent from host to device, and is
	-- responded to with a response. The structure
	-- of both request and response are the same,
	-- the Message sequence.

	-- Notifications are reports from the platform
	-- to the host that are not explicitly requested.
	-- This contains startup information and touch
	-- notifications.

	-- -------------------------------------------- --
	-- Message - Input & Output						--
	-- -------------------------------------------- --

	-- Used for input and output to the system.
	-- In the request case the host device will send a
	-- top level Message with the request identifier and
	-- fill it out with operations to perform.

	-- The system will respond with response messages
	-- contained in a Message with the response identifier
	-- including requested data or operation results.

	-- General way of working:

	-- To perform a get request, make sure to send the
	-- message with an empty sequence for the data being
	-- requested

	-- To perform a set request, send the message with
	-- the sequence for the command filled with the
	-- appropriate parameters as payload

	-- All requests will get a response message with
	-- the sequences existing in the request message
	-- filled with their current values. If a set
	-- request was performed the returned value should
	-- be checked to verify the operation was successful

	-- The current communications layer handles a single
	-- command/sequence at a time. As such each setting
	-- should be sent in their own message.

	Message ::= SEQUENCE {
		deviceAddress DeviceAddress OPTIONAL,
		-- Used to address a specific device when multiple devices are in the same system.
		-- For request, the last value is kept so multiple requests to the same
		-- device only needs to include the deviceAddress in the first of the requests.

		-- Command/Message to start.
		-- Do all configuration before issuing.
		enable [APPLICATION 5] SEQUENCE {
			disable [0] NULL OPTIONAL,

			-- Send enable with value 0 to enable continuous mode.
			-- If any other value is given, scanning will stop
			-- after that number of frames of data has been sent.
			-- This is useful for diagnostics scans and robot measurements.
			enable [1] INTEGER (0..127) OPTIONAL,

			reset [2] NULL OPTIONAL
		} OPTIONAL,
		-- If enable is in a set request, e.g. populated with any member,
		-- no more commands should be included in the same message.


		-- Request for touch format descriptor. See TouchDescriptor
		--	in primitive data types section below for more info.
		touchFormat [APPLICATION 6] SEQUENCE { -- Read only, touchDescriptor will be ignored in request message
			touchDescriptor TouchDescriptor OPTIONAL
		} OPTIONAL,

		-- The various types of data that can be reported
		-- are controlled indepentenly by sending boolean
		-- values for them.
		operationMode [APPLICATION 7] SEQUENCE {	-- Initial state after power up
			detection [0] BOOLEAN OPTIONAL,			-- Enabled
			signals [1] BOOLEAN OPTIONAL,			-- Disabled
			ledLevels [2] BOOLEAN OPTIONAL,			-- Disabled
			detectionHid [3] BOOLEAN OPTIONAL,		-- Only for USB Equipped devices - Disabled
			gestures [4] BOOLEAN OPTIONAL			-- Only for gesture supporting devices - Enabled
		} OPTIONAL,

		-- Target frequency for different modes of operation
		frequency [APPLICATION 8] SEQUENCE {
			finger [0] INTEGER OPTIONAL,
			stylus [1] INTEGER OPTIONAL,
			idle [2] INTEGER OPTIONAL
		} OPTIONAL,

		-- Scaling factor for coordinates reported.
		-- Does not affect internal working resolution.
		resolution [APPLICATION 9] SEQUENCE {
			x [0] INTEGER OPTIONAL,
			y [1] INTEGER OPTIONAL,
			z [2] INTEGER OPTIONAL
		} OPTIONAL,

		-- Diagnostic method for reporting open or short LEDs/PDs.
		-- Always run on platform level, as such all ASICs independent of device will be reported.
		-- OpenShortInformation in constructed data types provides more info
		openShort [APPLICATION 10] SEQUENCE { -- Read only, openShortInfo will be ignored in request message
			openShortInfo [0] SEQUENCE OF OpenShortInformation OPTIONAL,	-- One result set for each ASIC
			errorCount [1] INTEGER (0..127) OPTIONAL	-- Total number of open and short errors encountered across
			-- all ASICs. Should always be 0 on a correctly assembled system.
			-- If larger than 127 the number is restricted to 127.
		} OPTIONAL,

		-- Static information about the platform or a device can be fetched by requesting deviceInformation
		deviceInformation [APPLICATION 12] SEQUENCE {-- Read only, all parameters will be ignored in request message

			-- Information returned when deviceInformation is addressed to the platform device
			platformInformation [0] SEQUENCE {
				platformVersionMajor	[0] INTEGER (0..32767) OPTIONAL,
				platformVersionMinor	[1] INTEGER (0..32767) OPTIONAL,
				protocolVersionMajor    [2] INTEGER (0..32767) OPTIONAL,
				protocolVersionMinor    [3] INTEGER (0..32767) OPTIONAL,
				firmwareVersionMajor	[4] INTEGER (0..32767) OPTIONAL,
				firmwareVersionMinor	[5] INTEGER (0..32767) OPTIONAL,
				hardwareIdentifier		[6] IA5String OPTIONAL,
				hardwareVersion			[7] IA5String OPTIONAL,
				asicType				[8] AsicType OPTIONAL,
				numberOfAsics			[9] INTEGER (0..127) OPTIONAL,
				mcuUniqueIdentifier		[10] OCTET STRING (SIZE(0..32)) OPTIONAL,
				-- MCU Serial or die and chip identifier when such is available
				projectReference  [11] IA5String OPTIONAL,
				platformReference [12] IA5String OPTIONAL,
				buildTime         [13] IA5String OPTIONAL,
				buildDate         [14] IA5String OPTIONAL
			} OPTIONAL,

			-- Information returned from other device instances. Please note that
			-- each instance, if more than one available according to deviceCount,
			-- may return different data, as they are configured independently.
			deviceInstanceInformation [1] SEQUENCE {					-- Device type restrictions
				productVersionMajor	[0] INTEGER (0..32767) OPTIONAL,
				productVersionMinor	[1] INTEGER (0..32767) OPTIONAL,
				physicalWidth		[2] INTEGER (0..32767) OPTIONAL,
				physicalHeight		[3] INTEGER (0..32767) OPTIONAL,	-- N/A for Air Devices
				numberOfSignalAxes	[4] INTEGER (0..32767) OPTIONAL,
				signalsPerSignalAxis [5] SEQUENCE OF [0] INTEGER OPTIONAL,
				-- Added in protocol 1.1
				ledsPerPhysicalAxis [6] SEQUENCE OF [0] INTEGER OPTIONAL,
				pdsPerPhysicalAxis [7] SEQUENCE OF [0] INTEGER OPTIONAL,
				ledPdPlacementPerPhysicalAxis [8] SEQUENCE OF [0] LedPdPlacement OPTIONAL
			} OPTIONAL,

			-- If device contains any readable or writable storage areas
			-- each such area will be presented with a StorageArea sequence
			storageInformation [2] SEQUENCE {
				storageAreas [0] SEQUENCE OF [0] StorageArea,

				-- Buffer size indicators, to indicate maximum payloads
				maxReadSize [1] INTEGER,
				maxWriteSize [2] INTEGER
			} OPTIONAL,

			-- Response type expected from devices of type lightingDevices
			-- Provides metadata about the type and amount of available lights
			lightingInformation [3] SEQUENCE {
				numberOfLeds [0] INTEGER OPTIONAL,
				bitsPerLedChannel [1] SEQUENCE OF [0] INTEGER OPTIONAL
				-- Regular LEDs will only give a single channel while
				-- RGB LEDs will give three integers, one for each color channel
				-- Simple on/off channels will only be a single bit while
				-- channels with controllable intensity will have multiple bits
			} OPTIONAL

		} OPTIONAL,

		-- To be able to enumerate the virtual devices a request for deviceCount gives
		-- the count of each type of device.
		deviceCount [APPLICATION 15] SEQUENCE {-- Read only, all parameters will be ignored in request message
			totalNumberOfDevices	[0] INTEGER (0..127) OPTIONAL,
			-- Total number of devices does not include the platform and
			-- will always equal the sum of the other members of the sequence.

			-- Devices of which there are none is not reported.
			coreDevices				[1] INTEGER (0..127) OPTIONAL,
			airDevices				[2] INTEGER (0..127) OPTIONAL,
			plusDevices				[3] INTEGER (0..127) OPTIONAL,
			lightingDevices			[4] INTEGER (0..127) OPTIONAL
		} OPTIONAL,

		status [APPLICATION 13] SEQUENCE { -- Read only, all parameters will be ignored in request message
			-- If you want to restrict the get request to a subset, include a empty sequence corresponding
			-- to the subset you want. If left entirely empty the full get response will be provided
			counters [0] SEQUENCE {
				currentContacts			[0] INTEGER (0..127) OPTIONAL,
				scanningCounter			[1] INTEGER (0..65535) OPTIONAL,
				preparedTouchCounter	[2] INTEGER (0..65535) OPTIONAL,
				sentTouchCounter		[3] INTEGER (0..65535) OPTIONAL,
				invalidTouchCounter		[4] INTEGER (0..65535) OPTIONAL
			} OPTIONAL
		} OPTIONAL,
		
		resultCode [APPLICATION 20] INTEGER {
			ok (0),
			fail (1)
		} OPTIONAL,

		-- Instance specific settings for a device
		deviceConfiguration [APPLICATION 19] SEQUENCE {
			-- Set / get the number of touches to be tracked:
			numberOfTrackedTouches	[0] INTEGER (0..255) OPTIONAL,
			-- Set / get the minimal distance for updating a tracked touch in move state
			trackingMinDistanceMove	[1] INTEGER (0..16383) OPTIONAL,
			-- Set / get the sub touch active area low bound in X coordinate
			subTouchActiveArea		[2] SEQUENCE {
				-- Write Request and Read Response only:
				-- Set / get the sub touch active area low bound in X coordinate
				lowBoundX		[0] INTEGER (0..16383) OPTIONAL,
				-- Set / get the sub touch active area low bound in Y coordinate
				lowBoundY		[1] INTEGER (0..16383) OPTIONAL,
				-- Set / get the sub touch active area high bound in X coordinate
				highBoundX	[2] INTEGER (0..16383) OPTIONAL,
				-- Set / get the sub touch active area high bound in Y coordinate
				highBoundY	[3] INTEGER (0..16383) OPTIONAL,
				-- subTaa Reverse X coordinates, set / get true or false
				reverseX		[4] BOOLEAN OPTIONAL,
				-- SubTaa Reverse Y coordinates, set / get true or false
				reverseY		[5] BOOLEAN OPTIONAL
			} OPTIONAL,
			
			-- configure the reference signal setting
			referenceSignalConfig	[3] INTEGER (0..255) OPTIONAL,

			-- Restriction of detected objects based on their size
			sizeRestriction [4] SEQUENCE {
				maxSizeEnabled			[0] BOOLEAN OPTIONAL,
				maxSize					[1] INTEGER (0..255) OPTIONAL,
				minSizeEnabled			[2] BOOLEAN OPTIONAL,
				minSize					[3] INTEGER (0..255) OPTIONAL
			} OPTIONAL,

			-- configure the detection mode
			-- Standard modes increasing from 0, custom modes decreasing from 64
			-- Giving an unlisted value will have no effect.
			detectionMode [5] INTEGER {
				-- Reserved modes from (0) to (63) are listed below:
				default (0),		-- finger and stylus are both enabled
				finger (1),
				-- stylus (2),

				-- Special modes for customized applications are listed below:
				mergeTouches (32), -- merges all touch objects into one
				insensitiveFTIR (64)
			} OPTIONAL,

			-- Set / get the number of touches to be reported:
			numberOfReportedTouches	[6] INTEGER (0..255) OPTIONAL

		} OPTIONAL,

		-- Configurable options useful for retrieving diagnostic information
		diagnosticsSettings [APPLICATION 21] SEQUENCE {

			-- If fixedStrength is set, the next scan uses the
			-- set strength for all LEDs. The value is cleared upon receiving
			-- a disable command, or the fixed number of scans are done.
			fixedStrength [0] INTEGER (0..255) OPTIONAL,

			-- If forceCalibration is set to anything other than 0
			-- the device will recalibrate itself next time it is
			-- enabled. As a recalibration of led levels is needed
			-- when the ASIC gain is calibrated, this is included
			-- in the same settings level.
			-- Not cleared on disable/end of fixed number scan,
			-- so make sure to set to noCalibration when done.
			-- Ignored if fixedStrength is set at the same time.
			forceCalibration [1] INTEGER {
				noCalibration (0),
				calibrateLedLevels (1),
				calibrateLedLevelsWithHighestASICGain (2)
			} OPTIONAL,

			-- To enable filtering or normalization of raw signals
			-- reported, enable it here.
			rawSignalFiltering [2] INTEGER {
				disabled (0),
				enabled (1)
			} OPTIONAL,

			-- For systems with calibration data the storage area currently
			-- being used is indicated and set by altering the following parameter.
			calibrationStorageAreaInUse [3] StorageIdentifier OPTIONAL,

			-- Sends Air maximum filter result.
			signalMaximum [4] BOOLEAN OPTIONAL

		} OPTIONAL,

		-- Storage operations, available for storage devices
		-- Only one type of operation can be performed per request
		storageOperation [APPLICATION 25] SEQUENCE {
			storageIdentifier [0] StorageIdentifier,

			operationType [1] INTEGER {
				read (0),
				write (1),
				delete (2)
			},

			-- Offset into the storage area.
			-- Offset + size should never exceed the size of the storage area
			offset [2] INTEGER,
			size [3] INTEGER,

			-- Payload should only be populated in the request
			-- when doing a write operation. It will only be
			-- populated in a response after a read operation
			payload [4] OCTET STRING OPTIONAL,

			-- Operation status code should never be
			-- included in requests, only returned in responses.
			-- This indicates the status 
			operationStatusCode [5] INTEGER {
				success (0),
				genericError (1), -- For errors without specific status code
				outOfBounds (2), -- Read or write outside of storage area
				mediaNotPresent (3), -- For removable media
				identifierError (4), -- Storage with identifier does not exist.
				bufferOverflow (5), -- Storage read or write buffer not big enough for request.
				writeProtected (6), -- Storage is write protected, maybe ROM type.
				deleteNotApplicable (7) -- Delete attempted on media where operation not available
			} OPTIONAL

		} OPTIONAL,
		signalsLayout [APPLICATION 18] Vector OPTIONAL,

		-- For altering state of RGB LEDs on a device
		-- It is write only, and will only generate an empty sequence
		-- as a response to keep bandwidth usage low.
        lighting [APPLICATION 26] SEQUENCE {
            presenceBitMask [0] BIT STRING OPTIONAL,
            -- To avoid having to send state for all LEDs every
            -- time, this bitmask signifies the LEDs for which
            -- the state is to be changed. To set a LED to a
            -- specific color make sure to include it in the bitMask
            -- and send the color values in the right position of the
            -- state OCTET STRING

            state [1] OCTET STRING OPTIONAL,
            -- State data for the LEDs to be set.
            -- presenceBitMask indicates in rising order
            -- what LEDs' states are included in the payload. 

            -- Expected format of each state is according to the
            -- number of bits per channel in the deviceInformation,
            -- where each channel is 0-padded to be evenly aligned
            -- on byte boundaries.

            -- The size of the entire state payload should be a
            -- multiple of the total state size per LED.
            -- The maximum size will be the number of bits enabled in
            -- precenceBitMask * total size per LED.
            -- If state contains a smaller payload than maximum the
            -- last state information is repeated for all successive LEDs
            -- As such, to set all LEDs to the same state only a single state
            -- payload is required while setting all bits enabled in the
            -- presenceBitMask

            -- Some examples:
            -- Type    - Bits per channel   - Size per LED state
            -- On/Off  - 1                  - 1 byte
            -- Single  - 8                  - 1 byte
            -- RGB LED - 8, 8, 8            - 3 byte
            
            globalIntensity [2] INTEGER (0..65535) OPTIONAL
            -- Allows you to control the intensity level for all
            -- LEDs at the same time.

        } OPTIONAL,

		-- Low signal information.
		-- Get the comparing results between all signals to a minimal
		-- signal alert level.
		lowSignal [APPLICATION 28] SEQUENCE {
			-- Bit mask stating which signals having low signal error.
			lowSignalInfo [0] BIT STRING OPTIONAL
		} OPTIONAL,

		-- For systems where error counters are available,
		-- they can be cleared by sending a NULL value
		errorCounterClear [APPLICATION 31] NULL OPTIONAL,
		
		-- Error Information.
		-- Only Platform responds to this.
		errorInformation [APPLICATION 32] ErrorInformation OPTIONAL,
		
		-- Ask device to stream the Error Log for either a specific session,
		-- the current session (specify -1 as value) or all sessions (-2).
		-- The Error Log is streamed using ErrorLog entries.
		-- See the "errorLog" entry in StatusNotification for the Notification sent.
		-- Only Platform responds to this.
		errorLog [APPLICATION 33] INTEGER {
			currentSession (-1),
			allSessions (-2)
		} OPTIONAL,
		
		-- Get or Set Error Thresholds.
		errorThresholds [APPLICATION 34] ErrorThresholds OPTIONAL
	}

	-- -------------------------------------------- --
	-- Notifications - Touch data					--
	-- -------------------------------------------- --

	Notification ::= SEQUENCE {
		deviceAddress DeviceAddress OPTIONAL,
		-- Present when more than one device is available in system.
		-- Indicates the source of the notification message.
		
		notificationMessage CHOICE {
			singleTouch TouchNotification,
			-- This will be used in cases where only single touch is available.

			touchNotifications [0] SEQUENCE (SIZE(0..127)) OF TouchNotification,
			-- In cases where multi touch of 2 or more touches will be available
			-- this sequence will be used.

			-- The payload, sizes and offsets for each TouchNotification
			-- is described by the TouchDescriptor bit string

			bootCompleteNotification BootCompleteNotification,
			-- BootCompleteNotification is sent upon system start,
			-- see definition of BootCompleteNotification further down
			-- to see what flags and states are reported

			ledLevels [APPLICATION 11] RawData,
			coreSignals  [APPLICATION 14] RawData,
			airSignals  [APPLICATION 17] Vector,
			airMaximum  [1] Vector,
			statusNotification StatusNotification,
			gestureNotifications [2] SEQUENCE (SIZE(0..127)) OF GestureNotification
		},

		notificationTimestamp Timestamp OPTIONAL,
		-- For notifications which have use of temporal data
		-- the notification contains a timestamp
		
		notificationLatency Latency OPTIONAL
		-- For notifications which have use of temporal data
		-- the notification contains a processing latency value.
		-- Currently this is only used for TouchNotification.
		-- For touchNotification, the latency time starts from the
		-- beginning of the first frame after a touch object
		-- presented in active area, and ends at the current touch
		-- notification encoded.
	}

	-- -------------------------------------------- --
	-- Primitive Data Types							--
	-- -------------------------------------------- --

	DeviceAddress ::= [APPLICATION 0] OCTET STRING (SIZE (2))
	-- Addressing information used when multiple touch devices are present
	-- in the system.
	-- Byte0 - deviceType, Byte1 - deviceIndex
	-- DeviceTypes:	0x00	-	Platform
	--				0x01	-	zForce Core
	--				0x02	-	zForce Air
	--				0x03	-	zForce Plus
	--				0x04	-	Lighting devices

	TouchDescriptor ::= [APPLICATION 1] BIT STRING
	{
	-- Bitmask descriptor outlining the payload each
	-- TouchNotification contains.
	-- Name (bit)			-  Description		- size		- comment
		id (0),				-- Touch Identifier	- 1 byte
		event (1),			-- Up/Down/Move		- 1 byte	- 0=Down; 1=Move; 2=Up; 3=Invalid; 4=Ghost
		loc-x-byte1 (2),	-- X coordinate		- 1 byte
		loc-x-byte2 (3),	-- X expanded		- 1 byte	- for higher precision
		loc-x-byte3 (4),	-- X expanded		- 1 byte	- for higher precision
		loc-y-byte1 (5),	-- Y coordinate		- 1 byte
		loc-y-byte2 (6),	-- Y expanded		- 1 byte	- for higher precision
		loc-y-byte3 (7),	-- Y expanded		- 1 byte	- for higher precision
		loc-z-byte1 (8),	-- Z coordinate		- 1 byte
		loc-z-byte2 (9),	-- Z expanded		- 1 byte	- for higher precision
		loc-z-byte3 (10),	-- Z expanded		- 1 byte	- for higher precision
		size-x-byte1 (11),	-- X size			- 1 byte
		size-x-byte2 (12),	-- X size			- 1 byte	- for higher precision
		size-x-byte3 (13),	-- X size			- 1 byte	- for higher precision
		size-y-byte1 (14),	-- Y size			- 1 byte
		size-y-byte2 (15),	-- Y size			- 1 byte	- for higher precision
		size-y-byte3 (16),	-- Y size			- 1 byte	- for higher precision
		size-z-byte1 (17),	-- Z size			- 1 byte
		size-z-byte2 (18),	-- Z size			- 1 byte	- for higher precision
		size-z-byte3 (19),	-- Z size			- 1 byte	- for higher precision
		orientation (20),	-- Orientation		- 1 byte	- Hand orientation
		confidence (21),	-- Confidence		- 1 byte
		pressure (22)		-- Pressure			- 1 byte
	}
	-- Total maximum size:    23 bytes per touch

	TouchNotification ::= [APPLICATION 2] OCTET STRING
	-- Binary payload with content as outlined by TouchDescriptor

	Timestamp ::= [APPLICATION 24] INTEGER
	-- Timestamps for general use
	
	Latency ::= [APPLICATION 35] INTEGER
	-- Latency value for measurement use. Payload value is in millisecond unit.
	
	-- List of known ASIC types
	AsicType ::= INTEGER {
		nn1001 (1),
		nn1002 (2),
		nn1003 (3)
	}

	-- Addressing method for storage areas
	StorageIdentifier ::= INTEGER (0..127)

	-- Explicit notification for integers that
	-- contains signed values
	SignedInteger ::= INTEGER

	-- LED and PD placement types
	LedPdPlacement ::= INTEGER {
		pdFirstPdLast (0),
		pdFirstLedLast (1),
		ledFirstPdLast (2),
		ledFirstLedLast (3)
	}
	
	-- -------------------------------------------- --
	-- Constructed Data Types						--
	-- -------------------------------------------- --

	GestureNotification ::= [APPLICATION 4] SEQUENCE {
		gestureStatus [0] INTEGER {
			detection (0),	-- New gesture detected
			update (1),		-- Update of previously detected gesture
			stop (2)		-- Final update for previously detected gesture
		},

		-- Unique identifier for the gesture notification.
		-- If status is detection the first unoccupied ID is used,
		-- otherwise the ID is related to a previously detected gesture.
		gestureIdentifier [1] INTEGER OPTIONAL,

		gestureType [2] INTEGER {
--			Type				Continuous/Single Shot	Generic/Specific case	iOS Equivalent			Android equivalent
			tap (0),		--	Single Shot				Generic					UITapGesture			onDown / onSingleTapUp / onDoubleTap (GestureDetector)
			longPress (1),	--	Continuous				Generic					UILongPressGesture		onLongPress (GestureDetector)
			swipe (2),		--	Continuous				Generic					UISwipeGesture			onFling (GestureDetector)
			pan (3),		--	Continuous				Generic					UIPanGesture			onScroll (GestureDetector)
			pinch (4),		--	Continuous				Generic					UIPinchGesture			onScale (ScaleGestureDetector)
			rotation (5),	--	Continuous				Generic					UIRotationGesture		Not available
			grab (6),		--	Continuous				Steering Wheel specific	N/A						N/A
			rimTap (7)		--	Single Shot				Steering Wheel specific	N/A						N/A
		},

		originX [3] INTEGER OPTIONAL,
		originY [4] INTEGER OPTIONAL,

		sizeX [5] INTEGER OPTIONAL,
		sizeY [6] INTEGER OPTIONAL,
		
		deltaX [7] SignedInteger OPTIONAL,
		deltaY [8] SignedInteger OPTIONAL
	}
	
	-- Startup notification, indicating reset causes, proper ASIC
	-- function and global state before reset, in case of watchdog reset
	BootCompleteNotification ::= [APPLICATION 3] SEQUENCE {
		asicStatus [0] INTEGER
		{
			asicExists (0),
			asicNotFound (1)
		},
		resetSource [1] BIT STRING
		{
			powerUp (0),
			rstLow (1),
			watchdogExpired (2),
			flashViolation (3),
			nonMaskableInterrupt (4)
		},
		globalState [2] BIT STRING
		{
			watchDogExpiredWaitingForASICIRQ (0),
			watchDogExpiredWaitingForSPITXComm (1),
			watchDogExpiredWaitingForSPIRXComm (2),
			watchDogExpiredUnhandledIRQ (3),
			asicFlaggedUnexpectedPOR (4),
			asicFlaggedTSDFault (5),
			asicFlaggedVBGFault (6),
			asicFlaggedMemOverFlow (7)
		}
	}

	RawData ::= SEQUENCE OF VariableSizeIntegerString
	
	VariableSizeIntegerString ::= CHOICE
	{
		uint8 [0] OCTET STRING,
		uint12 [1] OCTET STRING,
		uint16 [2] OCTET STRING
	}
	
	-- A sequence containing the results for all LEDs and PDs
	-- of an Open Short test on an ASIC
	OpenShortInformation ::= [APPLICATION 23] SEQUENCE {
		asicIndex [0] INTEGER OPTIONAL,	-- Which ASIC the results belong to.
		ledOpen [1] BIT STRING,		-- Bit mask stating which LEDs indicate a open fault
		ledShort [2] BIT STRING,	-- Bit mask stating which LEDs indicate a short fault
		pdOpen [3] BIT STRING OPTIONAL,		-- Bit mask stating which PDs indicate a open fault
		-- NN1001 does not support PD open checks, so this may be omitted
		pdShort [4] BIT STRING		-- Bit mask stating which PDs indicate a short fault
	}

	-- For devices providing reading and writing of data to volatile or non-volatile
	-- memory, each available area that can be addressed will be described using a
	-- StorageArea sequence for each area.
	StorageArea ::= SEQUENCE {
		storageIdentifier [0] StorageIdentifier,
		-- Integer index required to pinpoint the specific storage area, to allow
		-- for multiple storage areas associated with the same device.
		storageDescription [1] IA5String (SIZE(0..32)) OPTIONAL,
		-- Description about the intended usage for this storage,
		-- e.g. Calibration, Configuration etc.
		storageType [2] INTEGER {
			rom (0),
			flash (1),
			eeprom (2),
			ram (3),
			asicRegister (4),
			asicSram (5)
		} OPTIONAL,
		storageLocation [3] INTEGER {
			internal (0), -- e.g. MCU flash memory
			external (1), -- e.g. external flash chip
			removable (2) -- e.g. SD card
		} OPTIONAL,
		storageSize [4] INTEGER
		-- Total size of the storage area.
		-- Adressable space will always be 0 <= address < storageSize

--		deleteLevel [5] INTEGER {
--			byteLevel (0),
--			blockLevel (1)
--		} OPTIONAL,
		-- If deletions for this storage area is done on
		-- block level, with lesser granularity than a byte
		-- it is indicated by deleteLevel

--		blockSize [6] INTEGER OPTIONAL,
		-- If deleteLevel is indeed an block level operation
		-- the block size is necessary to know starting addresses
		-- and block sizes of affected data.

	}	

	Vector ::= SEQUENCE {
		dataType [0] ENUMERATED {
			uint8 (0),
			int8 (1),
			uint12 (2),
			int12 (3),
			uint16 (4),
			int16 (5),
			uint24 (6),
			int24 (7),
			uint32 (8),
			int32 (9),
			uint64 (10),
			int64 (11),
			float (12),
			double (13)
		} OPTIONAL,
		shape [1] SEQUENCE OF [0] INTEGER OPTIONAL,
		-- data format:
		-- Row major order (C)
		-- Big endian. When LSB is a partial octet, it is in the most significant bits
		-- no padding
		data [2] OCTET STRING OPTIONAL
	}
	
	StatusNotification ::= [APPLICATION 27] SEQUENCE {
		-- Hardware Error detected. This only signals that it has occured, not what it is.
		-- That is read seperately.
		hardwareError [0] NULL OPTIONAL,
		
		-- True if the device is receiving touches on a single axis. This can be due to
		-- for example a user touching the outside of the light guide, thereby changing
		-- the reflectiveness of the mirror.
		-- False if it is no longer detected.
		singleAxisTouchError [1] BOOLEAN OPTIONAL,

		-- True if touches are no longer detected and sent.
		-- False if touches are now sent normally.
		touchesIgnored [2] BOOLEAN OPTIONAL,
		
		-- True if any signal is lower than predefined minimum level.
		-- False if all the signals are back to normal level.
		lowSignalError [3] BOOLEAN OPTIONAL,
		
		-- Hardware Error Detected. This also contains specifics about the error.
		-- Replaces hardwareError above.
		error [4] ErrorNotification OPTIONAL,

		-- Error Log Transfer.
		errorLog [5] ErrorLog OPTIONAL
	}

	ErrorInformation ::= SEQUENCE {
		systemTests [0] SystemErrorInformation OPTIONAL,
		asics [1] SEQUENCE OF [0] AsicInformation OPTIONAL,
		visibleLedDrivers [2] SEQUENCE OF [0] VisibleLedDriverInformation OPTIONAL
	}
	
	SystemErrorInformation ::= SEQUENCE {
		cpu [0] ErrorFlags OPTIONAL,					-- CPU Error Detected.
		internalWatchdog [1] ErrorFlags OPTIONAL,		-- Internal Watchdog
		flashProgramChecksum [2] ErrorFlags OPTIONAL,	-- Flash Program Checksum
		ram [3] ErrorFlags OPTIONAL,					-- RAM
		pll [4] ErrorFlags OPTIONAL,					-- Phase Locked Loop
		startupTestChecksum2 [5] ErrorFlags OPTIONAL,	-- Startup Test Checksum 2
		lsi [6] ErrorFlags OPTIONAL,					-- Low Speed Internal Clock
		hse [7] ErrorFlags OPTIONAL,					-- High Speed External Clock
		hseSwitch [8] ErrorFlags OPTIONAL,				-- High Speed External Clock Switch
		externalClockSource [9] ErrorFlags OPTIONAL,	-- External Clock Source
		abnormalTermination [10] ErrorFlags OPTIONAL,	-- Abnormal Termination of Clock Test
		testFlowCheckpoint1 [11] ErrorFlags OPTIONAL,	-- Test Flow Checkpoint 1
		testFlowCheckpoint2 [12] ErrorFlags OPTIONAL,	-- Test Flow Checkpoint 2
		nvmLogFull [13] ErrorFlags OPTIONAL,			-- NVM Log Full
		nvmFlashCorrupt [14] ErrorFlags OPTIONAL,		-- NVM Log Flash Corrupt
		stackOverflow [15] ErrorFlags OPTIONAL,			-- Stack Overflow
		hardFault [16] ErrorFlags OPTIONAL,				-- Hard Fault
		logicError [17] ErrorFlags OPTIONAL,			-- Software triggered logic errors. assert() in the firmware.
		asicSyncSwitch [18] ErrorFlags OPTIONAL			-- ASIC sync switch test failed
	}

	ErrorFlags ::= BIT STRING {
		applicable (0),		-- Test has been run.
		qualified (1) 		-- Error is qualified.
	}

	AsicInformation ::= SEQUENCE {
		index [0] INTEGER OPTIONAL,
		irLeds [1] DiodeComponentInformation OPTIONAL,
		irPds [2] DiodeComponentInformation OPTIONAL,
		offline [3] ErrorFlags OPTIONAL,					-- ASIC Offline.
		timeout [4] ErrorFlags OPTIONAL,					-- ASIC Timeout.
		overTemperatureExternalSensor [5] ErrorFlags OPTIONAL,	-- External Temperature Sensor Overtemperature.
		porFault [6] ErrorFlags OPTIONAL,					-- POR Fault.
		analogOrVbgFault [7] ErrorFlags OPTIONAL,			-- Analogue circuits reporting Vref drop or VBG Fault.
		memoryOverflow [8] ErrorFlags OPTIONAL,				-- Memory Overflow, Storage memory full.
		internalThermalShutdown [9] ErrorFlags OPTIONAL,	-- Internal sensor tripped Thermal Shutdown.
		proxResultOverflow [10] ErrorFlags OPTIONAL			-- PROX instruction result out of range.
	}
	
	VisibleLedDriverInformation ::= SEQUENCE {
		index [0] INTEGER OPTIONAL,
		visibleLeds [1] DiodeComponentInformation OPTIONAL,
		offline [2] ErrorFlags OPTIONAL
	}

	DiodeComponentInformation ::= SEQUENCE {
		componentOpen [0] BIT STRING OPTIONAL,
		componentOpenApplicable [1] BIT STRING OPTIONAL,
		componentShort [2] BIT STRING OPTIONAL,
		componentShortApplicable [3] BIT STRING OPTIONAL
	}
	
	ErrorLog ::= SEQUENCE {
		sessionIdentifier [0] INTEGER OPTIONAL,
		timestamp [1] Timestamp OPTIONAL,
		isLastEntry [2] NULL OPTIONAL,
		errorEntry [3] ErrorEntry OPTIONAL,
		resetCause [4] INTEGER {
			hard (0),					-- Reset pin
			soft (1),					-- Software reset
			internalWatchdog (2),		-- Internal Watchdog
			brownOut (3)				-- Power loss
		} OPTIONAL
	}
	
	ErrorNotification ::= SEQUENCE {
		errorEntry [0] ErrorEntry OPTIONAL
	}
	
	-- Can either be none or one.
	ErrorEntry ::= CHOICE {
		systemTest [0] SystemErrorInformation,
		asic [1] AsicErrorEntry,
		visibleLedDriver [2] VisibleLedDriverErrorEntry
	}
	
	-- For a desciption of error types, check AsicInformation above.
	AsicErrorEntry ::= SEQUENCE {
		index [0] INTEGER OPTIONAL,
		irLedIndex [1] INTEGER OPTIONAL,
		irPdIndex [2] INTEGER OPTIONAL,
		open [3] BOOLEAN OPTIONAL,
		short [4] BOOLEAN OPTIONAL,
		offline [5] BOOLEAN OPTIONAL,
		timeout [6] BOOLEAN OPTIONAL,
		overTemperatureExternalSensor [7] BOOLEAN OPTIONAL,
		porFault [8] BOOLEAN OPTIONAL,
		analogOrVbgFault [9] BOOLEAN OPTIONAL,
		memoryOverflow [10] BOOLEAN OPTIONAL,
		internalThermalShutdown [11] BOOLEAN OPTIONAL,
		proxResultOverflow [12] BOOLEAN OPTIONAL
	}

	VisibleLedDriverErrorEntry ::= SEQUENCE {
		index [0] INTEGER OPTIONAL,
		ledChannelIndex [1] INTEGER OPTIONAL,
		open [2] BOOLEAN OPTIONAL,
		short [3] BOOLEAN OPTIONAL,
		offline [4] BOOLEAN OPTIONAL
	}
	
	-- Exposes system Error Thresholds. Structures based on (and used together with)
	-- ErrorInformation.
	ErrorThresholds ::= SEQUENCE {
		asicsThresholds [0] SEQUENCE OF [0] AsicThresholds OPTIONAL,
		visibleLedDriversThresholds [1] SEQUENCE OF [0] VisibleLedDriverThresholds OPTIONAL
	}
	
	AsicThresholds ::= SEQUENCE {
		asicIdentifier [0] INTEGER OPTIONAL,
		irLedOpenThresholds [1] Thresholds OPTIONAL,
		irLedShortThresholds [2] Thresholds OPTIONAL,
		irPdOpenThresholds [3] Thresholds OPTIONAL,
		irPdShortThresholds [4] Thresholds OPTIONAL
	}
	
	VisibleLedDriverThresholds ::= SEQUENCE {
		visibleLedDriverIdentifier [0] INTEGER OPTIONAL,
		visibleLedOpenThresholds [1] Thresholds OPTIONAL,
		visibleLedShortThresholds [2] Thresholds OPTIONAL
	}
	
	Thresholds ::= SEQUENCE {
		low [0] INTEGER OPTIONAL,
		high [1] INTEGER OPTIONAL
	}
END

/*
  _____ _                            _                 
 / ____| |                          | |                
| |    | |__   __ _ _ __   __ _  ___| |     ___   __ _ 
| |    | '_ \ / _` | '_ \ / _` |/ _ \ |    / _ \ / _` |
| |____| | | | (_| | | | | (_| |  __/ |___| (_) | (_| |
 \_____|_| |_|\__,_|_| |_|\__, |\___|______\___/ \__, |
                           __/ |                  __/ |
                          |___/                  |___/ 
----------------------------------------------------------------------

* Add NN1003 to list of ASIC Types
* Add asicSram as storageType to easily discern NN1002 and NN1003 specific
  storage areas.
* Add gestures as operationMode parameter, to control transmission of
  gesture data.
* Make LedPdPlacement into its own datatype, instead of inline definition.

2016-04-26 - Protocol version 1.4
* Protocol cleanup and simplification by use of EXTENSIBILITY IMPLIED
* To avoid conflict due to EXTENSIBILITY IMPLIED the sub CHOICE for
  touch in notificationMessage has been eliminated.
* Add detectionMode to deviceConfiguration
* Add optional BuildInfo to platformInformation
* Command for clearing error counters added.
* Add delta values for gesture notifications.
* Add ErrorInformation, ErrorLog and ErrorNotification.
* Add ErrorThreshold getting/setting.
* Add Latency datatype and add notificationLatency to Notification

2016-03-02 - Protocol version 1.3
* Protocol added for gesture features.
* Add a StatusNotification message.
* Add HardwareError status notification.
* Add SingleAxisTouchError status notification for when someone
  touches the outside of a lightguide and it affects touches.
* Add TouchesIgnored status notification for when the unit will not
  be providing touches.
* Add lowSignalError to StatusNotification.
* Add new lowSignal message.
* Make Vector members optional.

2016-01-19 - Protocol version 1.2
* Add support for visual LED feedback from RGB LEDs.
* Add ASIC registers as storage type
* Added optional MCU serial number to platformInformation
* Add more complex singal data definition used when the standard
  matrix is not the best way. This consists of the new signalsLayout
  request and the airSignals notification.
* Add support for reporting maximum signal map.

2015-11-26 - Protocol version 1.1
* Renamed numberOfAxes and signalsPerAxis to numberOfSignalAxes and
  signalsPerSignalAxis to discern between physical and data related axes.
* Add LED and PD configuration info to deviceInstanceInformation.
* Added support for generic data storage
* Added indicator for used calibration storage area to diagnosticSettings
* Add MemOverFlow error to global state flags of BootComplete

2015-10-20 - Protocol version 1.0
* Initial release and feature freeze of protocol.
* Full support for Core Devices on platform v7.

*/

nn_parser.py:

# Auto-generated by asn1ate on 2017-08-24 12:49:36.289000
from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful


class Latency(univ.Integer):
    pass


Latency.tagSet = univ.Integer.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 35))


class ErrorFlags(univ.BitString):
    pass


ErrorFlags.namedValues = namedval.NamedValues(
    ('applicable', 0),
    ('qualified', 1)
)


class SystemErrorInformation(univ.Sequence):
    pass


SystemErrorInformation.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('cpu', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('internalWatchdog', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('flashProgramChecksum', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('ram', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('pll', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
    namedtype.OptionalNamedType('startupTestChecksum2', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
    namedtype.OptionalNamedType('lsi', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
    namedtype.OptionalNamedType('hse', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
    namedtype.OptionalNamedType('hseSwitch', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8))),
    namedtype.OptionalNamedType('externalClockSource', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 9))),
    namedtype.OptionalNamedType('abnormalTermination', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 10))),
    namedtype.OptionalNamedType('testFlowCheckpoint1', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 11))),
    namedtype.OptionalNamedType('testFlowCheckpoint2', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 12))),
    namedtype.OptionalNamedType('nvmLogFull', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 13))),
    namedtype.OptionalNamedType('nvmFlashCorrupt', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 14))),
    namedtype.OptionalNamedType('stackOverflow', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 15))),
    namedtype.OptionalNamedType('hardFault', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 16))),
    namedtype.OptionalNamedType('logicError', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 17))),
    namedtype.OptionalNamedType('asicSyncSwitch', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 18)))
)


class VisibleLedDriverErrorEntry(univ.Sequence):
    pass


VisibleLedDriverErrorEntry.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('index', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('ledChannelIndex', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('open', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('short', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('offline', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
)


class AsicErrorEntry(univ.Sequence):
    pass


AsicErrorEntry.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('index', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('irLedIndex', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('irPdIndex', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('open', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('short', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
    namedtype.OptionalNamedType('offline', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
    namedtype.OptionalNamedType('timeout', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
    namedtype.OptionalNamedType('overTemperatureExternalSensor', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
    namedtype.OptionalNamedType('porFault', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8))),
    namedtype.OptionalNamedType('analogOrVbgFault', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 9))),
    namedtype.OptionalNamedType('memoryOverflow', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 10))),
    namedtype.OptionalNamedType('internalThermalShutdown', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 11))),
    namedtype.OptionalNamedType('proxResultOverflow', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 12)))
)


class ErrorEntry(univ.Choice):
    pass


ErrorEntry.componentType = namedtype.NamedTypes(
    namedtype.NamedType('systemTest', SystemErrorInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
    namedtype.NamedType('asic', AsicErrorEntry().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
    namedtype.NamedType('visibleLedDriver', VisibleLedDriverErrorEntry().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
)


class Timestamp(univ.Integer):
    pass


Timestamp.tagSet = univ.Integer.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 24))


class ErrorLog(univ.Sequence):
    pass


ErrorLog.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('sessionIdentifier', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('timestamp', Timestamp().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('isLastEntry', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('errorEntry', ErrorEntry().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
    namedtype.OptionalNamedType('resetCause', univ.Integer(namedValues=namedval.NamedValues(('hard', 0), ('soft', 1), ('internalWatchdog', 2), ('brownOut', 3))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
)


class ErrorNotification(univ.Sequence):
    pass


ErrorNotification.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('errorEntry', ErrorEntry().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
)


class StatusNotification(univ.Sequence):
    pass


StatusNotification.tagSet = univ.Sequence.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 27))
StatusNotification.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('hardwareError', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('singleAxisTouchError', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('touchesIgnored', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('lowSignalError', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('error', ErrorNotification().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
    namedtype.OptionalNamedType('errorLog', ErrorLog().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5)))
)


class Vector(univ.Sequence):
    pass


Vector.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('dataType', univ.Enumerated(namedValues=namedval.NamedValues(('uint8', 0), ('int8', 1), ('uint12', 2), ('int12', 3), ('uint16', 4), ('int16', 5), ('uint24', 6), ('int24', 7), ('uint32', 8), ('int32', 9), ('uint64', 10), ('int64', 11), ('float', 12), ('double', 13))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('shape', univ.SequenceOf(componentType=univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('data', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
)


class VariableSizeIntegerString(univ.Choice):
    pass


VariableSizeIntegerString.componentType = namedtype.NamedTypes(
    namedtype.NamedType('uint8', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.NamedType('uint12', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.NamedType('uint16', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
)


class RawData(univ.SequenceOf):
    pass


RawData.componentType = VariableSizeIntegerString()


class BootCompleteNotification(univ.Sequence):
    pass


BootCompleteNotification.tagSet = univ.Sequence.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 3))
BootCompleteNotification.componentType = namedtype.NamedTypes(
    namedtype.NamedType('asicStatus', univ.Integer(namedValues=namedval.NamedValues(('asicExists', 0), ('asicNotFound', 1))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.NamedType('resetSource', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.NamedType('globalState', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
)


class TouchNotification(univ.OctetString):
    pass


TouchNotification.tagSet = univ.OctetString.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 2))


class DeviceAddress(univ.OctetString):
    pass


DeviceAddress.tagSet = univ.OctetString.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0))
DeviceAddress.subtypeSpec = constraint.ValueSizeConstraint(2, 2)


class SignedInteger(univ.Integer):
    pass


class GestureNotification(univ.Sequence):
    pass


GestureNotification.tagSet = univ.Sequence.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 4))
GestureNotification.componentType = namedtype.NamedTypes(
    namedtype.NamedType('gestureStatus', univ.Integer(namedValues=namedval.NamedValues(('detection', 0), ('update', 1), ('stop', 2))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('gestureIdentifier', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.NamedType('gestureType', univ.Integer(namedValues=namedval.NamedValues(('tap', 0), ('longPress', 1), ('swipe', 2), ('pan', 3), ('pinch', 4), ('rotation', 5), ('grab', 6), ('rimTap', 7))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('originX', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('originY', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
    namedtype.OptionalNamedType('sizeX', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
    namedtype.OptionalNamedType('sizeY', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
    namedtype.OptionalNamedType('deltaX', SignedInteger().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
    namedtype.OptionalNamedType('deltaY', SignedInteger().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))
)


class Notification(univ.Sequence):
    pass


Notification.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('deviceAddress', DeviceAddress()),
    namedtype.NamedType('notificationMessage', univ.Choice(componentType=namedtype.NamedTypes(
        namedtype.NamedType('singleTouch', TouchNotification()),
        namedtype.NamedType('touchNotifications', univ.SequenceOf(componentType=TouchNotification()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.NamedType('bootCompleteNotification', BootCompleteNotification()),
        namedtype.NamedType('ledLevels', RawData().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 11))),
        namedtype.NamedType('coreSignals', RawData().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 14))),
        namedtype.NamedType('airSignals', Vector().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 17))),
        namedtype.NamedType('airMaximum', Vector().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
        namedtype.NamedType('statusNotification', StatusNotification()),
        namedtype.NamedType('gestureNotifications', univ.SequenceOf(componentType=GestureNotification()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
    ))
    ),
    namedtype.OptionalNamedType('notificationTimestamp', Timestamp()),
    namedtype.OptionalNamedType('notificationLatency', Latency())
)


class LedPdPlacement(univ.Integer):
    pass


LedPdPlacement.namedValues = namedval.NamedValues(
    ('pdFirstPdLast', 0),
    ('pdFirstLedLast', 1),
    ('ledFirstPdLast', 2),
    ('ledFirstLedLast', 3)
)


class DiodeComponentInformation(univ.Sequence):
    pass


DiodeComponentInformation.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('componentOpen', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('componentOpenApplicable', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('componentShort', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('componentShortApplicable', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
)


class VisibleLedDriverInformation(univ.Sequence):
    pass


VisibleLedDriverInformation.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('index', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('visibleLeds', DiodeComponentInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
    namedtype.OptionalNamedType('offline', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
)


class AsicInformation(univ.Sequence):
    pass


AsicInformation.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('index', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('irLeds', DiodeComponentInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
    namedtype.OptionalNamedType('irPds', DiodeComponentInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
    namedtype.OptionalNamedType('offline', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.OptionalNamedType('timeout', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
    namedtype.OptionalNamedType('overTemperatureExternalSensor', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
    namedtype.OptionalNamedType('porFault', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
    namedtype.OptionalNamedType('analogOrVbgFault', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
    namedtype.OptionalNamedType('memoryOverflow', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8))),
    namedtype.OptionalNamedType('internalThermalShutdown', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 9))),
    namedtype.OptionalNamedType('proxResultOverflow', ErrorFlags().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 10)))
)


class ErrorInformation(univ.Sequence):
    pass


ErrorInformation.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('systemTests', SystemErrorInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
    namedtype.OptionalNamedType('asics', univ.SequenceOf(componentType=AsicInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('visibleLedDrivers', univ.SequenceOf(componentType=VisibleLedDriverInformation().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
)


class Thresholds(univ.Sequence):
    pass


Thresholds.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('low', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('high', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
)


class VisibleLedDriverThresholds(univ.Sequence):
    pass


VisibleLedDriverThresholds.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('visibleLedDriverIdentifier', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('visibleLedOpenThresholds', Thresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
    namedtype.OptionalNamedType('visibleLedShortThresholds', Thresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
)


class AsicThresholds(univ.Sequence):
    pass


AsicThresholds.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('asicIdentifier', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('irLedOpenThresholds', Thresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
    namedtype.OptionalNamedType('irLedShortThresholds', Thresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
    namedtype.OptionalNamedType('irPdOpenThresholds', Thresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
    namedtype.OptionalNamedType('irPdShortThresholds', Thresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4)))
)


class ErrorThresholds(univ.Sequence):
    pass


ErrorThresholds.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('asicsThresholds', univ.SequenceOf(componentType=AsicThresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('visibleLedDriversThresholds', univ.SequenceOf(componentType=VisibleLedDriverThresholds().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
)


class OpenShortInformation(univ.Sequence):
    pass


OpenShortInformation.tagSet = univ.Sequence.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 23))
OpenShortInformation.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('asicIndex', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.NamedType('ledOpen', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.NamedType('ledShort', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('pdOpen', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.NamedType('pdShort', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
)


class StorageIdentifier(univ.Integer):
    pass


StorageIdentifier.subtypeSpec = constraint.ValueRangeConstraint(0, 127)


class StorageArea(univ.Sequence):
    pass


StorageArea.componentType = namedtype.NamedTypes(
    namedtype.NamedType('storageIdentifier', StorageIdentifier().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
    namedtype.OptionalNamedType('storageDescription', char.IA5String().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 32)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
    namedtype.OptionalNamedType('storageType', univ.Integer(namedValues=namedval.NamedValues(('rom', 0), ('flash', 1), ('eeprom', 2), ('ram', 3), ('asicRegister', 4), ('asicSram', 5))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
    namedtype.OptionalNamedType('storageLocation', univ.Integer(namedValues=namedval.NamedValues(('internal', 0), ('external', 1), ('removable', 2))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
    namedtype.NamedType('storageSize', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
)


class AsicType(univ.Integer):
    pass


AsicType.namedValues = namedval.NamedValues(
    ('nn1001', 1),
    ('nn1002', 2),
    ('nn1003', 3)
)


class TouchDescriptor(univ.BitString):
    pass


TouchDescriptor.tagSet = univ.BitString.tagSet.tagImplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 1))
TouchDescriptor.namedValues = namedval.NamedValues(
    ('id', 0),
    ('event', 1),
    ('loc-x-byte1', 2),
    ('loc-x-byte2', 3),
    ('loc-x-byte3', 4),
    ('loc-y-byte1', 5),
    ('loc-y-byte2', 6),
    ('loc-y-byte3', 7),
    ('loc-z-byte1', 8),
    ('loc-z-byte2', 9),
    ('loc-z-byte3', 10),
    ('size-x-byte1', 11),
    ('size-x-byte2', 12),
    ('size-x-byte3', 13),
    ('size-y-byte1', 14),
    ('size-y-byte2', 15),
    ('size-y-byte3', 16),
    ('size-z-byte1', 17),
    ('size-z-byte2', 18),
    ('size-z-byte3', 19),
    ('orientation', 20),
    ('confidence', 21),
    ('pressure', 22)
)


class Message(univ.Sequence):
    pass


Message.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('deviceAddress', DeviceAddress()),
    namedtype.OptionalNamedType('enable', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('disable', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('enable', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('reset', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 5))),
    namedtype.OptionalNamedType('touchFormat', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('touchDescriptor', TouchDescriptor())
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 6))),
    namedtype.OptionalNamedType('operationMode', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('detection', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('signals', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('ledLevels', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.OptionalNamedType('detectionHid', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.OptionalNamedType('gestures', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 7))),
    namedtype.OptionalNamedType('frequency', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('finger', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('stylus', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('idle', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 8))),
    namedtype.OptionalNamedType('resolution', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('x', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('y', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('z', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 9))),
    namedtype.OptionalNamedType('openShort', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('openShortInfo', univ.SequenceOf(componentType=OpenShortInformation()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('errorCount', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 10))),
    namedtype.OptionalNamedType('deviceInformation', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('platformInformation', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('platformVersionMajor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.OptionalNamedType('platformVersionMinor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
            namedtype.OptionalNamedType('protocolVersionMajor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
            namedtype.OptionalNamedType('protocolVersionMinor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
            namedtype.OptionalNamedType('firmwareVersionMajor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
            namedtype.OptionalNamedType('firmwareVersionMinor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
            namedtype.OptionalNamedType('hardwareIdentifier', char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
            namedtype.OptionalNamedType('hardwareVersion', char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
            namedtype.OptionalNamedType('asicType', AsicType().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8))),
            namedtype.OptionalNamedType('numberOfAsics', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 9))),
            namedtype.OptionalNamedType('mcuUniqueIdentifier', univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 32)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 10))),
            namedtype.OptionalNamedType('projectReference', char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 11))),
            namedtype.OptionalNamedType('platformReference', char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 12))),
            namedtype.OptionalNamedType('buildTime', char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 13))),
            namedtype.OptionalNamedType('buildDate', char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 14)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
        namedtype.OptionalNamedType('deviceInstanceInformation', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('productVersionMajor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.OptionalNamedType('productVersionMinor', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
            namedtype.OptionalNamedType('physicalWidth', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
            namedtype.OptionalNamedType('physicalHeight', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
            namedtype.OptionalNamedType('numberOfSignalAxes', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 32767)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
            namedtype.OptionalNamedType('signalsPerSignalAxis', univ.SequenceOf(componentType=univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
            namedtype.OptionalNamedType('ledsPerPhysicalAxis', univ.SequenceOf(componentType=univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
            namedtype.OptionalNamedType('pdsPerPhysicalAxis', univ.SequenceOf(componentType=univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
            namedtype.OptionalNamedType('ledPdPlacementPerPhysicalAxis', univ.SequenceOf(componentType=LedPdPlacement().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
        namedtype.OptionalNamedType('storageInformation', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.NamedType('storageAreas', univ.SequenceOf(componentType=StorageArea().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.NamedType('maxReadSize', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
            namedtype.NamedType('maxWriteSize', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
        namedtype.OptionalNamedType('lightingInformation', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('numberOfLeds', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.OptionalNamedType('bitsPerLedChannel', univ.SequenceOf(componentType=univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 12))),
    namedtype.OptionalNamedType('deviceCount', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('totalNumberOfDevices', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('coreDevices', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('airDevices', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.OptionalNamedType('plusDevices', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.OptionalNamedType('lightingDevices', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 15))),
    namedtype.OptionalNamedType('status', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('counters', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('currentContacts', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 127)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.OptionalNamedType('scanningCounter', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 65535)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
            namedtype.OptionalNamedType('preparedTouchCounter', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 65535)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
            namedtype.OptionalNamedType('sentTouchCounter', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 65535)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
            namedtype.OptionalNamedType('invalidTouchCounter', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 65535)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 13))),
    namedtype.OptionalNamedType('resultCode', univ.Integer(namedValues=namedval.NamedValues(('ok', 0), ('fail', 1))).subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 20))),
    namedtype.OptionalNamedType('deviceConfiguration', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('numberOfTrackedTouches', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('trackingMinDistanceMove', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 16383)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('subTouchActiveArea', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('lowBoundX', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 16383)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.OptionalNamedType('lowBoundY', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 16383)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
            namedtype.OptionalNamedType('highBoundX', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 16383)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
            namedtype.OptionalNamedType('highBoundY', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 16383)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
            namedtype.OptionalNamedType('reverseX', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
            namedtype.OptionalNamedType('reverseY', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
        namedtype.OptionalNamedType('referenceSignalConfig', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.OptionalNamedType('sizeRestriction', univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('maxSizeEnabled', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
            namedtype.OptionalNamedType('maxSize', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
            namedtype.OptionalNamedType('minSizeEnabled', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
            namedtype.OptionalNamedType('minSize', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
        ))
        .subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
        namedtype.OptionalNamedType('detectionMode', univ.Integer(namedValues=namedval.NamedValues(('default', 0), ('finger', 1), ('mergeTouches', 32), ('insensitiveFTIR', 64))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
        namedtype.OptionalNamedType('numberOfReportedTouches', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 19))),
    namedtype.OptionalNamedType('diagnosticsSettings', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('fixedStrength', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('forceCalibration', univ.Integer(namedValues=namedval.NamedValues(('noCalibration', 0), ('calibrateLedLevels', 1), ('calibrateLedLevelsWithHighestASICGain', 2))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('rawSignalFiltering', univ.Integer(namedValues=namedval.NamedValues(('disabled', 0), ('enabled', 1))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.OptionalNamedType('calibrationStorageAreaInUse', StorageIdentifier().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.OptionalNamedType('signalMaximum', univ.Boolean().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 21))),
    namedtype.OptionalNamedType('storageOperation', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('storageIdentifier', StorageIdentifier().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.NamedType('operationType', univ.Integer(namedValues=namedval.NamedValues(('read', 0), ('write', 1), ('delete', 2))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.NamedType('offset', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.NamedType('size', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.OptionalNamedType('payload', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
        namedtype.OptionalNamedType('operationStatusCode', univ.Integer(namedValues=namedval.NamedValues(('success', 0), ('genericError', 1), ('outOfBounds', 2), ('mediaNotPresent', 3), ('identifierError', 4), ('bufferOverflow', 5), ('writeProtected', 6), ('deleteNotApplicable', 7))).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 25))),
    namedtype.OptionalNamedType('signalsLayout', Vector().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 18))),
    namedtype.OptionalNamedType('lighting', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('presenceBitMask', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('state', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('globalIntensity', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 65535)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 26))),
    namedtype.OptionalNamedType('lowSignal', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.OptionalNamedType('lowSignalInfo', univ.BitString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
    ))
    .subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 28))),
    namedtype.OptionalNamedType('errorCounterClear', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 31))),
    namedtype.OptionalNamedType('errorInformation', ErrorInformation().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 32))),
    namedtype.OptionalNamedType('errorLog', univ.Integer(namedValues=namedval.NamedValues(('currentSession', -1), ('allSessions', -2))).subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 33))),
    namedtype.OptionalNamedType('errorThresholds', ErrorThresholds().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 34)))
)


class ProtocolMessage(univ.Choice):
    pass


ProtocolMessage.componentType = namedtype.NamedTypes(
    namedtype.NamedType('request', Message().subtype(implicitTag=tag.Tag(tag.tagClassPrivate, tag.tagFormatConstructed, 14))),
    namedtype.NamedType('response', Message().subtype(implicitTag=tag.Tag(tag.tagClassPrivate, tag.tagFormatConstructed, 15))),
    namedtype.NamedType('notification', Notification().subtype(implicitTag=tag.Tag(tag.tagClassPrivate, tag.tagFormatConstructed, 16)))
)

pyasn1.error.PyAsn1Error: Duplicate default ASN.1 type

This following code used to work fine on 0.3.1 but breaks on 0.3.2 and 0.3.3:

from pyasn1.type import univ, namedtype

class Foobar(univ.Sequence):
    pass

Foobar.componentType = namedtype.NamedTypes(
    namedtype.NamedType('baz', univ.Any()),
    namedtype.OptionalNamedType('blerg', univ.Any())
)

On 0.3.2 and 0.3.3, here's the traceback we get:

Traceback (most recent call last):
  File "test.py", line 10, in <module>
    namedtype.OptionalNamedType('blerg', univ.Any())
  File "/home/ryanow01/sandboxes/pyasn1_problem/.tox/pyasn1033/local/lib/python2.7/site-packages/pyasn1/type/namedtype.py", line 117, in __init__
    self.__nonUniqueTagMap = self.__computeTagMaps(unique=False)
  File "/home/ryanow01/sandboxes/pyasn1_problem/.tox/pyasn1033/local/lib/python2.7/site-packages/pyasn1/type/namedtype.py", line 441, in __computeTagMaps
    raise error.PyAsn1Error('Duplicate default ASN.1 type at %s' % (self,))
pyasn1.error.PyAsn1Error: Duplicate default ASN.1 type at NamedTypes(NamedType('baz', Any()), OptionalNamedType('blerg', Any()))

0.2.3 backward compatibulity issue.

Installed parmiko 2.1.1 using pip which downloaded pyasn1 version 0.2.3. Caused issues for pysnmp-4.3.2

pysnmp-4.3.2-py2.7/pysnmp/proto/api/v1.py", line 58, in setDefaults
1, self._errorStatus, verifyConstraints=False
File "/usr/lib/python2.6/site-packages/pyasn1/type/univ.py", line 2123, in setComponentByPosition
raise error.PyAsn1Error('Component value is tag-incompatible: %r vs %r' % (value, componentType))
PyAsn1Error: Component value is tag-incompatible: Integer('noError', NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7), ('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10), ('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13), ('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16), ('notWritable', 17), ('inconsistentName', 18))) vs Integer(subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(0, Integer(2147483647))))

Reverted pyasn1 to version 0.1.9 and the code works.

UTF8 String bug

Hello,

last few hours I've been debugging the problem after port to new API v0.3.3.

I am experiencing problem like this:

  • Python v2.7.13
  • Parsing 2.5.29.17 subjectAltName
  • char.UTF8String() is being parsed in a way pyasn1.type.univ.OctetString is passed in the constructor.
  • prettyIn() of the AbstractCharacterString is called, which leads to call unicode(value) essentially leading to __unicode__() call on the OctetString
  • OctetString has default encoding iso-8859-1, as it stores _value as a str it tries to decode it in the default encoding iso-8859-1.
  • This leads to malformed non-ASCII characters from the UTF8 string
  • If I read the file manually the string is stored correctly as UTF8 string.

I can provide the example if needed.

Thanks a lot for suggestion.

BitString should be able to accept bytes/bytesarray

The BitString type should accept bytes as one of its options. At the moment you have to convert to hex via hexlify before you can use bytes.

(It's possible this is an oversight from Python 2 support, and the assumption is you can cast from bytes to str freely?)

0.4.1: AttributeError: 'tuple' object has no attribute 'tagClass'

Again some issues with my certificate parsing. You can use the same code from #67

Traceback (most recent call last):
  File "certtest.py", line 10, in <module>
    cert = encode(message[1][3])
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 636, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 423, in encodeValue
    chunk = encodeFun(component, asn1Spec, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 636, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 423, in encodeValue
    chunk = encodeFun(component, asn1Spec, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 636, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/cer/encoder.py", line 215, in encodeValue
    substrate += encodeFun(value[idx], asn1Spec, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 636, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/cer/encoder.py", line 179, in encodeValue
    for x in value]
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/cer/encoder.py", line 179, in <listcomp>
    for x in value]
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 636, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 423, in encodeValue
    chunk = encodeFun(component, asn1Spec, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 636, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/codec/ber/encoder.py", line 182, in encodeValue
    asn1Spec = value.clone(tagSet=tag.TagSet(tagSet.baseTag, tagSet.baseTag))
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/type/tag.py", line 189, in __init__
    [(superTag.tagClass, superTag.tagId) for superTag in superTags]
  File "/home/vagrant/.local/lib/python3.5/site-packages/pyasn1/type/tag.py", line 189, in <listcomp>
    [(superTag.tagClass, superTag.tagId) for superTag in superTags]
AttributeError: 'tuple' object has no attribute 'tagClass'

This error happens since 10 minutes ago as 0.4.1 was published to pypi. In 0.3.7 everything was working,

failure to parse Kerberos principal name

Getting a traceback trying to parse a Kerberos principal name in 0.3.2-0.3.4 (0.3.1 untested). This worked in 0.2.3 in the freeIPA project.

AttributeError: 'GeneralString' object has no attribute 'asn1Object'

asn1.txt

OpenType usage is not very clear

I'd like to use the type from rfc2459, which includes an opentype. I've got a AttributeTypeAndValue from which I'd like to decode the value. The only way I know to do it currently is somewhat awkward.

value_bytes = part['value'].asOctets()
spec = part.getComponentType()['value'].openType[part['type']]
value = decoder.decode(value_bytes, asn1Spec=spec)[0]

I couldn't find any way documented. Is there one?

0.4.2: int() argument must be a string or a number, not 'NoneType'

Hey @etingof:

While testing 0.4.1/0.4.2 against impacket I noticed an error is thrown when using the GetADUsers.py script. It was correctly working with pyasn1-0.3.7. This is the error thrown, any idea?:

Impacket v0.9.16-dev - Copyright 2002-2017 Core Security Technologies

Password:
[*] Querying freefly.net for information about domain. Be patient...
Traceback (most recent call last):
  File "./GetADUsers.py", line 265, in <module>
    executer.run()
  File "./GetADUsers.py", line 150, in run
    sizeLimit=0, searchControls = [sc])
  File "/Users/beto/src/impacket/impacket/ldap/ldap.py", line 369, in search
    response = self.sendReceive(searchRequest, searchControls)
  File "/Users/beto/src/impacket/impacket/ldap/ldap.py", line 458, in sendReceive
    self.send(request, controls)
  File "/Users/beto/src/impacket/impacket/ldap/ldap.py", line 418, in send
    data = encoder.encode(message)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 663, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 450, in encodeValue
    chunk = encodeFun(component, asn1Spec, **options)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 663, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 502, in encodeValue
    substrate += encodeFun(value[idx], asn1Spec, **options)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 663, in __call__
    substrate = concreteEncoder.encode(value, asn1Spec, self, **options)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 85, in encode
    value, asn1Spec, encodeFun, **options
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/codec/ber/encoder.py", line 437, in encodeValue
    for idx, component in enumerate(value.values()):
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/univ.py", line 2096, in values
    yield self[idx]
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/univ.py", line 2060, in __getitem__
    return self.getComponentByPosition(idx)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/univ.py", line 2290, in getComponentByPosition
    self.setComponentByPosition(idx)
  File "/Users/beto/src/impacket/impacket/ldap/ldapasn1.py", line 553, in setComponentByPosition
    matchConstraints=matchConstraints)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/univ.py", line 2359, in setComponentByPosition
    value = subComponentType.clone(value=value)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/base.py", line 349, in clone
    return self.__class__(value, **initilaizers)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/univ.py", line 103, in __init__
    base.AbstractSimpleAsn1Item.__init__(self, value, **kwargs)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/base.py", line 240, in __init__
    value = self.prettyIn(value)
  File "build/bdist.macosx-10.13-intel/egg/pyasn1/type/univ.py", line 254, in prettyIn
    return int(value)
TypeError: int() argument must be a string or a number, not 'NoneType'
None
int() argument must be a string or a number, not 'NoneType'

Thanks!

pyasn1 0.3.7 encoding of optional univ.Null broken

Hello,

I just ran across the following problems best illustrated by this code snippet:

from pyasn1.type import univ, namedtype, tag
from pyasn1.codec.ber import encoder

class Flag(univ.Null):
    pass

class TestSeq(univ.Sequence):
    pass

TestSeq.tagSet = univ.Set.tagSet.tagImplicitly(tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))
TestSeq.componentType = namedtype.NamedTypes(
    namedtype.OptionalNamedType('flag', Flag().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
)

t = TestSeq()
#t.setComponentByName("flag", '')

print t.getComponentByPosition(0).isValue

with open("/tmp/test.bin", "wb") as f:
    f.write(encoder.encode(t))

Since univ.Null has a defaultValue, isValue detection breaks for uninitialized components e.g. in SequenceEncoder. Therefore a univ.Null is included even if not initialized. Here is the dumpasn1 output for the generated /tmp/test.bin:

% dumpasn1 /tmp/test.bin
  0   2: [1] {
  2   0:   [0]
       :     Error: Object has zero length.
       :   }
0 warnings, 1 error

Obviously the flag is included though not initialized. Removing the line defaultValue = ''.encode() # This is tightly constrained from univ.py fixes this problem.

The second problem can be seen when uncommenting t.setComponentByName("flag", '') and switching from ber to der encoding or explicitly calling encode(t, ifNotEmpty=True). The line if options.get('ifNotEmpty', False) and not substrate: in ber/encoder.pywill than remove theuniv.Null` from the encoded data even if set.

% dumpasn1 /tmp/test.bin
  0   0: [1]
       :   Error: Object has zero length.

0 warnings, 1 error.

Best regards,

Eierkopp

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.