[nycphp-talk] Working with openssl
Aaron Fischer
agfische at email.smith.edu
Thu Aug 17 12:20:34 EDT 2006
I've been reading and am trying to work with the openssl code example
given in Pro PHP Security. It works smoothly when I run the demo code
on my server which generates a public and private key and encrypts and
decrypts a small bit of text.
However I run into errors when trying to test it in a manner that starts
to simulate a production environment.
How I'm testing:
1. Run the openssl demo code, which creates a public and private key
and encrypts a small amount of text.
2. On a separate page I have created a form that I use to copy and
paste the private key, encrypted text and passphrase.
3. Post the form which is coded to create a new openssl object and pass
it the private key and attempt to decrypt. This produces errors:
Warning: openssl_private_decrypt() [function.openssl-private-decrypt]:
key parameter is not a valid private key in
/home/a/adm1a/openSSL/openSSL.php on line 119
Warning: openssl_free_key() expects parameter 1 to be resource, null
given in /home/a/adm1a/openSSL/openSSL.php on line 122
Testing OpenSSL
Here are the testing pages:
OpenSSL Demo
http://www.smith.edu/admission/openSSL/openSSLdemo.php
Form testing page (passphrase is 'Encryption is fun for everyone')
http://www.smith.edu/admission/openSSL/openSSLtest.php
Here is the actual code:
OpenSSL class
http://www.smith.edu/admission/openSSL/openSSLCode.php
Demo code
http://www.smith.edu/admission/openSSL/openSSLdemoCode.php
Form page for testing
http://www.smith.edu/admission/openSSL/openSSLtestCode.php
Thoughts or suggestions? Much appreciated.
-Aaron
More information about the talk
mailing list