fix seed encrypting

This commit is contained in:
Daniel Seifert 2019-08-13 23:09:51 +02:00
parent 51ff19bf42
commit f4bf78cb1e
2 changed files with 4 additions and 1 deletions

View File

@ -251,7 +251,7 @@ class d3totp extends BaseModel
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($plaintext, $cipher, $key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary=true);
return $this->d3Base64_decode($iv.$hmac.$ciphertext_raw);
return base64_encode($iv.$hmac.$ciphertext_raw);
}
/**

View File

@ -732,8 +732,11 @@ class d3totpTest extends d3TotpUnitTestCase
{
$sReturn = $this->callMethod($this->_oModel, 'encrypt', ['foobar']);
// indirect tests, because string changes on every call
$this->assertInternalType('string', $sReturn);
$this->assertNotSame('foobar', $sReturn);
$this->assertStringEndsWith('==', $sReturn);
$this->assertTrue(strlen($sReturn) === 88);
}
/**