Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
37e82684
Commit
37e82684
authored
10 years ago
by
Björn Schießle
Committed by
Thomas Müller
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
make sharing and unsharing work
parent
8dde9325
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/encryption/lib/crypto/encryption.php
+14
-7
14 additions, 7 deletions
apps/encryption/lib/crypto/encryption.php
apps/encryption/lib/keymanager.php
+17
-0
17 additions, 0 deletions
apps/encryption/lib/keymanager.php
with
31 additions
and
7 deletions
apps/encryption/lib/crypto/encryption.php
+
14
−
7
View file @
37e82684
...
@@ -122,11 +122,7 @@ class Encryption implements IEncryptionModule {
...
@@ -122,11 +122,7 @@ class Encryption implements IEncryptionModule {
}
}
$encryptedKeyfiles
=
$this
->
crypt
->
multiKeyEncrypt
(
$this
->
fileKey
,
$publicKeys
);
$encryptedKeyfiles
=
$this
->
crypt
->
multiKeyEncrypt
(
$this
->
fileKey
,
$publicKeys
);
$this
->
keymanager
->
setAllFileKeys
(
$path
,
$encryptedKeyfiles
);
$this
->
keymanager
->
setFileKey
(
$path
,
$encryptedKeyfiles
[
'data'
]);
foreach
(
$encryptedKeyfiles
[
'keys'
]
as
$uid
=>
$keyFile
)
{
$this
->
keymanager
->
setShareKey
(
$path
,
$uid
,
$keyFile
);
}
}
}
return
$result
;
return
$result
;
}
}
...
@@ -218,11 +214,22 @@ class Encryption implements IEncryptionModule {
...
@@ -218,11 +214,22 @@ class Encryption implements IEncryptionModule {
* update encrypted file, e.g. give additional users access to the file
* update encrypted file, e.g. give additional users access to the file
*
*
* @param string $path path to the file which should be updated
* @param string $path path to the file which should be updated
* @param string $uid of the user who performs the operation
* @param array $accessList who has access to the file contains the key 'users' and 'public'
* @param array $accessList who has access to the file contains the key 'users' and 'public'
* @return boolean
* @return boolean
*/
*/
public
function
update
(
$path
,
$accessList
)
{
public
function
update
(
$path
,
$uid
,
$accessList
)
{
// TODO: Implement update() method.
$fileKey
=
$this
->
keymanager
->
getFileKey
(
$path
,
$uid
);
foreach
(
$accessList
[
'users'
]
as
$user
)
{
$publicKeys
[
$user
]
=
$this
->
keymanager
->
getPublicKey
(
$user
);
}
$encryptedFileKey
=
$this
->
crypt
->
multiKeyEncrypt
(
$fileKey
,
$publicKeys
);
$this
->
keymanager
->
deleteAllFileKeys
(
$path
);
$this
->
keymanager
->
setAllFileKeys
(
$path
,
$encryptedFileKey
);
return
true
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
apps/encryption/lib/keymanager.php
+
17
−
0
View file @
37e82684
...
@@ -183,6 +183,19 @@ class KeyManager {
...
@@ -183,6 +183,19 @@ class KeyManager {
return
$this
->
keyStorage
->
setFileKey
(
$path
,
$this
->
fileKeyId
,
$key
);
return
$this
->
keyStorage
->
setFileKey
(
$path
,
$this
->
fileKeyId
,
$key
);
}
}
/**
* set all file keys (the file key and the corresponding share keys)
*
* @param string $path
* @param array $keys
*/
public
function
setAllFileKeys
(
$path
,
$keys
)
{
$this
->
setFileKey
(
$path
,
$keys
[
'data'
]);
foreach
(
$keys
[
'keys'
]
as
$uid
=>
$keyFile
)
{
$this
->
setShareKey
(
$path
,
$uid
,
$keyFile
);
}
}
/**
/**
* write share key to the key storage
* write share key to the key storage
*
*
...
@@ -405,6 +418,10 @@ class KeyManager {
...
@@ -405,6 +418,10 @@ class KeyManager {
return
$this
->
keyStorage
->
deleteUserKey
(
$uid
,
$this
->
privateKeyId
);
return
$this
->
keyStorage
->
deleteUserKey
(
$uid
,
$this
->
privateKeyId
);
}
}
public
function
deleteAllFileKeys
(
$path
)
{
return
$this
->
keyStorage
->
deleteAllFileKeys
(
$path
);
}
/**
/**
* @param array $userIds
* @param array $userIds
* @return array
* @return array
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment