note 101513 added to function.openssl-pkey-get-public
| From: | info at steyla dot com | Date: | Tue, 21 Dec 2010 19:55:21 +0000 |
| Subject: | note 101513 added to function.openssl-pkey-get-public | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175120@lists.php.net to get a copy of this message | ||
If you are trying to read a PKCS#1 RSA public key you run into trouble, because openssl wants the
public key in X.509 style.
The PKCS#1 RSA public key
-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAgYxTW5Yj+5QiQtlPMnS9kqQ/HVp+T2KtmvShe68cm8luR7Dampmb
[...]
cbn6n2FsV91BlEnrAKq65PGJxcwcH5+aJwIDAQAB
-----END RSA PUBLIC KEY-----
.. is not readable while the X.509 style public key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgYxTW5Yj+5QiQtlPMnS9
[..]
JwIDAQAB
-----END PUBLIC KEY-----
is. You can use an easy (and dirty) work around to read the PKCS#1 RSA anyway. The first few bytes
of the X.509 style public key contain header information and can shamelessly be copied.
In other words: Delete everything after the first 32 bytes from the above X.509 key (starting behind
Q8A) and attach your PKCS#1 data, reformat to 64 bytes length and use it with openssl.
Please note: The above example only works for 2048 bit length.
Like I said - it's kind of dirty - but hey - if you're as desperate as I was.
Michaela
----
Server IP: 69.147.83.197
Probable Submitter: 195.145.8.130
----
Manual Page -- http://www.php.net/manual/en/function.openssl-pkey-get-public.php
Edit -- https://master.php.net/note/edit/101513
Del: integrated -- https://master.php.net/note/delete/101513/integrated
Del: useless -- https://master.php.net/note/delete/101513/useless
Del: bad code -- https://master.php.net/note/delete/101513/bad+code
Del: spam -- https://master.php.net/note/delete/101513/spam
Del: non-english -- https://master.php.net/note/delete/101513/non-english
Del: in docs -- https://master.php.net/note/delete/101513/in+docs
Del: other reasons-- https://master.php.net/note/delete/101513
Reject -- https://master.php.net/note/reject/101513
Search -- https://master.php.net/manage/user-notes.php