summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-18 15:29:53 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-18 15:29:53 +0100
commit9a152a91c982d5f2ba07d0197ef2fe5eb8c8510c (patch)
tree089223cd683e17c84e4a80a4ee3592df3f5a8e9d /tests/codeigniter/core
parent9c7ce322232eb1e55b9caa138dffe67d9acc660f (diff)
Add an ext/hash compatibility layer (just hash_pbkdf2(), for now)
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/compat/hash_test.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/codeigniter/core/compat/hash_test.php b/tests/codeigniter/core/compat/hash_test.php
new file mode 100644
index 000000000..25bbd4eb1
--- /dev/null
+++ b/tests/codeigniter/core/compat/hash_test.php
@@ -0,0 +1,51 @@
+<?php
+
+class hash_test extends CI_TestCase {
+
+ public function test_bootstrap()
+ {
+ if (is_php('5.5'))
+ {
+ return $this->markTestSkipped('ext/standard/password is available on PHP 5.5');
+ }
+
+ $this->assertTrue(function_exists('hash_pbkdf2'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * hash_pbkdf2() test
+ *
+ * Borrowed from PHP's own tests
+ *
+ * @depends test_bootstrap
+ */
+ public function test_hash_pbkdf2()
+ {
+ $this->assertEquals('0c60c80f961f0e71f3a9', hash_pbkdf2('sha1', 'password', 'salt', 1, 20));
+ $this->assertEquals(
+ "\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6",
+ hash_pbkdf2('sha1', 'password', 'salt', 1, 20, TRUE)
+ );
+ $this->assertEquals('3d2eec4fe41c849b80c8d8366', hash_pbkdf2('sha1', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25));
+ $this->assertEquals(
+ "\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38",
+ hash_pbkdf2('sha1', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25, TRUE)
+ );
+ $this->assertEquals('120fb6cffcf8b32c43e7', hash_pbkdf2('sha256', 'password', 'salt', 1, 20));
+ $this->assertEquals(
+ "\x12\x0f\xb6\xcf\xfc\xf8\xb3\x2c\x43\xe7\x22\x52\x56\xc4\xf8\x37\xa8\x65\x48\xc9",
+ hash_pbkdf2('sha256', 'password', 'salt', 1, 20, TRUE)
+ );
+ $this->assertEquals(
+ '348c89dbcbd32b2f32d814b8116e84cf2b17347e',
+ hash_pbkdf2('sha256', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 40)
+ );
+ $this->assertEquals(
+ "\x34\x8c\x89\xdb\xcb\xd3\x2b\x2f\x32\xd8\x14\xb8\x11\x6e\x84\xcf\x2b\x17\x34\x7e\xbc\x18\x00\x18\x1c\x4e\x2a\x1f\xb8\xdd\x53\xe1\xc6\x35\x51\x8c\x7d\xac\x47\xe9",
+ hash_pbkdf2('sha256', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 40, TRUE)
+ );
+ }
+
+} \ No newline at end of file