Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix identify for some public key pem file that missing object identifier #92

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

machinewu
Copy link

@machinewu machinewu commented Dec 14, 2016

I use the following code with python rsa module generate public and private key pem file.

run following code after install python rsa module: pip install rsa

#!/usr/bin/env python
# coding=utf-8

import rsa

pubkey, prikey = rsa.newkeys(1024, poolsize=1)
#print 'pubkey n:\n%s' % pubkey.n
#print 'pubkey e:\n%s' % pubkey.e

print
print 'private key:\n%s' % prikey.save_pkcs1(format='PEM')
print
print 'public key:\n%s' % pubkey.save_pkcs1(format='PEM')

The public key pem file generated is different from using linux openssl generate. For that pem file without object identifier.
We can check it at https://lapo.it.

python rsa generated public key:

-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAIOf5xGsiGU765gpdsmkqLMTjj5kq5avJAaYssl9R858tnEsHJvfAy9u
aouoPZRtlCCrl0JtqSwf7xAqlLZAsys5Hb++Q9hUDoYAbhEdtzVH5FCzPpSUeOc1
+mal1e8487qUlJvhLjAKvgPJvGcK+KwvZkLvz4OZ0MrBkToNypS5AgMBAAE=
-----END RSA PUBLIC KEY-----


openssl rsa generated public key:

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChdQAWNIU0WsWLuz6rawY/yD6N
wLcqQDWhh9eLatbJ3JhS7QRW2OzvWvjIWQuqAnqviGmqD+x2jpEfxDIpLck4pRFY
HPLqzhGBPBwBJTY1xi4g9qOH61zxHvY1XafeV/mThh5RGmGa9b2olcSframxHRHT
icm4inwUx2H3lg5fnQIDAQAB
-----END PUBLIC KEY-----

python_rsa
openssl

some different for the head and foot:
-----BEGIN RSA PUBLIC KEY-----
different:
-----BEGIN PUBLIC KEY-----

For this PR, I fix it. jsencrypt can work both format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant