开发者

How to find the modulus and exponent from a public key?

开发者 https://www.devze.com 2023-03-29 16:54 出处:网络
I need to encrypt some data using RSA in PHP. All of the libraries around ask for an exponent and a modulus, yet I get a single public key like this

I need to encrypt some data using RSA in PHP. All of the libraries around ask for an exponent and a modulus, yet I get a single public key like this

Public Key:

-----BEGIN开发者_开发问答 PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVnXLu0FM37CmUYjJuu4JaB6bo
liJ1b5BybAVcqlfvUxjpU+VVhKnZNd4IU7S0ITRTAKvoFk68CiUmaRA9871mfxjp
sX6YeNs913LyGwFw0bmno+1o6URBui2p3gHwGQL8R/jIl4NHC1TF47Q5Vj3RuraV
Ky4YH6dp7YIJRaU7JQIDAQAB
-----END PUBLIC KEY----- 

How do you retrieve the public exponent and modulus part from this ?


How'd you get that key?

openssl asn1parse -inform PEM -in pubkey.txt -i
    0:d=0  hl=3 l= 159 cons: SEQUENCE
    3:d=1  hl=2 l=  13 cons:  SEQUENCE
    5:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
   16:d=2  hl=2 l=   0 prim:   NULL
   18:d=1  hl=3 l= 141 prim:  BIT STRING

According to that the last sequence of bytes should have a length of 141 and yet the whole key is only 119 characters long.

Ignoring how long the BIT STRING ought to be, for the moment, not even it appears to conform to any standard format.

0

精彩评论

暂无评论...
验证码 换一张
取 消