Class RSAPrivateKey

Description

A RSA Private key

Reads/generates/exports rsa private keys. Also allows signing arbitary data and opening sealed data.

Please note that PHPs implemetation is kind of strange, getting the public key is only possible on certificates although they are also part of the public key.

Located in /phpsatk/local/org.eenterphace.sat.crypto.openssl/rsa.private.key.php (line 40)


	
			
Method Summary
RSAPrivateKey __construct ()
void __destruct ()
string exportPrivateKey ([string $passphrase = null])
void exportPrivateKeyToFile (File $file, [string $passphrase = null])
void genKeys ([int $bits = null])
resource getPrivateKey ()
string open (string $sealed, string $envelope_key)
void readFile (File $source, [mixed $passphrase = null])
void readString (mixed $string, [mixed $passphrase = null])
string sign (string $data)
Methods
Constructor __construct (line 55)

Intializes the private key object

Checks whether the openssl extension is available.

  • access: public
RSAPrivateKey __construct ()
Destructor __destruct (line 203)

Destructor

Will free the private key on object desctruction

  • access: public
void __destruct ()
exportPrivateKey (line 113)

Exports the private key

A passphrase can be used to protect the private key.

  • return: Exported private key (possibly encrypted)
  • access: public
string exportPrivateKey ([string $passphrase = null])
  • string $passphrase: Passphrase used to encrypt the key
exportPrivateKeyToFile (line 134)

Exports the private key to a file

A passphrase can be used to protect the private key.

  • access: public
void exportPrivateKeyToFile (File $file, [string $passphrase = null])
  • File $file: File where to store the private key
  • string $passphrase: Passphrase used to encrypt the key
genKeys (line 91)

Generates a new private key

  • access: public
void genKeys ([int $bits = null])
  • int $bits: Keysize
getPrivateKey (line 152)

Gets the private key resource

Be warned: the resource will be freed (become invalid) on object destruction

  • access: public
resource getPrivateKey ()
open (line 188)

Opens sealed (encrypted) data.

Sealed data is data encrypted using a symmetric cipher which is encrypted using a public key. You will have to recieve the encrypted data (PHP uses OpenSSL's RC4 cipher) and the RSA encrypted envelope key (which is used to decrypt the sealed data).

  • return: Decrypted data
  • access: public
string open (string $sealed, string $envelope_key)
  • string $sealed: Sealed data
  • string $envelope_key: RSA encrypted envelope key
readFile (line 62)
  • access: public
void readFile (File $source, [mixed $passphrase = null])
readString (line 74)
  • access: public
void readString (mixed $string, [mixed $passphrase = null])
sign (line 166)

Signs some data

The signed data can be verified using the corresponding public key. SHA1 will be used for hash generation. Will return a signature that has to be passed with the data.

  • return: Signature
  • access: public
string sign (string $data)
  • string $data: Data to sign

Documentation generated on Mon, 21 May 2007 10:35:18 +0200 by phpDocumentor 1.3.0RC5