[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/ -> PublicKey.php (summary)

RSA Public 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: 513 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  exponentiate()
  rsavp1()
  rsassa_pkcs1_v1_5_verify()
  rsassa_pkcs1_v1_5_relaxed_verify()
  emsa_pss_verify()
  rsassa_pss_verify()
  verify()
  rsaes_pkcs1_v1_5_encrypt()
  rsaes_oaep_encrypt()
  rsaep()
  raw_encrypt()
  encrypt()
  toString()
  asPrivateKey()

Functions
Functions that are not part of a class:

exponentiate(BigInteger $x)   X-Ref
Exponentiate

return: \phpseclib3\Math\BigInteger
param: \phpseclib3\Math\BigInteger $x

rsavp1($s)   X-Ref
RSAVP1

See {@link http://tools.ietf.org/html/rfc3447#section-5.2.2 RFC3447#section-5.2.2}.

return: bool|\phpseclib3\Math\BigInteger
param: \phpseclib3\Math\BigInteger $s

rsassa_pkcs1_v1_5_verify($m, $s)   X-Ref
RSASSA-PKCS1-V1_5-VERIFY

See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}.

return: bool
param: string $m
param: string $s

rsassa_pkcs1_v1_5_relaxed_verify($m, $s)   X-Ref
RSASSA-PKCS1-V1_5-VERIFY (relaxed matching)

Per {@link http://tools.ietf.org/html/rfc3447#page-43 RFC3447#page-43} PKCS1 v1.5
specified the use BER encoding rather than DER encoding that PKCS1 v2.0 specified.
This means that under rare conditions you can have a perfectly valid v1.5 signature
that fails to validate with _rsassa_pkcs1_v1_5_verify(). PKCS1 v2.1 also recommends
that if you're going to validate these types of signatures you "should indicate
whether the underlying BER encoding is a DER encoding and hence whether the signature
is valid with respect to the specification given in [PKCS1 v2.0+]". so if you do
$rsa->getLastPadding() and get RSA::PADDING_RELAXED_PKCS1 back instead of
RSA::PADDING_PKCS1... that means BER encoding was used.

return: bool
param: string $m
param: string $s

emsa_pss_verify($m, $em, $emBits)   X-Ref
EMSA-PSS-VERIFY

See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}.

return: string
param: string $m
param: string $em
param: int $emBits

rsassa_pss_verify($m, $s)   X-Ref
RSASSA-PSS-VERIFY

See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}.

return: bool|string
param: string $m
param: string $s

verify($message, $signature)   X-Ref
Verifies a signature

return: bool
see: self::sign()
param: string $message
param: string $signature

rsaes_pkcs1_v1_5_encrypt($m, $pkcs15_compat = false)   X-Ref
RSAES-PKCS1-V1_5-ENCRYPT

See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}.

return: bool|string
param: string $m
param: bool $pkcs15_compat optional

rsaes_oaep_encrypt($m)   X-Ref
RSAES-OAEP-ENCRYPT

See {@link http://tools.ietf.org/html/rfc3447#section-7.1.1 RFC3447#section-7.1.1} and
{http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}.

return: string
param: string $m

rsaep($m)   X-Ref
RSAEP

See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.1}.

return: bool|\phpseclib3\Math\BigInteger
param: \phpseclib3\Math\BigInteger $m

raw_encrypt($m)   X-Ref
Raw Encryption / Decryption

Doesn't use padding and is not recommended.

return: bool|string
param: string $m

encrypt($plaintext)   X-Ref
Encryption

Both self::PADDING_OAEP and self::PADDING_PKCS1 both place limits on how long $plaintext can be.
If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will
be concatenated together.

return: bool|string
see: self::decrypt()
param: string $plaintext

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

The public key is only returned under two circumstances - if the private key had the public key embedded within it
or if the public key was set via setPublicKey().  If the currently loaded key is supposed to be the public key this
function won't return it since this library, for the most part, doesn't distinguish between public and private keys.

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

asPrivateKey()   X-Ref
Converts a public key to a private key

return: RSA