} signRequests
- * @param {function((u2f.Error|u2f.RegisterResponse))} callback
- * @param {number=} opt_timeoutSeconds
- */
-u2f.register = function(registerRequests, signRequests,
- callback, opt_timeoutSeconds) {
- u2f.getPortSingleton_(function(port) {
- var reqId = ++u2f.reqCounter_;
- u2f.callbackMap_[reqId] = callback;
- var timeoutSeconds = (typeof opt_timeoutSeconds !== 'undefined' ?
- opt_timeoutSeconds : u2f.EXTENSION_TIMEOUT_SEC);
- var req = port.formatRegisterRequest_(
- signRequests, registerRequests, timeoutSeconds, reqId);
- port.postMessage(req);
- });
-};
\ No newline at end of file
diff --git a/data/web/inc/lib/vendor/yubico/u2flib-server/examples/cli/u2f-server.phps b/data/web/inc/lib/vendor/yubico/u2flib-server/examples/cli/u2f-server.phps
deleted file mode 100755
index 8acb66a4da..0000000000
--- a/data/web/inc/lib/vendor/yubico/u2flib-server/examples/cli/u2f-server.phps
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/php
-getRegisterData();
-} elseif($mode === "authenticate") {
- $challenge = $u2f->getAuthenticateData($regs);
-}
-
-print json_encode($challenge[0]) . "\n";
-$response = fgets(STDIN);
-
-if($mode === "register") {
- $result = $u2f->doRegister($challenge[0], json_decode($response));
-} elseif($mode === "authenticate") {
- $result = $u2f->doAuthenticate($challenge, $regs, json_decode($response));
-}
-
-print json_encode($result) . "\n";
-
-?>
diff --git a/data/web/inc/lib/vendor/yubico/u2flib-server/examples/localstorage/index.phps b/data/web/inc/lib/vendor/yubico/u2flib-server/examples/localstorage/index.phps
deleted file mode 100644
index d840dd36a1..0000000000
--- a/data/web/inc/lib/vendor/yubico/u2flib-server/examples/localstorage/index.phps
+++ /dev/null
@@ -1,186 +0,0 @@
-
-
-
- PHP U2F Demo
-
-
-
-
-
-
-
-
-
-
- 0 Authenticators currently registered.
-
-
-
-
-
diff --git a/data/web/inc/lib/vendor/yubico/u2flib-server/examples/pdo/index.phps b/data/web/inc/lib/vendor/yubico/u2flib-server/examples/pdo/index.phps
deleted file mode 100644
index c04d63e247..0000000000
--- a/data/web/inc/lib/vendor/yubico/u2flib-server/examples/pdo/index.phps
+++ /dev/null
@@ -1,204 +0,0 @@
-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
-
-$pdo->exec("create table if not exists users (id integer primary key, name varchar(255))");
-$pdo->exec("create table if not exists registrations (id integer primary key, user_id integer, keyHandle varchar(255), publicKey varchar(255), certificate text, counter integer)");
-
-$scheme = isset($_SERVER['HTTPS']) ? "https://" : "http://";
-$u2f = new u2flib_server\U2F($scheme . $_SERVER['HTTP_HOST']);
-
-session_start();
-
-function createAndGetUser($name) {
- global $pdo;
- $sel = $pdo->prepare("select * from users where name = ?");
- $sel->execute(array($name));
- $user = $sel->fetch();
- if(!$user) {
- $ins = $pdo->prepare("insert into users (name) values(?)");
- $ins->execute(array($name));
- $sel->execute(array($name));
- $user = $sel->fetch();
- }
- return $user;
-}
-
-function getRegs($user_id) {
- global $pdo;
- $sel = $pdo->prepare("select * from registrations where user_id = ?");
- $sel->execute(array($user_id));
- return $sel->fetchAll();
-}
-
-function addReg($user_id, $reg) {
- global $pdo;
- $ins = $pdo->prepare("insert into registrations (user_id, keyHandle, publicKey, certificate, counter) values (?, ?, ?, ?, ?)");
- $ins->execute(array($user_id, $reg->keyHandle, $reg->publicKey, $reg->certificate, $reg->counter));
-}
-
-function updateReg($reg) {
- global $pdo;
- $upd = $pdo->prepare("update registrations set counter = ? where id = ?");
- $upd->execute(array($reg->counter, $reg->id));
-}
-
-?>
-
-
-
- PHP U2F example
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/web/inc/lib/vendor/yubico/u2flib-server/phpunit.xml b/data/web/inc/lib/vendor/yubico/u2flib-server/phpunit.xml
deleted file mode 100644
index fa6f08e836..0000000000
--- a/data/web/inc/lib/vendor/yubico/u2flib-server/phpunit.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- tests
-
-
-
-
-
diff --git a/data/web/inc/lib/vendor/yubico/u2flib-server/psalm.xml b/data/web/inc/lib/vendor/yubico/u2flib-server/psalm.xml
deleted file mode 100644
index 6b6234cfbd..0000000000
--- a/data/web/inc/lib/vendor/yubico/u2flib-server/psalm.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/web/inc/lib/vendor/yubico/u2flib-server/src/u2flib_server/U2F.php b/data/web/inc/lib/vendor/yubico/u2flib-server/src/u2flib_server/U2F.php
deleted file mode 100644
index 8583fff2ea..0000000000
--- a/data/web/inc/lib/vendor/yubico/u2flib-server/src/u2flib_server/U2F.php
+++ /dev/null
@@ -1,563 +0,0 @@
-appId = $appId;
- $this->attestDir = $attestDir;
- }
-
- /**
- * Called to get a registration request to send to a user.
- * Returns an array of one registration request and a array of sign requests.
- *
- * @param array $registrations List of current registrations for this
- * user, to prevent the user from registering the same authenticator several
- * times.
- * @return array An array of two elements, the first containing a
- * RegisterRequest the second being an array of SignRequest
- * @throws Error
- */
- public function getRegisterData(array $registrations = array())
- {
- $challenge = $this->createChallenge();
- $request = new RegisterRequest($challenge, $this->appId);
- $signs = $this->getAuthenticateData($registrations);
- return array($request, $signs);
- }
-
- /**
- * Called to verify and unpack a registration message.
- *
- * @param RegisterRequest $request this is a reply to
- * @param object $response response from a user
- * @param bool $includeCert set to true if the attestation certificate should be
- * included in the returned Registration object
- * @return Registration
- * @throws Error
- */
- public function doRegister($request, $response, $includeCert = true)
- {
- if( !is_object( $request ) ) {
- throw new \InvalidArgumentException('$request of doRegister() method only accepts object.');
- }
-
- if( !is_object( $response ) ) {
- throw new \InvalidArgumentException('$response of doRegister() method only accepts object.');
- }
-
- if( property_exists( $response, 'errorCode') && $response->errorCode !== 0 ) {
- throw new Error('User-agent returned error. Error code: ' . $response->errorCode, ERR_BAD_UA_RETURNING );
- }
-
- if( !is_bool( $includeCert ) ) {
- throw new \InvalidArgumentException('$include_cert of doRegister() method only accepts boolean.');
- }
-
- $rawReg = $this->base64u_decode($response->registrationData);
- $regData = array_values(unpack('C*', $rawReg));
- $clientData = $this->base64u_decode($response->clientData);
- $cli = json_decode($clientData);
-
- if($cli->challenge !== $request->challenge) {
- throw new Error('Registration challenge does not match', ERR_UNMATCHED_CHALLENGE );
- }
-
- if(isset($cli->typ) && $cli->typ !== REQUEST_TYPE_REGISTER) {
- throw new Error('ClientData type is invalid', ERR_BAD_TYPE);
- }
-
- if(isset($cli->origin) && $cli->origin !== $request->appId) {
- throw new Error('App ID does not match the origin', ERR_NO_MATCHING_ORIGIN);
- }
-
- $registration = new Registration();
- $offs = 1;
- $pubKey = substr($rawReg, $offs, PUBKEY_LEN);
- $offs += PUBKEY_LEN;
- // decode the pubKey to make sure it's good
- $tmpKey = $this->pubkey_to_pem($pubKey);
- if($tmpKey === null) {
- throw new Error('Decoding of public key failed', ERR_PUBKEY_DECODE );
- }
- $registration->publicKey = base64_encode($pubKey);
- $khLen = $regData[$offs++];
- $kh = substr($rawReg, $offs, $khLen);
- $offs += $khLen;
- $registration->keyHandle = $this->base64u_encode($kh);
-
- // length of certificate is stored in byte 3 and 4 (excluding the first 4 bytes)
- $certLen = 4;
- $certLen += ($regData[$offs + 2] << 8);
- $certLen += $regData[$offs + 3];
-
- $rawCert = $this->fixSignatureUnusedBits(substr($rawReg, $offs, $certLen));
- $offs += $certLen;
- $pemCert = "-----BEGIN CERTIFICATE-----\r\n";
- $pemCert .= chunk_split(base64_encode($rawCert), 64);
- $pemCert .= "-----END CERTIFICATE-----";
- if($includeCert) {
- $registration->certificate = base64_encode($rawCert);
- }
- if($this->attestDir) {
- if(openssl_x509_checkpurpose($pemCert, -1, $this->get_certs()) !== true) {
- throw new Error('Attestation certificate can not be validated', ERR_ATTESTATION_VERIFICATION );
- }
- }
-
- if(!openssl_pkey_get_public($pemCert)) {
- throw new Error('Decoding of public key failed', ERR_PUBKEY_DECODE );
- }
- $signature = substr($rawReg, $offs);
-
- $dataToVerify = pack('C', 0);
- $dataToVerify .= hash('sha256', $request->appId, true);
- $dataToVerify .= hash('sha256', $clientData, true);
- $dataToVerify .= $kh;
- $dataToVerify .= $pubKey;
-
- if(openssl_verify($dataToVerify, $signature, $pemCert, 'sha256') === 1) {
- return $registration;
- } else {
- throw new Error('Attestation signature does not match', ERR_ATTESTATION_SIGNATURE );
- }
- }
-
- /**
- * Called to get an authentication request.
- *
- * @param array $registrations An array of the registrations to create authentication requests for.
- * @return array An array of SignRequest
- * @throws Error
- */
- public function getAuthenticateData(array $registrations)
- {
- $sigs = array();
- $challenge = $this->createChallenge();
- foreach ($registrations as $reg) {
- if( !is_object( $reg ) ) {
- throw new \InvalidArgumentException('$registrations of getAuthenticateData() method only accepts array of object.');
- }
- /** @var Registration $reg */
-
- $sig = new SignRequest();
- $sig->appId = $this->appId;
- $sig->keyHandle = $reg->keyHandle;
- $sig->challenge = $challenge;
- $sigs[] = $sig;
- }
- return $sigs;
- }
-
- /**
- * Called to verify an authentication response
- *
- * @param array $requests An array of outstanding authentication requests
- * @param array $registrations An array of current registrations
- * @param object $response A response from the authenticator
- * @return Registration
- * @throws Error
- *
- * The Registration object returned on success contains an updated counter
- * that should be saved for future authentications.
- * If the Error returned is ERR_COUNTER_TOO_LOW this is an indication of
- * token cloning or similar and appropriate action should be taken.
- */
- public function doAuthenticate(array $requests, array $registrations, $response)
- {
- if( !is_object( $response ) ) {
- throw new \InvalidArgumentException('$response of doAuthenticate() method only accepts object.');
- }
-
- if( property_exists( $response, 'errorCode') && $response->errorCode !== 0 ) {
- throw new Error('User-agent returned error. Error code: ' . $response->errorCode, ERR_BAD_UA_RETURNING );
- }
-
- /** @var object|null $req */
- $req = null;
-
- /** @var object|null $reg */
- $reg = null;
-
- $clientData = $this->base64u_decode($response->clientData);
- $decodedClient = json_decode($clientData);
-
- if(isset($decodedClient->typ) && $decodedClient->typ !== REQUEST_TYPE_AUTHENTICATE) {
- throw new Error('ClientData type is invalid', ERR_BAD_TYPE);
- }
-
- foreach ($requests as $req) {
- if( !is_object( $req ) ) {
- throw new \InvalidArgumentException('$requests of doAuthenticate() method only accepts array of object.');
- }
-
- if($req->keyHandle === $response->keyHandle && $req->challenge === $decodedClient->challenge) {
- break;
- }
-
- $req = null;
- }
- if($req === null) {
- throw new Error('No matching request found', ERR_NO_MATCHING_REQUEST );
- }
- if(isset($decodedClient->origin) && $decodedClient->origin !== $req->appId) {
- throw new Error('App ID does not match the origin', ERR_NO_MATCHING_ORIGIN);
- }
- foreach ($registrations as $reg) {
- if( !is_object( $reg ) ) {
- throw new \InvalidArgumentException('$registrations of doAuthenticate() method only accepts array of object.');
- }
-
- if($reg->keyHandle === $response->keyHandle) {
- break;
- }
- $reg = null;
- }
- if($reg === null) {
- throw new Error('No matching registration found', ERR_NO_MATCHING_REGISTRATION );
- }
- $pemKey = $this->pubkey_to_pem($this->base64u_decode($reg->publicKey));
- if($pemKey === null) {
- throw new Error('Decoding of public key failed', ERR_PUBKEY_DECODE );
- }
-
- $signData = $this->base64u_decode($response->signatureData);
- $dataToVerify = hash('sha256', $req->appId, true);
- $dataToVerify .= substr($signData, 0, 5);
- $dataToVerify .= hash('sha256', $clientData, true);
- $signature = substr($signData, 5);
-
- if(openssl_verify($dataToVerify, $signature, $pemKey, 'sha256') === 1) {
- $upb = unpack("Cupb", substr($signData, 0, 1));
- if($upb['upb'] !== 1) {
- throw new Error('User presence byte value is invalid', ERR_BAD_USER_PRESENCE );
- }
- $ctr = unpack("Nctr", substr($signData, 1, 4));
- $counter = $ctr['ctr'];
- /* TODO: wrap-around should be handled somehow.. */
- if($counter > $reg->counter) {
- $reg->counter = $counter;
- return self::castObjectToRegistration($reg);
- } else {
- throw new Error('Counter too low.', ERR_COUNTER_TOO_LOW );
- }
- } else {
- throw new Error('Authentication failed', ERR_AUTHENTICATION_FAILURE );
- }
- }
-
- /**
- * @param object $object
- * @return Registration
- */
- protected static function castObjectToRegistration($object)
- {
- $reg = new Registration();
- if (property_exists($object, 'publicKey')) {
- $reg->publicKey = $object->publicKey;
- }
- if (property_exists($object, 'certificate')) {
- $reg->certificate = $object->certificate;
- }
- if (property_exists($object, 'counter')) {
- $reg->counter = $object->counter;
- }
- if (property_exists($object, 'keyHandle')) {
- $reg->keyHandle = $object->keyHandle;
- }
- return $reg;
- }
-
- /**
- * @return array
- */
- private function get_certs()
- {
- $files = array();
- $dir = $this->attestDir;
- if($dir !== null && is_dir($dir) && $handle = opendir($dir)) {
- while(false !== ($entry = readdir($handle))) {
- if(is_file("$dir/$entry")) {
- $files[] = "$dir/$entry";
- }
- }
- closedir($handle);
- } elseif (is_file("$dir")) {
- $files[] = "$dir";
- }
- return $files;
- }
-
- /**
- * @param string $data
- * @return string
- */
- private function base64u_encode($data)
- {
- return trim(strtr(base64_encode($data), '+/', '-_'), '=');
- }
-
- /**
- * @param string $data
- * @return string
- */
- private function base64u_decode($data)
- {
- return base64_decode(strtr($data, '-_', '+/'));
- }
-
- /**
- * @param string $key
- * @return null|string
- */
- private function pubkey_to_pem($key)
- {
- if(strlen($key) !== PUBKEY_LEN || $key[0] !== "\x04") {
- return null;
- }
-
- /*
- * Convert the public key to binary DER format first
- * Using the ECC SubjectPublicKeyInfo OIDs from RFC 5480
- *
- * SEQUENCE(2 elem) 30 59
- * SEQUENCE(2 elem) 30 13
- * OID1.2.840.10045.2.1 (id-ecPublicKey) 06 07 2a 86 48 ce 3d 02 01
- * OID1.2.840.10045.3.1.7 (secp256r1) 06 08 2a 86 48 ce 3d 03 01 07
- * BIT STRING(520 bit) 03 42 ..key..
- */
- $der = "\x30\x59\x30\x13\x06\x07\x2a\x86\x48\xce\x3d\x02\x01";
- $der .= "\x06\x08\x2a\x86\x48\xce\x3d\x03\x01\x07\x03\x42";
- $der .= "\0".$key;
-
- $pem = "-----BEGIN PUBLIC KEY-----\r\n";
- $pem .= chunk_split(base64_encode($der), 64);
- $pem .= "-----END PUBLIC KEY-----";
-
- return $pem;
- }
-
- /**
- * @return string
- * @throws Error
- */
- private function createChallenge()
- {
- $challenge = random_bytes(32);
- $challenge = $this->base64u_encode( $challenge );
-
- return $challenge;
- }
-
- /**
- * Fixes a certificate where the signature contains unused bits.
- *
- * @param string $cert
- * @return mixed
- */
- private function fixSignatureUnusedBits($cert)
- {
- if(in_array(hash('sha256', $cert), $this->FIXCERTS, true)) {
- $cert[strlen($cert) - 257] = "\0";
- }
- return $cert;
- }
-}
-
-/**
- * Class for building a registration request
- *
- * @package u2flib_server
- */
-class RegisterRequest
-{
- /** @var string Protocol version */
- public $version = U2F_VERSION;
-
- /** @var string Registration challenge */
- public $challenge;
-
- /** @var string Application id */
- public $appId;
-
- /**
- * @param string $challenge
- * @param string $appId
- * @internal
- */
- public function __construct($challenge, $appId)
- {
- $this->challenge = $challenge;
- $this->appId = $appId;
- }
-}
-
-/**
- * Class for building up an authentication request
- *
- * @package u2flib_server
- */
-class SignRequest
-{
- /** @var string Protocol version */
- public $version = U2F_VERSION;
-
- /** @var string Authentication challenge */
- public $challenge = '';
-
- /** @var string Key handle of a registered authenticator */
- public $keyHandle = '';
-
- /** @var string Application id */
- public $appId = '';
-}
-
-/**
- * Class returned for successful registrations
- *
- * @package u2flib_server
- */
-class Registration
-{
- /** @var string The key handle of the registered authenticator */
- public $keyHandle = '';
-
- /** @var string The public key of the registered authenticator */
- public $publicKey = '';
-
- /** @var string The attestation certificate of the registered authenticator */
- public $certificate = '';
-
- /** @var int The counter associated with this registration */
- public $counter = -1;
-}
-
-/**
- * Error class, returned on errors
- *
- * @package u2flib_server
- */
-class Error extends \Exception
-{
- /**
- * Override constructor and make message and code mandatory
- * @param string $message
- * @param int $code
- * @param \Exception|null $previous
- */
- public function __construct($message, $code, \Exception $previous = null) {
- parent::__construct($message, $code, $previous);
- }
-}