Skip to content

Commit

Permalink
Normalize whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Nov 21, 2024
1 parent 72fd57a commit ec8b21c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions module/VuFind/src/VuFind/Crypt/BlockCipher.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ class BlockCipher
* @var array
*/
protected $encryptionAlgos = [
'aes' => 'aes-256',
'aes' => 'aes-256',
'blowfish' => 'bf',
'des' => 'des',
'des' => 'des',
'camellia' => 'camellia-256',
'cast5' => 'cast5',
'seed' => 'seed',
'cast5' => 'cast5',
'seed' => 'seed',
];

/**
Expand All @@ -94,12 +94,12 @@ class BlockCipher
* @var array
*/
protected $blockSizes = [
'aes' => 16,
'aes' => 16,
'blowfish' => 8,
'des' => 8,
'des' => 8,
'camellia' => 16,
'cast5' => 8,
'seed' => 16,
'cast5' => 8,
'seed' => 16,
];

/**
Expand All @@ -108,12 +108,12 @@ class BlockCipher
* @var array
*/
protected $keySizes = [
'aes' => 32,
'aes' => 32,
'blowfish' => 56,
'des' => 8,
'des' => 8,
'camellia' => 32,
'cast5' => 16,
'seed' => 16,
'cast5' => 16,
'seed' => 16,
];

/**
Expand Down Expand Up @@ -189,9 +189,9 @@ protected function pkcs7Pad(string $string, int $blockSize = 32): string
*/
protected function pkcs7Strip(string $string): string
{
$end = mb_substr($string, -1, null, '8bit');
$end = mb_substr($string, -1, null, '8bit');
$last = ord($end);
$len = mb_strlen($string, '8bit') - $last;
$len = mb_strlen($string, '8bit') - $last;
if (mb_substr($string, $len, null, '8bit') === str_repeat($end, $last)) {
return mb_substr($string, 0, $len, '8bit');
}
Expand Down Expand Up @@ -281,7 +281,7 @@ protected function openSslEncrypt(string $data): string

// padding
$data = $this->pkcs7Pad($data, $this->getBlockSize());
$iv = $this->getSalt();
$iv = $this->getSalt();

$result = openssl_encrypt(
$data,
Expand Down Expand Up @@ -532,8 +532,8 @@ public function decrypt(string $data): string|bool

$keySize = $this->getKeySize();

$hmacSize = $this->getHashSize($this->hash);
$hmac = mb_substr($data, 0, $hmacSize, '8bit');
$hmacSize = $this->getHashSize($this->hash);
$hmac = mb_substr($data, 0, $hmacSize, '8bit');
$ciphertext = base64_decode(mb_substr($data, $hmacSize, null, '8bit') ?: '');
$iv = mb_substr($ciphertext, 0, $this->getSaltSize(), '8bit');
$hmacNew = $this->getValidationHmac($ciphertext, $iv, $keySize);
Expand Down

0 comments on commit ec8b21c

Please sign in to comment.