<commit_before><?php
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 */

require_once 'Crypt/RSA.php' ;

class Unit_Crypt_RSA_ModeTest extends PhpseclibTestCase
{
    public function testEncryptionModeNone()
    {
        $plaintext = 'a';

        $rsa = new Crypt_RSA();

        $privatekey = '-----<KEY>';
        $rsa->loadKey($privatekey);
        $rsa->loadKey($rsa->getPublicKey());

        $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_NONE);
        $expected = '105b92f59a87a8ad4da52c128b8c99491790ef5a54770119e0819060032fb9e772ed6772828329567f3d7e9472154c1530f8156ba7fd732f52ca1c06' .
            '5a3f5ed8a96c442e4662e0464c97f133aed31262170201993085a589565d67cc9e727e0d087e3b225c8965203b271e38a499c92fc0d6502297eca712' .
            '4d04bd467f6f1e7c';
        $expected = pack('H*', $expected);
        $result = $rsa->encrypt($plaintext);

        $this->assertEquals($result, $expected);

        $rsa->loadKey($privatekey);
        $this->assertEquals(trim($rsa->decrypt($result), "\0"), $plaintext);
    }
}<commit_msg>Tests/RSA: add PSS test<commit_after><?php
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 */

require_once 'Crypt/RSA.php' ;

class Unit_Crypt_RSA_ModeTest extends PhpseclibTestCase
{
    public function testEncryptionModeNone()
    {
        $plaintext = 'a';

        $rsa = new Crypt_RSA();

        $privatekey = '-----BEGIN RSA PRIVATE KEY-----
<KEY>
-----END RSA PRIVATE KEY-----';
        $rsa->loadKey($privatekey);
        $rsa->loadKey($rsa->getPublicKey());

        $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_NONE);
        $expected = '105b92f59a87a8ad4da52c128b8c99491790ef5a54770119e0819060032fb9e772ed6772828329567f3d7e9472154c1530f8156ba7fd732f52ca1c06' .
            '5a3f5ed8a96c442e4662e0464c97f133aed31262170201993085a589565d67cc9e727e0d087e3b225c8965203b271e38a499c92fc0d6502297eca712' .
            '4d04bd467f6f1e7c';
        $expected = pack('H*', $expected);
        $result = $rsa->encrypt($plaintext);

        $this->assertEquals($result, $expected);

        $rsa->loadKey($privatekey);
        $this->assertEquals(trim($rsa->decrypt($result), "\0"), $plaintext);
    }

    /**
     * @group github768
     */
    public function testPSSSigs()
    {
        $rsa = new Crypt_RSA();
        $rsa->loadKey('-----<KEY>
-----END PUBLIC KEY-----');

        $sig = pack('H*', '1bd29a1d704a906cd7f726370ce1c63d8fb7b9a620871a05f3141a311c0d6e75fefb5d36dfb50d3ea2d37cd67992471419bfadd35da6e13b494' .
            '058ddc9b568d4cfea13ddc3c62b86a6256f5f296980d1131d3eaec6089069a3de79983f73eae20198a18721338b4a66e9cfe80e4f8e4fcef7a5bead5cbb' .
            'b8ac4c76adffbc178c');

        $this->assertTrue($rsa->verify('zzzz', $sig));
    }
}
{'fraction_non_alphanumeric': 0.1392931392931393, 'fraction_numerical': 0.1826056826056826, 'mean_word_length': 3.489891135303266, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3378071', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1145, 'n_words': 120}