forked from D3Public/oxtotp
fix seed encrypting
This commit is contained in:
parent
51ff19bf42
commit
f4bf78cb1e
@ -251,7 +251,7 @@ class d3totp extends BaseModel
|
|||||||
$iv = openssl_random_pseudo_bytes($ivlen);
|
$iv = openssl_random_pseudo_bytes($ivlen);
|
||||||
$ciphertext_raw = openssl_encrypt($plaintext, $cipher, $key, $options=OPENSSL_RAW_DATA, $iv);
|
$ciphertext_raw = openssl_encrypt($plaintext, $cipher, $key, $options=OPENSSL_RAW_DATA, $iv);
|
||||||
$hmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary=true);
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -732,8 +732,11 @@ class d3totpTest extends d3TotpUnitTestCase
|
|||||||
{
|
{
|
||||||
$sReturn = $this->callMethod($this->_oModel, 'encrypt', ['foobar']);
|
$sReturn = $this->callMethod($this->_oModel, 'encrypt', ['foobar']);
|
||||||
|
|
||||||
|
// indirect tests, because string changes on every call
|
||||||
$this->assertInternalType('string', $sReturn);
|
$this->assertInternalType('string', $sReturn);
|
||||||
$this->assertNotSame('foobar', $sReturn);
|
$this->assertNotSame('foobar', $sReturn);
|
||||||
|
$this->assertStringEndsWith('==', $sReturn);
|
||||||
|
$this->assertTrue(strlen($sReturn) === 88);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user