From db0d2c9bd6f2ef64721a840ce4f196af20822490 Mon Sep 17 00:00:00 2001 From: Stig Venaas Date: Thu, 23 Nov 2000 19:30:47 +0000 Subject: Added README on usage, and added myself to CREDITS --- ext/openssl/README | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 ext/openssl/README (limited to 'ext/openssl/README') diff --git a/ext/openssl/README b/ext/openssl/README new file mode 100644 index 0000000000..b0a3e2b916 --- /dev/null +++ b/ext/openssl/README @@ -0,0 +1,164 @@ +OpenSSL extension for PHP4 +$Id$ + +The functions implemented so far make it possible to seal and open data, +and also create and verify signatures. To enable the extension, configure +PHP with --with-openssl. + + +Functions: + +int openssl_get_privatekey(string key [, string passphrase]) + +Parses the key data and returns a key resource identifier. If the key is +encrypted a passphrase is needed. This can be supplied as second argument. + + +int openssl_get_publickey(string cert) + +Extracts the public key from the given certificate and returns a key +resource identifier. + + +void openssl_free_key(int key) + +Frees the resource given by the key resource identifier. + + +bool openssl_sign(string data, string signature, int key) + +Uses key to create signature for data, returns true on success and false +on failure. + + +int openssl_verify(string data, string signature, int key) + +Uses key to verify that the signature is correct for the given data. +Returns 1 if correct, 0 if incorrect, and -1 on error. + + +int openssl_seal(string data, string sealdata, array ekeys, array pubkeys) + +Encrypts data using pubkeys, so that only owners of the respective private +keys and ekeys can decrypt and read the data. Returns the length of the +sealed data on success, else false. + + +bool openssl_open(string data, string opendata, string ekey, int privkey) + +Opens (decrypts) sealed data using a private key and the corresponding +envelope key. Returns true on success and false on failure. + + +See below for more details on usage. Also feel free to mail me at +venaas@php.net if you have questions. The OpenSSL documentation, +especially the EVP documentation at +http://www.openssl.org/docs/crypto/evp.html, might also be of help. + + +HOWTO: + +To do anything you need a private key and a certificate containing the +corresponding public key. This is similar to what you have using say an +Apache webserver with OpenSSL. For testing you could try keys that come +with OpenSSL, that's what the sample scripts below do. You can also get +keys from some CA, or you can create them yourself. + + +Creating private key + +To generate an unprotected 1024 bit RSA private key you can do + + openssl genrsa -out /tmp/test.key 1024 + +Private keys should be protected by a passphrase though. + + +Creating a self signed certificate + +To generate a self signed certificate from the key that is valid for +365 days, do + + openssl req -new -key /tmp/test.key -out /tmp/test.crt -days 365 -x509 + + +Example usage + +These examples use keys that come with OpenSSL, you should perhaps test with +those first. + + +Seal and open + + + + +Sign and verify + + -- cgit v1.2.1