Skip to content

Commit

Permalink
Set functions as private to be able to refactor later
Browse files Browse the repository at this point in the history
Also a few comment fixes

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Feb 21, 2023
1 parent 7148257 commit f2912ce
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/encryption/lib/Crypto/Crypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
* @author Björn Schießle <bjoern@schiessle.org>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author Côme Chilliet <come.chilliet@nextcloud.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Kevin Niehage <kevin@niehage.name>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Stefan Weiberg <sweiberg@suse.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Kevin Niehage <kevin@niehage.name>
*
* @license AGPL-3.0
*
Expand Down Expand Up @@ -761,8 +762,9 @@ public function useLegacyBase64Encoding(): bool {
/**
* Uses phpseclib RC4 implementation
*/
protected function rc4Decrypt(string $data, string $secret): string {
private function rc4Decrypt(string $data, string $secret): string {
$rc4 = new RC4();
/** @psalm-suppress InternalMethod */
$rc4->setKey($secret);

return $rc4->decrypt($data);
Expand All @@ -771,21 +773,21 @@ protected function rc4Decrypt(string $data, string $secret): string {
/**
* Uses phpseclib RC4 implementation
*/
protected function rc4Encrypt(string $data, string $secret): string {
private function rc4Encrypt(string $data, string $secret): string {
$rc4 = new RC4();
/** @psalm-suppress InternalMethod */
$rc4->setKey($secret);

return $rc4->encrypt($data);
}

/**
* wraps openssl_open() for cases where RC4 is not supported by OpenSSL v3
* and replaces it with a custom implementation where necessary
* Custom implementation of openssl_open()
*
* @param \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key
* @throws DecryptionFailedException
*/
public function opensslOpen(string $data, string &$output, string $encrypted_key, $private_key, string $cipher_algo): bool {
private function opensslOpen(string $data, string &$output, string $encrypted_key, $private_key, string $cipher_algo): bool {
$result = false;

// check if RC4 is used
Expand All @@ -809,7 +811,7 @@ public function opensslOpen(string $data, string &$output, string $encrypted_key
*
* @throws EncryptionFailedException
*/
public function opensslSeal(string $data, string &$sealed_data, array &$encrypted_keys, array $public_key, string $cipher_algo): int|false {
private function opensslSeal(string $data, string &$sealed_data, array &$encrypted_keys, array $public_key, string $cipher_algo): int|false {
$result = false;

// check if RC4 is used
Expand Down

0 comments on commit f2912ce

Please sign in to comment.