diff --git a/src/JWT.php b/src/JWT.php index 22a67e32..785dc683 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -44,6 +44,7 @@ class JWT 'RS256' => array('openssl', 'SHA256'), 'RS384' => array('openssl', 'SHA384'), 'RS512' => array('openssl', 'SHA512'), + 'ES256' => array('openssl', 'SHA256'), ); /** diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 804a3769..959034dd 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -206,17 +206,29 @@ public function testEmptyKeyFails() $decoded = JWT::decode($encoded, '', array('HS256')); } - public function testRSEncodeDecode() - { - $privKey = openssl_pkey_new(array('digest_alg' => 'sha256', - 'private_key_bits' => 1024, - 'private_key_type' => OPENSSL_KEYTYPE_RSA)); - $msg = JWT::encode('abc', $privKey, 'RS256'); - $pubKey = openssl_pkey_get_details($privKey); - $pubKey = $pubKey['key']; - $decoded = JWT::decode($msg, $pubKey, array('RS256')); - $this->assertEquals($decoded, 'abc'); - } + public function testRSEncodeDecode() + { + $privKey = openssl_pkey_new(array('digest_alg' => 'sha256', + 'private_key_bits' => 1024, + 'private_key_type' => OPENSSL_KEYTYPE_RSA)); + $msg = JWT::encode('abc', $privKey, 'RS256'); + $pubKey = openssl_pkey_get_details($privKey); + $pubKey = $pubKey['key']; + $decoded = JWT::decode($msg, $pubKey, array('RS256')); + $this->assertEquals($decoded, 'abc'); + } + + public function testESEncodeDecode() + { + $privKey = openssl_pkey_new(array('digest_alg' => 'sha256', + 'private_key_bits' => 1024, + 'private_key_type' => OPENSSL_KEYTYPE_RSA)); + $msg = JWT::encode('abc', $privKey, 'ES256'); + $pubKey = openssl_pkey_get_details($privKey); + $pubKey = $pubKey['key']; + $decoded = JWT::decode($msg, $pubKey, array('ES256')); + $this->assertEquals($decoded, 'abc'); + } public function testKIDChooser() {