summaryrefslogtreecommitdiffstats
path: root/lib/private/Security/Crypto.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-01-16 20:28:22 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-01-16 22:01:19 +0100
commit0e0db3765887930682aadc6bc8ec7df5ffd187f6 (patch)
treef11f9ebd73638273d281cb6d635ba6069edefd9f /lib/private/Security/Crypto.php
parent2b70c708abc667c3e3c4fd9a97626012bf1ded25 (diff)
downloadnextcloud-server-0e0db3765887930682aadc6bc8ec7df5ffd187f6.tar.gz
nextcloud-server-0e0db3765887930682aadc6bc8ec7df5ffd187f6.zip
Make OCP\Security stricter
* Add typehints * Add return types * Opcode opts from phpstorm * Made strict * Fixed tests: No need to test bogus values anymore strict typing fixes this Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Security/Crypto.php')
-rw-r--r--lib/private/Security/Crypto.php7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/private/Security/Crypto.php b/lib/private/Security/Crypto.php
index d2be1484279..04d618bf373 100644
--- a/lib/private/Security/Crypto.php
+++ b/lib/private/Security/Crypto.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -67,7 +68,7 @@ class Crypto implements ICrypto {
* @param string $password Password to use (defaults to `secret` in config.php)
* @return string Calculated HMAC
*/
- public function calculateHMAC($message, $password = '') {
+ public function calculateHMAC(string $message, string $password = ''): string {
if($password === '') {
$password = $this->config->getSystemValue('secret');
}
@@ -86,7 +87,7 @@ class Crypto implements ICrypto {
* @param string $password Password to encrypt, if not specified the secret from config.php will be taken
* @return string Authenticated ciphertext
*/
- public function encrypt($plaintext, $password = '') {
+ public function encrypt(string $plaintext, string $password = ''): string {
if($password === '') {
$password = $this->config->getSystemValue('secret');
}
@@ -115,7 +116,7 @@ class Crypto implements ICrypto {
$this->cipher->setPassword($password);
$parts = explode('|', $authenticatedCiphertext);
- if(count($parts) !== 3) {
+ if(\count($parts) !== 3) {
throw new \Exception('Authenticated ciphertext could not be decoded.');
}