Re: How to get exponent from a PKey object?

flya flya <[email protected]> Sun, 1 Mar 2009 08:11:58 +0800
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
very thanks, pk.get_rsa().pub() can get a tuple with E and N, I tried
this function, in ubuntu 8.10, the program crashed, In windows, it
works, maybe there's a bug in ubuntu version, but no matter, my
program will just on windows.

On Fri, Feb 27, 2009 at 9:06 PM, Mads Kiilerich <[email protected]> wrote:
> flya flya wrote:
>>
>> I need read the public key from =C2=A0certificate, I can get a PKey obje=
ct
>> use follow codes:
>> =C2=A0 =C2=A0from M2Crypto import X509
>> =C2=A0 =C2=A0cer =3D X509.load_cert('test.pem', X509.FORMAT_PEM)
>> =C2=A0 =C2=A0pk =3D cer.get_pubkey()
>> and use pk.get_modulus() to get the modulus, but how can I get exponent?
>> I need these =C2=A0two values to make a new public key struct , and use =
it
>> as a param to call a function from a dll file using ctypes. I found E
>> is often 65537, but I ask a university teacher, he say it can be any
>> value, so how can I get it?
>>
>
> When I looked at it briefly some time ago I concluded that
> pk.get_rsa().pub() was the best option. The prefixes there doesn't look l=
ike
> anything I have seen before, but adding and removing them is an easy and
> ugly hack.
>
> (The question is slightly similar to
> http://article.gmane.org/gmane.comp.python.cryptography/524 - and the ans=
wer
> might be the same ;-) )
>
> /Mads
>
>
>



--=20
http://www.flyaflya.com