mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 04:05:15 +00:00
Merge branch '3.0'
This commit is contained in:
commit
7c8868a632
@ -93,6 +93,7 @@ abstract class RSA extends AsymmetricKey
|
|||||||
* @see self::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
const ENCRYPTION_OAEP = 1;
|
const ENCRYPTION_OAEP = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use PKCS#1 padding.
|
* Use PKCS#1 padding.
|
||||||
*
|
*
|
||||||
@ -104,6 +105,7 @@ abstract class RSA extends AsymmetricKey
|
|||||||
* @see self::decrypt()
|
* @see self::decrypt()
|
||||||
*/
|
*/
|
||||||
const ENCRYPTION_PKCS1 = 2;
|
const ENCRYPTION_PKCS1 = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not use any padding
|
* Do not use any padding
|
||||||
*
|
*
|
||||||
@ -130,6 +132,7 @@ abstract class RSA extends AsymmetricKey
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
const SIGNATURE_PSS = 16;
|
const SIGNATURE_PSS = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a relaxed version of PKCS#1 padding for signature verification
|
* Use a relaxed version of PKCS#1 padding for signature verification
|
||||||
*
|
*
|
||||||
@ -139,6 +142,7 @@ abstract class RSA extends AsymmetricKey
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
const SIGNATURE_RELAXED_PKCS1 = 32;
|
const SIGNATURE_RELAXED_PKCS1 = 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use PKCS#1 padding for signature verification
|
* Use PKCS#1 padding for signature verification
|
||||||
*
|
*
|
||||||
|
@ -56,16 +56,14 @@ abstract class OpenSSL
|
|||||||
new BigInteger($n),
|
new BigInteger($n),
|
||||||
new BigInteger($e)
|
new BigInteger($e)
|
||||||
);
|
);
|
||||||
$rsa = RSA::load($key);
|
|
||||||
//$rsa->setPublicKeyFormat('PKCS1');
|
|
||||||
|
|
||||||
$plaintext = str_pad($x->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT);
|
$plaintext = str_pad($x->toBytes(), $n->getLengthInBytes(), "\0", STR_PAD_LEFT);
|
||||||
|
|
||||||
// this is easily prone to failure. if the modulo is a multiple of 2 or 3 or whatever it
|
// this is easily prone to failure. if the modulo is a multiple of 2 or 3 or whatever it
|
||||||
// won't work and you'll get a "failure: error:0906D06C:PEM routines:PEM_read_bio:no start line"
|
// won't work and you'll get a "failure: error:0906D06C:PEM routines:PEM_read_bio:no start line"
|
||||||
// error. i suppose, for even numbers, we could do what PHP\Montgomery.php does, but then what
|
// error. i suppose, for even numbers, we could do what PHP\Montgomery.php does, but then what
|
||||||
// about odd numbers divisible by 3, by 5, etc?
|
// about odd numbers divisible by 3, by 5, etc?
|
||||||
if (!openssl_public_encrypt($plaintext, $result, "$rsa", OPENSSL_NO_PADDING)) {
|
if (!openssl_public_encrypt($plaintext, $result, $key, OPENSSL_NO_PADDING)) {
|
||||||
throw new \UnexpectedValueException(openssl_error_string());
|
throw new \UnexpectedValueException(openssl_error_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user