Esempio n. 1
0
 /**
  * @expectedException paul999\u2f\Exceptions\U2fError
  * @expectedExceptionCode paul999\u2f\Exceptions\U2fError::ERR_BAD_UA_RETURNING
  */
 public function testDoAuthenticateUAError()
 {
     $reqs = array(new SignRequest(null, null, null));
     $regs = array(new Registration(null, null, null));
     $resp = new AuthenticationResponse(null, null, null, 5);
     $this->u2f->doAuthenticate($reqs, $regs, $resp);
 }
Esempio n. 2
0
 /**
  * Actual registration
  * @throws http_exception
  */
 public function register()
 {
     try {
         $register = json_decode($this->user->data['u2f_request']);
         $response = json_decode(htmlspecialchars_decode($this->request->variable('register', '')));
         $error = 0;
         if (property_exists($response, 'errorCode')) {
             $error = $response->errorCode;
         }
         $registerrequest = new RegisterRequest($register->challenge, $register->appId);
         $responserequest = new RegisterResponse($response->registrationData, $response->clientData, $error);
         $reg = $this->u2f->doRegister($registerrequest, $responserequest);
         $sql_ary = array('user_id' => $this->user->data['user_id'], 'key_handle' => $reg->getKeyHandle(), 'public_key' => $reg->getPublicKey(), 'certificate' => $reg->getCertificate(), 'counter' => $reg->getCounter() > 0 ? $reg->getCounter() : 0, 'registered' => time(), 'last_used' => time());
         $sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
         $this->db->sql_query($sql);
         $sql_ary = array('u2f_request' => '');
         $this->update_session($sql_ary);
     } catch (U2fError $err) {
         $this->createError($err);
     }
 }