Re: F38 - Which python asn1 library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 5/5/23 22:51, Samuel Sieb wrote:
On 5/5/23 13:01, Robert Moskowitz wrote:
What my colleague said, see below.

On 5/5/23 15:35, Jonathan Billings wrote:
On May 5, 2023, at 14:40, Robert Moskowitz <rgm@xxxxxxxxxxxxxxx> wrote:

A colleague sent me a python script that does asn1 encoding.  It starts with:

import asn1

then after a few

asn1_enc.write(oid, asn1.Numbers.ObjectIdentifier)

There's no way that would work without something else being involved. You only imported "asn1".  That can't give you something called "asn1_enc", so you're not showing enough for us to help you.

That is all my colleague has indicated he is doing.  He can only generally advise me as we are working on the same IETF standard, but behind different contract setups.

asn1 encoding is a standard part of any asn1 package.  That and decoding, so something like asn1_enc object has to be available.


It seems pyasn1 is already installed. It does not provide asn1_enc.

python3-pyasn1 is the only Python asn1 library available.  It provides a package called "pyasn1" that you can import.

# dnf list > dnf.lst
# grep asn1 dnf.lst |grep -i python
python3-pyasn1.noarch 0.4.8-12.fc38 @fedora
python3-pyasn1-modules.noarch 0.4.8-12.fc38 @fedora
python-asn1-doc.noarch 2.6.0-2.fc38 fedora
python-pyasn1-doc.noarch 0.4.8-12.fc38 fedora
python3-asn1.noarch 2.6.0-2.fc38 fedora
python3-asn1crypto.noarch 1.5.1-4.fc38
-----------------
python3-pyasn1 was installed already.  python-asn1 was not.  Don't know about python3-asn1crypto.



I am pretty sure this is just old or broken code. According to the documentation:

https://python-asn1.readthedocs.io/en/latest/usage.html


… you would just create a new asn1.Encoder() object and use that to write(). Perhaps “asn1_enc” is defined that way in the code?

I think this isn’t really a Fedora issue, unless the API changes in F38, in which case, it’s time to update the code, or pin your requirements to an older version of asn1.

He is actively doing this.  I believe he uses Ubuntu.

asn1 is a 3^rd party package that I installed from pip under the name pyasn1 IIRC. You would import it in your code using:

The README for python3-pyasn1 says that it is the one that you would get from "pip install pyasn1" so it should be the right one.

thanks


import asn1

The import is "pyasn1" in Fedora as it should be, but that still won't get you the thing you're looking for, so you need to provide some more lines of the code to see where that's coming from.

asn1 is a 3rd party package that I installed from pip under the name pyasn1 IIRC. You would import it in your code using:

import asn1

I created the OID as a string ("1.3.6.1.4.1.6715.2.6.blah") and passed it into the  asn1 Encoders write function like this:

asn1_enc.write(oid, asn1.Numbers.ObjectIdentifier)
oid_bytes = asn1_enc.output()

Then I just combined it all together with the bytes of the Endorsement.

base64.b64encode(len(oid_bytes).to_bytes(1, 'little') + oid_bytes + endorsement_bytes).decode('ascii')

---------
That is probably all he can tell me.

So I got more research to do, as in the end, we have to interoperate.
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux