This commit is contained in:
@ -16,10 +16,24 @@ final class EncryptedPayloadTest extends TestCase
|
||||
$json = '{"clientCode":"X","answers":[]}';
|
||||
$env = qdb_sensitive_envelope($json, $token);
|
||||
$this->assertTrue($env['encrypted']);
|
||||
$this->assertSame('A256GCM', $env['alg']);
|
||||
$plain = qdb_decrypt_sensitive_envelope($env, $token);
|
||||
$this->assertSame($json, $plain);
|
||||
}
|
||||
|
||||
public function testLegacyCbcEnvelopeStillDecrypts(): void
|
||||
{
|
||||
require_once dirname(__DIR__, 2) . '/lib/encrypted_payload.php';
|
||||
$token = bin2hex(random_bytes(32));
|
||||
$json = '{"legacy":true}';
|
||||
$key = hkdf_session_key_from_token($token);
|
||||
$env = [
|
||||
'encrypted' => true,
|
||||
'payload' => base64_encode(aes256_cbc_encrypt_bytes($json, $key)),
|
||||
];
|
||||
$this->assertSame($json, qdb_decrypt_sensitive_envelope($env, $token));
|
||||
}
|
||||
|
||||
public function testWrongTokenFailsDecrypt(): void
|
||||
{
|
||||
require_once dirname(__DIR__, 2) . '/lib/encrypted_payload.php';
|
||||
|
||||
Reference in New Issue
Block a user