Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Sep 18, 2024

Summary

TODO

  • ...

Checklist

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/deps/php-seclin branch from d9d7046 to 25d13a4 Compare November 5, 2024 15:29
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/deps/php-seclin branch from c66f090 to 9ca9c89 Compare November 5, 2024 22:46
@susnux
Copy link
Contributor Author

susnux commented Nov 5, 2024

Problem with this:
Checker::createSignatureData does create a different signature... No idea what is happening the parameters are the same.

@joshtrichards
Copy link
Member

Perhaps phpseclib2_compat as an intermediate step for v31+ (or at least v32+)?

https://phpseclib.com/docs/why#phpseclib2_compat

Signed-off-by: Josh <josh.t.richards@gmail.com>
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
$auth = new RSA\PrivateKey();
$auth->withPassword($this->config->getSystemValue('secret', ''));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$auth->withPassword($this->config->getSystemValue('secret', ''));
$auth = $auth->withPassword($this->config->getSystemValue('secret', ''));

v3 is immutable

// Add fallback routine for a time where secret was not enforced to be exists
$auth->setPassword('');
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
$auth->withPassword('');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$auth->withPassword('');
$auth = $auth->withPassword('');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L220 for v3

private static function getCipher() {
	$cipher = new AES('cbc');

Updated RSA key loading to use PSS padding and options.

Signed-off-by: Josh <josh.t.richards@gmail.com>
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
try {
$auth = RSACrypt::loadPrivateKey(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to support EC / DSA keys as well. One can do that thusly:

$auth = \phpseclib3\Crypt\PublicKeyLoader::load(
    $storage->getBackendOption('private_key'),
    $this->config->getSystemValue('secret', '');
);
if (!$auth instanceof \phpseclib3\Crypt\Common\PrivateKey) {
    throw new \Exception('A private key needs to be loaded - not a ' . $auth::class . ' key');
}

I suppose it might also be worthwhile to realize that if no key can be detected (eg. you try to load a PHP file as a key) then a \phpseclib3\Exception\NoKeyLoadedException will be thrown.

That said, if more than just RSA keys are going to be supported then renaming the class would prob be appropriate as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants