Skip to content

Commit 8152795

Browse files
committed
JsonSerialized SignRequest and fix public property access bug
1 parent 71ebc19 commit 8152795

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/SignRequest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Samyoul\U2F\U2FServer;
1010

1111

12-
class SignRequest
12+
class SignRequest implements \JsonSerializable
1313
{
1414
/** Protocol version */
1515
protected $version = U2FServer::VERSION;
@@ -62,4 +62,14 @@ public function appId()
6262
return $this->appId;
6363
}
6464

65+
public function jsonSerialize()
66+
{
67+
return [
68+
'version' => $this->version,
69+
'challenge' => $this->challenge,
70+
'keyHandle' => $this->keyHandle,
71+
'appId' => $this->appId,
72+
];
73+
}
74+
6575
}

src/U2FServer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public static function makeAuthentication(array $registrations, $appId)
216216
* @param array $requests An array of outstanding authentication requests
217217
* @param array <Registration> $registrations An array of current registrations
218218
* @param object $response A response from the authenticator
219-
* @return Registration
219+
* @return \stdClass
220220
* @throws U2FException
221221
*
222222
* The Registration object returned on success contains an updated counter
@@ -255,7 +255,7 @@ public static function authenticate(array $requests, array $registrations, $resp
255255
throw new \InvalidArgumentException('$requests of authenticate() method only accepts an array of objects.');
256256
}
257257

258-
if($req->keyHandle === $response->keyHandle && $req->challenge === $decodedClient->challenge) {
258+
if($req->keyHandle() === $response->keyHandle && $req->challenge() === $decodedClient->challenge) {
259259
break;
260260
}
261261

@@ -297,7 +297,7 @@ public static function authenticate(array $requests, array $registrations, $resp
297297

298298
// Build signature and data from response
299299
$signData = static::base64u_decode($response->signatureData);
300-
$dataToVerify = hash('sha256', $req->appId, true);
300+
$dataToVerify = hash('sha256', $req->appId(), true);
301301
$dataToVerify .= substr($signData, 0, 5);
302302
$dataToVerify .= hash('sha256', $clientData, true);
303303
$signature = substr($signData, 5);

0 commit comments

Comments
 (0)