fix: get collection key correctly
This commit is contained in:
parent
336a6c53fc
commit
dca63ca487
1 changed files with 10 additions and 13 deletions
|
@ -31,21 +31,21 @@ class MultiPartUploader {
|
|||
String fileHash,
|
||||
int collectionID,
|
||||
) async {
|
||||
final collection =
|
||||
CollectionsService.instance.getCollectionByID(collectionID);
|
||||
if (collection == null) {
|
||||
throw Exception("Collection not found");
|
||||
}
|
||||
final collectionKey =
|
||||
CollectionsService.instance.getCollectionKey(collectionID);
|
||||
final result =
|
||||
await _db.getFileEncryptionData(localId, fileHash, collectionID);
|
||||
final encryptedFileKey = CryptoUtil.base642bin(result.encryptedFileKey);
|
||||
final fileNonce = CryptoUtil.base642bin(result.fileNonce);
|
||||
|
||||
final key = CryptoUtil.base642bin(collection.encryptedKey);
|
||||
final encryptKeyNonce = CryptoUtil.base642bin(result.keyNonce);
|
||||
|
||||
return EncryptionResult(
|
||||
key: CryptoUtil.decryptSync(encryptedFileKey, key, encryptKeyNonce),
|
||||
key: CryptoUtil.decryptSync(
|
||||
encryptedFileKey,
|
||||
collectionKey,
|
||||
encryptKeyNonce,
|
||||
),
|
||||
nonce: fileNonce,
|
||||
);
|
||||
}
|
||||
|
@ -96,15 +96,12 @@ class MultiPartUploader {
|
|||
Uint8List fileKey,
|
||||
Uint8List fileNonce,
|
||||
) async {
|
||||
final collection =
|
||||
CollectionsService.instance.getCollectionByID(collectionID);
|
||||
if (collection == null) {
|
||||
throw Exception("Collection not found");
|
||||
}
|
||||
final collectionKey =
|
||||
CollectionsService.instance.getCollectionKey(collectionID);
|
||||
|
||||
final encryptedResult = CryptoUtil.encryptSync(
|
||||
fileKey,
|
||||
CryptoUtil.base642bin(collection.encryptedKey),
|
||||
collectionKey,
|
||||
);
|
||||
|
||||
await _db.createTrackUploadsEntry(
|
||||
|
|
Loading…
Add table
Reference in a new issue