public function testWeakCrypto() { $this->assertNotSame('', $this->otp_auth->generateSecret()); self::$weak_crypto = true; $this->assertSame('', $this->otp_auth->generateSecret()); self::$weak_crypto = false; $this->assertNotSame('', $this->otp_auth->generateSecret()); }
public function testGenerateSecret() { $time = microtime(true); $secret = ''; while (microtime(true) - $time < 1) { $new_secret = $this->otp_auth->generateSecret(10); $this->assertNotSame($secret, $new_secret); $this->assertEquals(16, strlen($new_secret)); $secret = $new_secret; } }
/** * Start with the registration of a new security key. * This page should return a name of a template, and * it should assign the required variables for this template. * * @return string */ public function register_start() { $secret = $this->otp->generateSecret(); $QR = $this->otp_helper->generateKeyURI('totp', $secret, generate_board_url(), '', 0, 'sha1'); $this->template->assign_vars(array('TFA_QR_CODE' => 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=' . $QR, 'TFA_SECRET' => $secret, 'L_TFA_ADD_OTP_KEY_EXPLAIN' => $this->user->lang('TFA_ADD_OTP_KEY_EXPLAIN', $secret), 'S_HIDDEN_FIELDS_MODULE' => build_hidden_fields(array('secret' => $secret)))); return 'tfa_otp_ucp_new'; }