├── run-tests.bat ├── .travis.yml ├── tests ├── Utility.php └── Security.php ├── CHANGELOG.md ├── wishlist.txt ├── LICENSE ├── composer.json ├── src ├── Image.php ├── BaseFuture.php ├── Utility.php └── Security.php ├── run-tests.sh ├── README.md └── autoload.php /run-tests.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM todo: interface with gpg4win to verify the signature 3 | php vendor\phpunit\phpunit\phpunit --bootstrap autoload.php tests -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | 5 | - 5.3 6 | - 5.4 7 | - 5.5 8 | - 5.6 9 | 10 | 11 | install: 12 | 13 | - composer self-update 14 | - chmod +x ./run-tests.sh 15 | 16 | script: ./run-tests.sh 17 | -------------------------------------------------------------------------------- /tests/Utility.php: -------------------------------------------------------------------------------- 1 | 1, 'b' => 1], 13 | ['a' => 2, 'b' => 3], 14 | ['a' => 3, 'b' => 2] 15 | ]; 16 | 17 | $y = [ 18 | 1 => 1, 19 | 2 => 3, 20 | 3 => 2 21 | ]; 22 | 23 | $this->assertEquals( 24 | $y, 25 | Future\Utility::arrayColumn($x, 'b', 'a') 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.3.0 4 | 5 | Widened scope to include 5.3 because of LTS operating systems. 6 | Also added a `BaseFuture` class to prevent code duplication. 7 | 8 | ### New functions polyfilled 9 | 10 | * **PHP 5.4** 11 | * `getimagesizefromstring()` 12 | * `hex2bin()` 13 | 14 | ### New interfaces polyfilled 15 | 16 | * **PHP 5.4** 17 | * `JsonSerializable` 18 | * `SessionHandlerInterface` 19 | 20 | ## 0.2.0 21 | 22 | ### New functions polyfilled 23 | 24 | * **PHP 5.5** 25 | * `array_column()` 26 | * `boolval()` 27 | * `hash_pbkdf2()` 28 | * `openssl_pbkdf2()` 29 | 30 | ## 0.1.1 31 | 32 | Added unit test coverage. 33 | 34 | ## 0.1.0 35 | 36 | Initial release. Just polyfilled hash_equals() -------------------------------------------------------------------------------- /wishlist.txt: -------------------------------------------------------------------------------- 1 | PHP 5.4 2 | 3 | CLASSES/INTERFACES 4 | ================== 5 | CallbackFilterIterator 6 | RecursiveCallbackFilterIterator 7 | 8 | SessionHandler 9 | Transliterator 10 | Spoofchecker 11 | 12 | PHP 5.5 13 | 14 | FUNCTIONS 15 | ========= 16 | curl_escape() 17 | curl_unescape() 18 | pg_escape_literal() 19 | pg_escape_identifier() 20 | 21 | CLASSES/INTERFACES 22 | ================== 23 | DateTimeImmutable 24 | DateTimeInterface 25 | IntlCalendar 26 | IntlGregorianCalendar 27 | IntlTimeZone 28 | IntlBreakIterator 29 | IntlRuleBasedBreakIterator 30 | IntlCodePointBreakIterator 31 | 32 | PHP 5.6 33 | 34 | gmp_root() 35 | gmp_rootrem() 36 | ldap_escape() 37 | ldap_modify_batch() 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Resonant Core, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sarciszewski/php-future", 3 | "description": "Polyfill new (5.6+) features into old (5.4+) versions of PHP", 4 | "keywords": [ 5 | "security", 6 | "future", 7 | "compatibility", 8 | "hash_equals" 9 | ], 10 | "license": "MIT", 11 | "type": "library", 12 | "authors": [ 13 | { 14 | "name": "Scott Arciszewski", 15 | "email": "scott@paragonie.com", 16 | "homepage": "https://appsec.solutions", 17 | "role": "Developer" 18 | } 19 | ], 20 | "support": { 21 | "issues": "https://github.com/sarciszewski/php-future/issues", 22 | "email": "info@paragonie.com", 23 | "source": "https://github.com/sarciszewski/php-future" 24 | }, 25 | "autoload": { 26 | "files": ["autoload.php"] 27 | }, 28 | "require": { 29 | "paragonie/random_compat": "^1|^2|^9", 30 | "paragonie/sodium_compat": "^1|^2", 31 | "ircmaxell/password_compat": "^1.0" 32 | }, 33 | "require-dev": { 34 | "phpunit/phpunit": "4.5.*" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/Security.php: -------------------------------------------------------------------------------- 1 | assertTrue(\hash_equals($a, $b)); 16 | 17 | $a = 'd4ef98335dc5512500ea74a70a26dbd2759acc0ac116f0d747d05848a8365da9'; 18 | $b = 'd4ef98335dc5512500ea74a70a26dbd2759acc0ac116f0d747d05848a8365da1'; 19 | 20 | $this->assertFalse(\hash_equals($a, $b)); 21 | } 22 | 23 | /** 24 | * @covers \Sarciszewski\PHPFuture\Security::pbkdf2() 25 | * ref https://www.ietf.org/rfc/rfc6070.txt 26 | */ 27 | public function testPBKDF2() 28 | { 29 | $a = Future\Security::pbkdf2("sha1", "password", "salt", 2, 20, true); 30 | $this->assertEquals( 31 | $a, 32 | hex2bin('ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957') 33 | ); 34 | 35 | $b = Future\Security::pbkdf2("sha1", "password", "salt", 2, 20, false); 36 | $this->assertEquals( 37 | $b, 38 | 'ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957' 39 | ); 40 | 41 | 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Image.php: -------------------------------------------------------------------------------- 1 | 9 | gpg --fingerprint D8406D0D82947747293778314AA394086372C20A 10 | if [ $? -ne 0 ]; then 11 | echo -e "\033[31mCould not download PGP public key for verification\033[0m" 12 | exit 13 | fi 14 | fi 15 | if [ "$clean" -eq 1 ]; then 16 | # Let's clean them up, if they exist 17 | if [ -f phpunit.phar ]; then 18 | rm -f phpunit.phar 19 | fi 20 | if [ -f phpunit.phar.asc ]; then 21 | rm -f phpunit.phar.asc 22 | fi 23 | fi 24 | 25 | # Let's grab the latest release and its signature 26 | if [ ! -f phpunit.phar ]; then 27 | wget https://phar.phpunit.de/phpunit.phar 28 | fi 29 | if [ ! -f phpunit.phar.asc ]; then 30 | wget https://phar.phpunit.de/phpunit.phar.asc 31 | fi 32 | 33 | # Verify before running 34 | gpg --verify phpunit.phar.asc phpunit.phar 35 | if [ $? -eq 0 ]; then 36 | echo 37 | echo -e "\033[33mBegin Unit Testing\033[0m" 38 | # Run the testing suite 39 | php phpunit.phar --bootstrap autoload.php tests 40 | # Cleanup 41 | if [ "$clean" -eq 1 ]; then 42 | echo -e "\033[32mCleaning Up!\033[0m" 43 | rm -f phpunit.phar 44 | rm -f phpunit.phar.asc 45 | fi 46 | else 47 | echo 48 | chmod -x phpunit.phar 49 | mv phpunit.phar /tmp/bad-phpunit.phar 50 | mv phpunit.phar.asc /tmp/bad-phpunit.phar.asc 51 | echo -e "\033[31mSignature did not match! Check /tmp/bad-phpunit.phar for trojans\033[0m" 52 | exit 1 53 | fi 54 | 55 | # The MIT License (MIT) 56 | # 57 | # Copyright (c) 2015 Resonant Core, LLC 58 | # 59 | # Permission is hereby granted, free of charge, to any person obtaining a copy 60 | # of this software and associated documentation files (the "Software"), to deal 61 | # in the Software without restriction, including without limitation the rights 62 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 63 | # copies of the Software, and to permit persons to whom the Software is 64 | # furnished to do so, subject to the following conditions: 65 | # 66 | # The above copyright notice and this permission notice shall be included in all 67 | # copies or substantial portions of the Software. 68 | # 69 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 70 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 71 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 72 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 73 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 74 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 75 | # SOFTWARE. 76 | -------------------------------------------------------------------------------- /src/Utility.php: -------------------------------------------------------------------------------- 1 |