Skip to content

Commit

Permalink
Add unit test against very large messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Feb 5, 2018
1 parent c30efaf commit 8964da4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/unit/SymmetricTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@ public function testEncrypt()
$this->assertSame($plain->getString(), 'test message');
}

/**
* @throws CryptoException\CannotPerformOperation
* @throws CryptoException\InvalidDigestLength
* @throws CryptoException\InvalidKey
* @throws CryptoException\InvalidMessage
* @throws CryptoException\InvalidSignature
* @throws CryptoException\InvalidType
* @throws TypeError
*/
public function testEncryptLarge()
{
$msg = str_repeat("\xff", 1 << 17);
$key = new EncryptionKey(new HiddenString(str_repeat('A', 32)));
$message = Symmetric::encrypt(
new HiddenString($msg),
$key
);
$this->assertSame(
strpos($message, Halite::VERSION_PREFIX),
0
);

$plain = Symmetric::decrypt($message, $key);
$this->assertSame($plain->getString(), $msg);
}

/**
* @throws CryptoException\CannotPerformOperation
* @throws CryptoException\InvalidDigestLength
Expand Down

0 comments on commit 8964da4

Please sign in to comment.