Skip to content

Commit

Permalink
changes due to to rebase
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Jan 13, 2018
1 parent dc45ef5 commit 87e71cc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,22 @@ public void cryptFileWithMetadata() throws Exception {
// n9WXAIXO2wRY4R8nXwmo
assertTrue(cryptFile("ia7OEEEyXMoRa1QWQk8r",
"78f42172166f9dc8fd1a7156b1753353",
EncryptionUtils.decodeStringToBase64Bytes(metadata.files.get("ia7OEEEyXMoRa1QWQk8r").encrypted.key),
EncryptionUtils.decodeStringToBase64Bytes(metadata.files.get("ia7OEEEyXMoRa1QWQk8r").initializationVector),
EncryptionUtils.decodeStringToBase64Bytes(metadata.files.get("ia7OEEEyXMoRa1QWQk8r").authenticationTag)));
EncryptionUtils.decodeStringToBase64Bytes(metadata.getFiles().get("ia7OEEEyXMoRa1QWQk8r")
.getEncrypted().getKey()),
EncryptionUtils.decodeStringToBase64Bytes(metadata.getFiles().get("ia7OEEEyXMoRa1QWQk8r")
.getInitializationVector()),
EncryptionUtils.decodeStringToBase64Bytes(metadata.getFiles().get("ia7OEEEyXMoRa1QWQk8r")
.getAuthenticationTag())));

// n9WXAIXO2wRY4R8nXwmo
assertTrue(cryptFile("n9WXAIXO2wRY4R8nXwmo",
"825143ed1f21ebb0c3b3c3f005b2f5db",
EncryptionUtils.decodeStringToBase64Bytes(metadata.files.get("n9WXAIXO2wRY4R8nXwmo").encrypted.key),
EncryptionUtils.decodeStringToBase64Bytes(metadata.files.get("n9WXAIXO2wRY4R8nXwmo").initializationVector),
EncryptionUtils.decodeStringToBase64Bytes(metadata.files.get("n9WXAIXO2wRY4R8nXwmo").authenticationTag)));
EncryptionUtils.decodeStringToBase64Bytes(metadata.getFiles().get("n9WXAIXO2wRY4R8nXwmo")
.getEncrypted().getKey()),
EncryptionUtils.decodeStringToBase64Bytes(metadata.getFiles().get("n9WXAIXO2wRY4R8nXwmo")
.getInitializationVector()),
EncryptionUtils.decodeStringToBase64Bytes(metadata.getFiles().get("n9WXAIXO2wRY4R8nXwmo")
.getAuthenticationTag())));
}

