[clug] X.509 SubjectPublicKeyInfo fields

Michael Still mikal at stillhq.com
Thu Jan 26 09:42:00 UTC 2023


Thanks for the pointer. After a lot of digging today and disappearing down
ASN1. and PKS#1 rabbit holes, this all comes down to this:

from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.serialization import Encoding
from cryptography.hazmat.primitives.serialization import PublicFormat

# Generate a RSA public keypair for this session
private_key = rsa.generate_private_key(public_exponent=65537, key_size=1024)
public_key_der = private_key.public_key().public_bytes(Encoding.DER,
PublicFormat.SubjectPublicKeyInfo)

Now to work out what a "EME-OAEP as described in PKCS#1 v2.0 with SHA-1,
MGF1 and an empty encoding parameter" is!

Michael

On Thu, Jan 26, 2023 at 7:42 AM jm via linux <linux at lists.samba.org> wrote:

> I've been using the python cryptography library to manipulate X509
> certs. The Subject field appears to be OIDs similar to that used in
> SNMP, ie, ASN.1
>
> see
> https://github.com/pyca/cryptography/blob/main/docs/x509/reference.rst
>
> Hope that helps,
> Jeff.
>
> On 25/1/23 21:46, Michael Still via linux wrote:
> > Hi,
> >
> > I'm playing with a protocol at the moment which has 162 bytes embedded
> into
> > a packet for a "1024 bit RSA public key in X.509 SubjectPublicKeyInfo
> > format". I am having troubles finding documentation on exactly how one
> > would generate a RSA keypair in python and then encode it into this
> format.
> >
> > I can generate a RSA keypair a variety of ways, its the finding
> > documentation on what a SubjectPublicKeyInfo actually is which is killing
> > me. I've looked at RFC3279, and RFC5280 but am not smart enough to
> > understand what they're saying...
> >
> > Hints welcome.
> >
> > Thanks,
> > Michael
>
>
>
> --
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux
>


More information about the linux mailing list