Skip to content

Commit

Permalink
Fix #74
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Apr 20, 2018
1 parent ed7c455 commit 157ca23
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Protocol/Version1.php
Expand Up @@ -236,10 +236,10 @@ public static function verify(
}
if (\is_null($footer)) {
$footer = Util::extractFooter($signMsg);
$signMsg = Util::removeFooter($signMsg);
} else {
$signMsg = Util::validateAndRemoveFooter($signMsg, $footer);
}
$signMsg = Util::removeFooter($signMsg);
$expectHeader = self::HEADER . '.public.';
$givenHeader = Binary::safeSubstr($signMsg, 0, 10);
if (!\hash_equals($expectHeader, $givenHeader)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Version2.php
Expand Up @@ -218,10 +218,10 @@ public static function verify(
}
if (\is_null($footer)) {
$footer = Util::extractFooter($signMsg);
$signMsg = Util::removeFooter($signMsg);
} else {
$signMsg = Util::validateAndRemoveFooter($signMsg, $footer);
}
$signMsg = Util::removeFooter($signMsg);
/** @var string $footer */
$expectHeader = self::HEADER . '.public.';
$givenHeader = Binary::safeSubstr($signMsg, 0, 10);
Expand Down
4 changes: 2 additions & 2 deletions tests/Version1Test.php
Expand Up @@ -153,9 +153,9 @@ public function testSign()
$this->assertInternalType('string', $signed);
$this->assertSame('v1.public.', Binary::safeSubstr($signed, 0, 10));
try {
Version1::verify($signed, $publicKey);
Version1::verify($signed, $publicKey, '');
$this->fail('Missing footer');
} catch (\Exception $ex) {
} catch (PasetoException $ex) {
}
$decode = Version1::verify($signed, $publicKey, 'footer');
$this->assertInternalType('string', $decode);
Expand Down
4 changes: 2 additions & 2 deletions tests/Version2Test.php
Expand Up @@ -134,9 +134,9 @@ public function testSign()
$this->assertInternalType('string', $signed);
$this->assertSame('v2.public.', Binary::safeSubstr($signed, 0, 10));
try {
Version2::verify($signed, $publicKey);
Version2::verify($signed, $publicKey, '');
$this->fail('Missing footer');
} catch (\Exception $ex) {
} catch (PasetoException $ex) {
}
$decode = Version2::verify($signed, $publicKey, 'footer');
$this->assertInternalType('string', $decode);
Expand Down

0 comments on commit 157ca23

Please sign in to comment.