From my colleagues on the IETF PKIX list were a lot of asn.1 oldtimers live...

>>> from pyasn1.type import univ
>>> from pyasn1.codec.der.decoder import decode as der_decoder
>>> from pyasn1.codec.der.encoder import encode as der_encoder
>>> import binascii
>>> oid = univ.ObjectIdentifier('1.3.6.1.4.1.6715.2.6.6')
>>> s = der_encoder(oid)
>>> print(binascii.hexlify(s))
060a2b06010401b43b020606

For this I don't need the der_decoder, only the encoder.

So I am set.  Actually since for my usage, the OID if fixed, only the content varies, I can just use the output above and prepend it to the value!  Don't have to call asn1 for every time to just get the same value!

thanks all.

On 5/7/23 10:15, stan via users wrote:
On Sun, 7 May 2023 08:46:26 -0400
Robert Moskowitz <rgm@htt-consult.com> wrote:

from /usr/share/doc/python3-asn1/README.rst 
of the fedora package python3-asn1

How to use Python-asn1
======================

.. note:: You can find more detailed documentation on the `Usage`_ page.

.. _Usage: usage.rst

Encoding
--------

If you want to encode data and retrieve its DER-encoded representation,
use code such as:

.. code-block:: python

  import asn1

  encoder = asn1.Encoder()
  encoder.start()
  encoder.write('1.2.3', asn1.Numbers.ObjectIdentifier)
  encoded_bytes = encoder.output()


Decoding
--------

If you want to decode ASN.1 from DER or BER encoded bytes, use code
such as:

.. code-block:: python

  import asn1

  decoder = asn1.Decoder()
  decoder.start(encoded_bytes)
  tag, value = decoder.read()
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue