[ Index ]

PHP Cross Reference of DokuWiki




/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/ -> PrivateKey.php (summary)

DSA Private Key

Author: Jim Wigginton
Copyright: 2015 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 152 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 functions


Functions that are not part of a class:

getPublicKey()   X-Ref
Returns the public key

If you do "openssl rsa -in private.rsa -pubout -outform PEM" you get a PKCS8 formatted key
that contains a publicKeyAlgorithm AlgorithmIdentifier and a publicKey BIT STRING.
An AlgorithmIdentifier contains an OID and a parameters field. With RSA public keys this
parameters field is NULL. With DSA PKCS8 public keys it is not - it contains the p, q and g
variables. The publicKey BIT STRING contains, simply, the y variable. This can be verified
by getting a DSA PKCS8 public key:

"openssl dsa -in private.dsa -pubout -outform PEM"

ie. just swap out rsa with dsa in the rsa command above.

A PKCS1 public key corresponds to the publicKey portion of the PKCS8 key. In the case of RSA
the publicKey portion /is/ the key. In the case of DSA it is not. You cannot verify a signature
without the parameters and the PKCS1 DSA public key format does not include the parameters.

return: mixed
see: self::getPrivateKey()

sign($message)   X-Ref
Create a signature

return: mixed
param: string $message
see: self::verify()

toString($type, array $options = [])   X-Ref
Returns the private key

return: string
param: string $type
param: array $options optional