Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
V7.0 (#303)
Browse files Browse the repository at this point in the history
* v7.0

* Doc updated

* Object conflict

* PHPUnit 6

* Apply fixes from StyleCI (#302)

[ci skip] [skip ci]
  • Loading branch information
Spomky authored Oct 11, 2017
1 parent 2f814f3 commit 8c99915
Show file tree
Hide file tree
Showing 69 changed files with 1,209 additions and 1,191 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ sudo: true
matrix:
allow_failures:
- php: nightly
- php: hhvm
fast_finish: true
include:
- php: 5.6
env: deps=low
- php: 5.6
- php: 7.0
- php: 7.0
env: deps=low
- php: 7.1
- php: hhvm
- php: hhvm
env: deps=low
- php: 7.2
- php: nightly

before_script:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ The release process [is described here](doc/Release.md).
# Prerequisites

This library needs at least:
* ![PHP 5.6+](https://img.shields.io/badge/PHP-5.6%2B-ff69b4.svg),
* ![PHP 7.0+](https://img.shields.io/badge/PHP-7.0%2B-ff69b4.svg),
* OpenSSL extension.

Please consider the following optional requirements:
Expand All @@ -136,7 +136,8 @@ As the time needed to perform operation is long compared to the other algorithms

# Continuous Integration

It has been successfully tested using `PHP 5.6`, `PHP 7.0`, `PHP 7.1` and `HHVM` with all algorithms.
It has been successfully tested using `PHP 7.0`, `PHP 7.1` and `PHP7.2` with all algorithms.
If you use PHP 5.6, please install the version ^6.0 of this project.

Tests vectors from the [RFC 7520](http://tools.ietf.org/html/rfc7520) are fully implemented and all tests pass.

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@
}
},
"require": {
"php": "^5.6|^7.0",
"php": "^7.0",
"lib-openssl": "*",
"spomky-labs/base64url": "^1.0",
"spomky-labs/aes-key-wrap": "^3.0",
"spomky-labs/php-aes-gcm": "^1.2",
"beberlei/assert": "^2.4",
"symfony/polyfill-mbstring": "^1.1",
"symfony/polyfill-php70": "^1.1",
"fgrosse/phpasn1": "^2.0",
"mdanter/ecc": "0.5.*",
"psr/cache": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
"phpunit/phpunit": "^6.0",
"satooshi/php-coveralls": "^1.0",
"symfony/cache": "^2.0|^3.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Algorithm/Signature/ECDSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Assert\Assertion;
use Base64Url\Base64Url;
use FG\ASN1\Object;
use FG\ASN1\ASNObject;
use FG\ASN1\Universal\Integer;
use FG\ASN1\Universal\Sequence;
use Jose\Algorithm\SignatureAlgorithmInterface;
Expand Down Expand Up @@ -56,7 +56,7 @@ private function getOpenSSLSignature(JWKInterface $key, $data)

Assertion::true($result, 'Signature failed');

$asn = Object::fromBinary($signature);
$asn = ASNObject::fromBinary($signature);
Assertion::isInstanceOf($asn, Sequence::class, 'Invalid signature');

$res = '';
Expand Down
17 changes: 9 additions & 8 deletions src/Behaviour/EncrypterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
use Base64Url\Base64Url;
use Jose\Algorithm;
use Jose\Compression;
use Jose\Object;
use Jose\Object\JWEInterface;
use Jose\Object\JWKInterface;

trait EncrypterTrait
{
Expand All @@ -27,13 +28,13 @@ trait EncrypterTrait
*
* @return bool
*/
abstract protected function checkKeyUsage(Object\JWKInterface $key, $usage);
abstract protected function checkKeyUsage(JWKInterface $key, $usage);

/**
* @param \Jose\Object\JWKInterface $key
* @param string $algorithm
*/
abstract protected function checkKeyAlgorithm(Object\JWKInterface $key, $algorithm);
abstract protected function checkKeyAlgorithm(JWKInterface $key, $algorithm);

/**
* @return \Jose\Algorithm\JWAManagerInterface
Expand All @@ -50,7 +51,7 @@ abstract protected function getCompressionManager();
* @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm
* @param \Jose\Object\JWKInterface $recipient_key
*/
private function checkKeys(Algorithm\KeyEncryptionAlgorithmInterface $key_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, Object\JWKInterface $recipient_key)
private function checkKeys(Algorithm\KeyEncryptionAlgorithmInterface $key_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, JWKInterface $recipient_key)
{
$this->checkKeyUsage($recipient_key, 'encryption');
if ('dir' !== $key_encryption_algorithm->getAlgorithmName()) {
Expand All @@ -68,7 +69,7 @@ private function checkKeys(Algorithm\KeyEncryptionAlgorithmInterface $key_encryp
*
* @return string
*/
private function determineCEK(Object\JWEInterface $jwe, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, $key_management_mode, array &$additional_headers)
private function determineCEK(JWEInterface $jwe, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, $key_management_mode, array &$additional_headers)
{
switch ($key_management_mode) {
case Algorithm\KeyEncryption\KeyEncryptionInterface::MODE_ENCRYPT:
Expand Down Expand Up @@ -96,7 +97,7 @@ private function determineCEK(Object\JWEInterface $jwe, Algorithm\ContentEncrypt
*
* @return string
*/
private function getKeyManagementMode(Object\JWEInterface $jwe)
private function getKeyManagementMode(JWEInterface $jwe)
{
$mode = null;
$recipients = $jwe->getRecipients();
Expand All @@ -123,7 +124,7 @@ private function getKeyManagementMode(Object\JWEInterface $jwe)
*
* @return \Jose\Compression\CompressionInterface|null
*/
private function getCompressionMethod(Object\JWEInterface $jwe)
private function getCompressionMethod(JWEInterface $jwe)
{
$method = null;
$nb_recipients = $jwe->countRecipients();
Expand Down Expand Up @@ -160,7 +161,7 @@ private function getCompressionMethod(Object\JWEInterface $jwe)
*
* @return \Jose\Algorithm\ContentEncryptionAlgorithmInterface
*/
private function getContentEncryptionAlgorithm(Object\JWEInterface $jwe)
private function getContentEncryptionAlgorithm(JWEInterface $jwe)
{
$algorithm = null;

Expand Down
7 changes: 4 additions & 3 deletions src/Checker/CheckerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
namespace Jose\Checker;

use Assert\Assertion;
use Jose\Object;
use Jose\Object\JWSInterface;
use Jose\Object\JWTInterface;

/**
* Class CheckerManager.
Expand All @@ -34,7 +35,7 @@ class CheckerManager implements CheckerManagerInterface
*
* @return string[]
*/
private function checkJWT(Object\JWTInterface $jwt)
private function checkJWT(JWTInterface $jwt)
{
$checked_claims = [];

Expand Down Expand Up @@ -63,7 +64,7 @@ private function checkHeaders(array $protected_headers, array $headers, array $c
/**
* {@inheritdoc}
*/
public function checkJWS(Object\JWSInterface $jws, $signature)
public function checkJWS(JWSInterface $jws, $signature)
{
Assertion::integer($signature);
Assertion::lessThan($signature, $jws->countSignatures());
Expand Down
22 changes: 11 additions & 11 deletions src/KeyConverter/ECKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Assert\Assertion;
use Base64Url\Base64Url;
use FG\ASN1\ExplicitlyTaggedObject;
use FG\ASN1\Object;
use FG\ASN1\ASNObject;
use FG\ASN1\Universal\BitString;
use FG\ASN1\Universal\Integer;
use FG\ASN1\Universal\ObjectIdentifier;
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct($data)
private function loadPEM($data)
{
$data = base64_decode(preg_replace('#-.*-|\r|\n#', '', $data));
$asnObject = Object::fromBinary($data);
$asnObject = ASNObject::fromBinary($data);

Assertion::isInstanceOf($asnObject, Sequence::class);
$children = $asnObject->getChildren();
Expand All @@ -89,7 +89,7 @@ private function loadPEM($data)
private function loadPKCS8(array $children)
{
$binary = hex2bin($children[2]->getContent());
$asnObject = Object::fromBinary($binary);
$asnObject = ASNObject::fromBinary($binary);
Assertion::isInstanceOf($asnObject, Sequence::class);

return $asnObject->getChildren();
Expand Down Expand Up @@ -193,20 +193,20 @@ private function loadPublicPEM(array $children)
}

/**
* @param \FG\ASN1\Object $children
* @param \FG\ASN1\ASNObject $children
*/
private function verifyVersion(Object $children)
private function verifyVersion(ASNObject $children)
{
Assertion::isInstanceOf($children, Integer::class, 'Unable to load the key');
Assertion::eq(1, $children->getContent(), 'Unable to load the key');
}

/**
* @param \FG\ASN1\Object $children
* @param string|null $x
* @param string|null $y
* @param \FG\ASN1\ASNObject $children
* @param string|null $x
* @param string|null $y
*/
private function getXAndY(Object $children, &$x, &$y)
private function getXAndY(ASNObject $children, &$x, &$y)
{
Assertion::isInstanceOf($children, ExplicitlyTaggedObject::class, 'Unable to load the key');
Assertion::isArray($children->getContent(), 'Unable to load the key');
Expand All @@ -222,11 +222,11 @@ private function getXAndY(Object $children, &$x, &$y)
}

/**
* @param \FG\ASN1\Object $children
* @param \FG\ASN1\ASNObject $children
*
* @return string
*/
private function getD(Object $children)
private function getD(ASNObject $children)
{
Assertion::isInstanceOf($children, '\FG\ASN1\Universal\OctetString', 'Unable to load the key');

Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase.php → tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
use Jose\Test\Stub\IssuerChecker;
use Jose\Test\Stub\JtiChecker;
use Jose\Test\Stub\SubjectChecker;
use PHPUnit\Framework\TestCase;

/**
* Class TestCase.
*/
class TestCase extends \PHPUnit_Framework_TestCase
class BaseTestCase extends TestCase
{
/**
* @var \Jose\Checker\CheckerManagerInterface|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

use Jose\Decrypter;
use Jose\Loader;
use Jose\Test\TestCase;
use Jose\Test\BaseTestCase;

/**
* @group CVE
* @group Functional
*/
class InvalidCurveAttackTest extends TestCase
class InvalidCurveAttackBaseTest extends BaseTestCase
{
/**
* @expectedException \InvalidArgumentException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

use Jose\Factory\JWSFactory;
use Jose\Object\JWK;
use Jose\Test\TestCase;
use Jose\Test\BaseTestCase;

/**
* @group CheckerManager
* @group Functional
*/
class CheckerManagerTest extends TestCase
class CheckerManagerBaseTest extends BaseTestCase
{
/**
* @expectedException \InvalidArgumentException
Expand Down
Loading

0 comments on commit 8c99915

Please sign in to comment.