/**
Expand Down Expand Up @@ -277,45 +283,45 @@ private DecryptedFolderMetadata generateFolderMetadata() throws Exception {
metadataKeys.put(1, EncryptionUtils.encryptStringAsymmetric(metadataKey1, cert));
metadataKeys.put(2, EncryptionUtils.encryptStringAsymmetric(metadataKey2, cert));
DecryptedFolderMetadata.Encrypted encrypted = new DecryptedFolderMetadata.Encrypted();
encrypted.metadataKeys = metadataKeys;
encrypted.setMetadataKeys(metadataKeys);

DecryptedFolderMetadata.Metadata metadata1 = new DecryptedFolderMetadata.Metadata();
metadata1.metadataKeys = metadataKeys;
metadata1.version = 1;
metadata1.setMetadataKeys(metadataKeys);
metadata1.setVersion(1);

DecryptedFolderMetadata.Sharing sharing = new DecryptedFolderMetadata.Sharing();
sharing.signature = "HMACOFRECIPIENTANDNEWESTMETADATAKEY";
sharing.setSignature("HMACOFRECIPIENTANDNEWESTMETADATAKEY");
HashMap<String, String> recipient = new HashMap<>();
recipient.put("[email protected]", "PUBLIC KEY");
recipient.put("[email protected]", "PUBLIC KEY");
sharing.recipient = recipient;
metadata1.sharing = sharing;
sharing.setRecipient(recipient);
metadata1.setSharing(sharing);

HashMap<String, DecryptedFolderMetadata.DecryptedFile> files = new HashMap<>();

DecryptedFolderMetadata.Data data1 = new DecryptedFolderMetadata.Data();
data1.key = "WANM0gRv+DhaexIsI0T3Lg==";
data1.filename = "test.txt";
data1.version = 1;
data1.setKey("WANM0gRv+DhaexIsI0T3Lg==");
data1.setFilename("test.txt");
data1.setVersion(1);

DecryptedFolderMetadata.DecryptedFile file1 = new DecryptedFolderMetadata.DecryptedFile();
file1.initializationVector = "gKm3n+mJzeY26q4OfuZEqg==";
file1.encrypted = data1;
file1.metadataKey = 0;
file1.authenticationTag = "PboI9tqHHX3QeAA22PIu4w==";
file1.setInitializationVector("gKm3n+mJzeY26q4OfuZEqg==");
file1.setEncrypted(data1);
file1.setMetadataKey(0);
file1.setAuthenticationTag("PboI9tqHHX3QeAA22PIu4w==");

files.put("ia7OEEEyXMoRa1QWQk8r", file1);

DecryptedFolderMetadata.Data data2 = new DecryptedFolderMetadata.Data();
data2.key = "9dfzbIYDt28zTyZfbcll+g==";
data2.filename = "test2.txt";
data2.version = 1;
data2.setKey("9dfzbIYDt28zTyZfbcll+g==");
data2.setFilename("test2.txt");
data2.setVersion(1);

DecryptedFolderMetadata.DecryptedFile file2 = new DecryptedFolderMetadata.DecryptedFile();
file2.initializationVector = "hnJLF8uhDvDoFK4ajuvwrg==";
file2.encrypted = data2;
file2.metadataKey = 0;
file2.authenticationTag = "qOQZdu5soFO77Y7y4rAOVA==";
file2.setInitializationVector("hnJLF8uhDvDoFK4ajuvwrg==");
file2.setEncrypted(data2);
file2.setMetadataKey(0);
file2.setAuthenticationTag("qOQZdu5soFO77Y7y4rAOVA==");

files.put("n9WXAIXO2wRY4R8nXwmo", file2);

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP;


/**
* Main Application of the project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,7 @@ private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile pare
}
}

boolean metadataExists = false;
String token = null;

ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());

String privateKey = arbitraryDataProvider.getValue(getAccount().name, EncryptionUtils.PRIVATE_KEY);
String publicKey = arbitraryDataProvider.getValue(getAccount().name, EncryptionUtils.PUBLIC_KEY);

/// perform the upload
/// perform the upload
if (mChunked && (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE)) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mContext, encryptedTempFile.getAbsolutePath(),
mFile.getParentRemotePath() + encryptedFileName, mFile.getMimetype(),
Expand All @@ -585,7 +577,7 @@ private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile pare
}

// FileChannel channel = null;
//try {
// try {
// channel = new RandomAccessFile(ocFile.getStoragePath(), "rw").getChannel();
// fileLock = channel.tryLock();
// } catch (FileNotFoundException e) {
Expand Down Expand Up @@ -747,8 +739,13 @@ private RemoteOperationResult unlockFolder(OCFile parentFolder, OwnCloudClient c
}

private RemoteOperationResult checkConditions(File originalFile) {
// Check that connectivity conditions are met and delays the upload otherwise

// check that internet is not behind walled garden
if (Device.getNetworkType(mContext).equals(JobRequest.NetworkType.ANY) ||
ConnectivityUtils.isInternetWalled(mContext)) {
return new RemoteOperationResult(ResultCode.NO_NETWORK_CONNECTION);
}

// check that connectivity conditions are met and delays the upload otherwise
if (mOnWifiOnly && !Device.getNetworkType(mContext).equals(JobRequest.NetworkType.UNMETERED)) {
Log_OC.d(TAG, "Upload delayed until WiFi is available: " + getRemotePath());
return new RemoteOperationResult(ResultCode.DELAYED_FOR_WIFI);
Expand Down Expand Up @@ -1146,8 +1143,8 @@ private boolean existsFile(OwnCloudClient client, String remotePath, DecryptedFo

return false;
} else {
ExistenceCheckRemoteOperation existsOperation =
new ExistenceCheckRemoteOperation(remotePath, mContext, false);
ExistenceCheckRemoteOperation existsOperation = new ExistenceCheckRemoteOperation(remotePath, mContext,
false);
RemoteOperationResult result = existsOperation.execute(client);
return result.isSuccess();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
import com.owncloud.android.utils.AnalyticsUtils;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.ThemeUtils;
Expand Down Expand Up @@ -1037,14 +1036,6 @@ public boolean onFileActionChosen(int menuId, ArrayList<OCFile> checkedFiles) {
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, false);
return true;
}
case R.id. action_encrypted: {
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, true);
return true;
}
case R.id. action_unset_encrypted: {
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, false);
return true;
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,6 @@
<string name="screenshot_04_accounts">Mit verschiedenen Kontos verbinden</string>
<string name="screenshot_05_autoUpload">Automatisches Hochladen von Bildern &amp; Videos</string>
<string name="screenshot_06_davdroid">Kalender &amp; Kontakte mit DAVdroid synchronisieren</string>
<string name="dev_version_no_information_available">Keine Information verfügbar!</string>
<string name="dev_version_no_new_version_available">Keine neue Version verfügbar!</string>

<string name="end_to_end_encryption_folder_not_empty">Verzeichnis nicht leer!</string>
<string name="end_to_end_encryption_wrong_password">Fehler beim entschlüsseln. Falsches Passwort??</string>
Expand Down

0 comments on commit 87e71cc

Please sign in to comment.