Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
PrivateKey Class Reference

RSA private key. More...

Public Member Functions

 __construct ($pemString, $passPhrase=null)
 Constructor.
 
 getPublicKey ()
 Get the public key.
 
 encrypt ($data, $padding=OPENSSL_PKCS1_PADDING)
 Encrypt using this key.
 
 decrypt ($data, $padding=OPENSSL_PKCS1_OAEP_PADDING)
 Decrypt using this key.
 
 toString ()
 
- Public Member Functions inherited from AbstractKey
 getSize ()
 Get key size in bits.
 
 getOpensslKeyResource ()
 Retrieve openssl key resource.
 
 encrypt ($data)
 Encrypt using this key.
 
 decrypt ($data)
 Decrypt using this key.
 
 toString ()
 Get string representation of this key.
 
 __toString ()
 

Static Public Member Functions

static fromFile ($pemFile, $passPhrase=null)
 Create private key instance from PEM formatted key file.
 

Protected Attributes

 $publicKey = null
 
- Protected Attributes inherited from AbstractKey
 $pemString = null
 
 $opensslKeyResource = null
 
 $details = []
 

Additional Inherited Members

- Public Attributes inherited from AbstractKey
const DEFAULT_KEY_SIZE = 2048
 

Detailed Description

RSA private key.

Constructor & Destructor Documentation

__construct (   $pemString,
  $passPhrase = null 
)

Constructor.

Parameters
string$pemString
string$passPhrase
Exceptions
Exception\RuntimeException

Member Function Documentation

decrypt (   $data,
  $padding = OPENSSL_PKCS1_OAEP_PADDING 
)

Decrypt using this key.

Starting in 2.4.9/2.5.2, we changed the default padding to OPENSSL_PKCS1_OAEP_PADDING to prevent Bleichenbacher's chosen-ciphertext attack.

See Also
http://archiv.infsec.ethz.ch/education/fs08/secsem/bleichenbacher98.pdf
Parameters
string$data
integer$padding
Returns
string
Exceptions
Exception\RuntimeException
Exception\InvalidArgumentException
encrypt (   $data,
  $padding = OPENSSL_PKCS1_PADDING 
)

Encrypt using this key.

Parameters
string$data
integer$padding
Returns
string
Exceptions
Exception\RuntimeException
Exception\InvalidArgumentException
static fromFile (   $pemFile,
  $passPhrase = null 
)
static

Create private key instance from PEM formatted key file.

Parameters
string$pemFile
string | null$passPhrase
Returns
PrivateKey
Exceptions
Exception\InvalidArgumentException
getPublicKey ( )

Get the public key.

Returns
PublicKey
toString ( )
Returns
string

Member Data Documentation

$publicKey = null
protected