Fixed #632 Fatal error: Cannot access self:: when no class scope is active

This commit is contained in:
Matej Kravjar 2017-06-20 12:40:49 +02:00
parent 3cbb9516ef
commit 47c419545a
2 changed files with 13 additions and 2 deletions

View File

@ -1357,8 +1357,8 @@ class DES extends Base
$k[self::ENCRYPT][$i] = '$ke[' . $i . ']';
$k[self::DECRYPT][$i] = '$kd[' . $i . ']';
}
$init_encrypt = '$ke = $self->keys[self::ENCRYPT];';
$init_decrypt = '$kd = $self->keys[self::DECRYPT];';
$init_encrypt = '$ke = $self->keys[$self::ENCRYPT];';
$init_decrypt = '$kd = $self->keys[$self::DECRYPT];';
break;
}

View File

@ -186,4 +186,15 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
$this->assertEquals($result, $expected, "Failed asserting inner chainin worked correctly in $engineName engine");
}
}
// test special case lambda function error
public function testCorrectSelfUseInLambda()
{
$td = new TripleDES( TripleDES::MODE_ECB );
$td->setPreferredEngine( TripleDES::ENGINE_INTERNAL );
for ( $i = 0; $i < 20; $i++ ) {
$td->setKey( str_repeat( 'a', 20 ) . pack( 'V', mt_rand() ) );
$td->encrypt( str_repeat( 'a', 32 ) );
}
}
}