diff --git a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionTestUtils.kt b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionTestUtils.kt index 33a245066d82..8857caae5f58 100644 --- a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionTestUtils.kt +++ b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionTestUtils.kt @@ -30,7 +30,23 @@ import com.owncloud.android.lib.resources.status.E2EVersion class EncryptionTestUtils { val t1PrivateKey = - "MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQC1p8eYMFwGoi7geYzEwNbePRLL5LRhorAecFG3zkpLBwSi/QHkU4u4uSegEbHgOfe73eKVOFdfFpw8wd5cvtY+4CzbX8bu+yrC+tFGcJ25/4VQ78Bl4MI0SvOmxDwuZNrg9SWgs9RwialKOsfCEyz0SS8RstGNt5KZKn1e8z7V9X/eORPmOQ5KcIXHlMbAY3m4erBSKvhRZdqy+Dbnc0rZeZaKkoIMJH1OYfVto/ek12iIKF2YStPVzoTgNsFelPDxeA/lltgf6qDVRD+ELydEncPIJwcv52D8ZitoEyEOfjDZW+rvvE02g1ZD1xPkDLpwltAsFCglCKvKBAWuhthFAgMBAAECgf8BN1MLcq+6m8C1tzNvN/UDd9c0rUpexM6D5eC4O+6B7YGidEqIhHVIzUj0e2HUgpRBbURxsvF1FWdIT2gu7dnULtOGWQxNujJ0kGwXfAnqxh/rACDFb5TS3sJawEExC5yJw14bCEbE/0uBF5uiTU/U9AV7PKHlqAKsS2RtcwPNceB8zDu0hh/Mb/uS7274TsxUllx0WzGZrozO1K6AlOete9rXmmpghpFTNVhxgf0pxe3hrK+tZGSL9di+Wft9eCvSbdG/FzeXgwVqmGtWU7kSB7FqstEEJO4VpOSyEfcXGHTHwdZjrhBUuAcjWE8E0mCKa8htRE52czb3C0f7ZYkCgYEA5eH3vmHEgQjXzSSEtbmDLRq9X9SB7pIAIXHj2UuEOTkLUJ/7xLTHqt82jqZaZzns1RZIJXKZjH85C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Yol6cVjXXAIcfzj5tpGVxHMk9Q9tR0v6DY+HqhzjEpJ0QRUl+GKnz6f" + + "QVzqPpvYqhCptoFahpPDUIp5XJmiYSUoclVX5F4aikYHJx3kBYMkdYqDUgDxSGkHzBJZAoGAHV44xgTW02dgeB5GfDJVWCJKAU" + + "GsYOFuUehKUBXSJ0929hdP0sjOQDJN3DEDISzmgdWX5NyLJxEYgFWNivpePjWCWzOzyua3nPSpvxPIUB7xh27gjT91glj1hEmy" + + "sCd7+9yoMPiCXR7iigRycxegI/Krd39QzISSk9O0finfytU=" val t1PublicKey = """-----BEGIN CERTIFICATE----- MIIC6DCCAdCgAwIBAgIBADANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDDAJ0MTAe @@ -52,7 +68,23 @@ t9ONcUqCKP7hd8rajtxM4JIIRExwD8OkgARWGg== -----END CERTIFICATE-----""" val johnPrivateKey = - "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDuPcSvlhqElPQsCdJEuGmptGj4TUBWe33yu+ncOYR8Ec3M0H4NL0gEORJJcz9i18ByLpNzDy6NUGOtlf9YSat/zKdAfFiZJolKc/y4BPfTr8xx5ml2mu4Rz39LXRru+nnhluV3g1h2Z9LvWhUVUqAztz9W2HH6uC7jx+7HNtYC9VgsVzHjuHPQMlOePPZlr9Hry5enF/Psn24RdiKqwCz8WhsOwtmW5PdHLLBVHAoF53URnFR4sgmLLGlS2GEZ8hvxvdV/2NmhRWLebmCZziyklAe9gCR9lgfN32tqzyMG7VptBHFy7YJidWjpjSZPGEqFBL+fmCO/cTGJAXfCn9djAgMBAAECggEAV2QBCgedopShHKZdoyeiWsX621o7B341LR0RI99VYc2GGGNCWcPGPwZQVvEXh0JtLXU4UTR4dw3OApbLG6+qYS7JCzaRqVwhcFYrlbT804HhFMbYWNFsEsxyfUqh3peyrbWUZsqfYI+lKHd61F+CtHW7nje3V6jISnXEeP78cgioKOX8gsCG8DEWsmaLrQz0PyMwdhucRfa8Bm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62v + |jUYF+6xLwimTXJB+MEPpWLMc+Y5NsInX8zKg/393atzWsS9kJOrKgdZmk8+4PfRs53ty2NMPCrRhIExNqtxS7/XYZ0/Y2TpeDwaQfQ + |0WBn9wYVE+6yDkOq0x//OOx9ommGN/I2QDcAnVjTpPm7AJAoGAYT8cDsdlTnfIlY70BSpC/8q8bKgdFeaXz+3MfW6W5wqzC9O7uS2h + |9/rxCAj+lhaJS1dcXOql3Rfi3Tu80vwOxR1SzQ4StKvmJHSDhLA8aFwOahemxBojR1M2lz4IxzQ94n12o5/dozygNYQJSdEkv6IGiT + |QuxM8zuTZdZQ5g2AECgYAujetfkwgVW7/gumpMKytoY0VuTzF4Y/XZfqBMVIiPIuUl57JbDzrcx6YVXX3PavxNWmBLBmMq3SHMbdva + |H7LnU/8rvkT8xRVLg/w/bRJc3Lb3oUjrdhkUQUYDoOfMoFA+ceZ2L6bnSXwm86KKV+xoXWpxAoL4AvdNrMhoWw3+yg==""" + .trimMargin() val johnPublicKey = """-----BEGIN CERTIFICATE----- MIIDkDCCAnigAwIBAgIBADANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJERTEb diff --git a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt index 11107f522953..f1a862d25eb3 100644 --- a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt +++ b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2IT.kt @@ -38,7 +38,6 @@ import com.owncloud.android.util.EncryptionTestIT import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertTrue import org.junit.Assert.assertNotEquals -import org.junit.Assert.assertNotNull import org.junit.Test class EncryptionUtilsV2IT : AbstractIT() { @@ -243,18 +242,6 @@ class EncryptionUtilsV2IT : AbstractIT() { assertEquals(metadataKeyBase64, decryptedMetadataKeyBase64) } - @Test - fun testUserT1() { - val base64encoded = - """Mq33DAHJY0Uc6AhaHFUp1abiWiwVvRDa8h0ckU1qqM4Digb9FKlqcXP2zR+0NbfCAxGLNOUxBVeJJ9qlJg32OGNsNg1wqtZlnLS2NkopSlwajgELRcc94PhS+7rWiNBkNIkD7OGaHvtNRXcG60UekpMK9/TjcBBK3eEgSbJGIaZkDXF9q15i7qocrGeogHKH7Uzd/GJJw/Q2Wid5y4ssfNe66FCdXsvczACcFqb7SSawhihby9b47HVqnwKEcKLeUAJPY4f1n/amvqFhDQsR9PjttLcVIPBjLY8LGgtEH3nBwEc3mCkPtA2Vxrnr4r7+smL0DEeVFXL5pCXBVx44Ng==""" - - val decoded = EncryptionUtils.decodeStringToBase64Bytes(base64encoded) - - val decrypted = EncryptionUtils.decryptStringAsymmetric(base64encoded, encryptionTestUtils.t1PrivateKey) - - assertNotNull(decrypted) - } - @Test fun testEncryptDecryptMetadataFile() { val enc1 = MockUser("enc1", "Nextcloud") @@ -263,11 +250,7 @@ class EncryptionUtilsV2IT : AbstractIT() { val encrypted = encryptionUtilsV2.encryptFolderMetadataFile( metadataFile, - folder, - storageManager, - client, enc1.accountName, - enc1PrivateKey, enc1Cert ) @@ -390,10 +373,8 @@ class EncryptionUtilsV2IT : AbstractIT() { val enc1 = MockUser("enc1", "Nextcloud") val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert) val encrypted = encryptionUtilsV2.encryptFolderMetadataFile( - metadataFile, oCFile, storageManager, - client, + metadataFile, enc1UserId, - enc1PrivateKey, enc1Cert ) @@ -404,49 +385,6 @@ class EncryptionUtilsV2IT : AbstractIT() { assertTrue(true) // if we reach this, test is successful } - @Test - fun verifyMetadataJohn() { - val johnCert = """-----BEGIN CERTIFICATE----- -MIIDkDCCAnigAwIBAgIBADANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJERTEb -MBkGA1UECAwSQmFkZW4tV3VlcnR0ZW1iZXJnMRIwEAYDVQQHDAlTdHV0dGdhcnQx -EjAQBgNVBAoMCU5leHRjbG91ZDENMAsGA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O4ew== ------END CERTIFICATE-----""" - val metadata = - """{"metadata":{"authenticationTag":"F8r4KqKuX2xwVrNhrDfoBA==","ciphertext":"HN93D/fiwincv/4an4oUI2gq6J7kw42L3oxGLPXckeZpuM8EI1B2Ucb0vDokKOCmW5BCvZXINMYylTRTL+gAWXOhta6yHOBfp5ebe+S7duJ1NA/6qDX5okmfUnRtW6fn2FNetL25eNPOEHxCXGdqJrmbJJLID6hlblvTXVcXyvgqoq5fbHBWs2GsN+gE","nonce":"mbJysCiC2LfyGowAJdDOAw=="},"users":[{"certificate":"-----BEGIN CERTIFICATE-----\nMIIDkDCCAnigAwIBAgIBADANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJERTEb\nMBkGA1UECAwSQmFkZW4tV3VlcnR0ZW1iZXJnMRIwEAYDVQQHDAlTdHV0dGdhcnQx\nEjAQBgNVBAoMCU5leHRjbG91ZDENMAsGA1UEAwwEam9objAeFw0yMzA3MTQwNzM0\nNTZaFw00MzA3MDkwNzM0NTZaMGExCzAJBgNVBAYTAkRFMRswGQYDVQQIDBJCYWRl\nbi1XdWVydHRlbWJlcmcxEjAQBgNVBAcMCVN0dXR0Z2FydDESMBAGA1UECgwJTmV4\ndGNsb3VkMQ0wCwYDVQQDDARqb2huMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEA7j3Er5YahJT0LAnSRLhpqbRo+E1AVnt98rvp3DmEfBHNzNB+DS9IBDkS\nSXM/YtfAci6Tcw8ujVBjrZX/WEmrf8ynQHxYmSaJSnP8uAT306/MceZpdpruEc9/\nS10a7vp54Zbld4NYdmfS71oVFVKgM7c/Vthx+rgu48fuxzbWAvVYLFcx47hz0DJT\nnjz2Za/R68uXpxfz7J9uEXYiqsAs/FobDsLZluT3RyywVRwKBed1EZxUeLIJiyxp\nUthhGfIb8b3Vf9jZoUVi3m5gmc4spJQHvYAkfZYHzd9ras8jBu1abQRxcu2CYnVo\n6Y0mTxhKhQS/n5gjv3ExiQF3wp/XYwIDAQABo1MwUTAdBgNVHQ4EFgQUmTeILVuB\ntv70fTGkXWGAueDp5kAwHwYDVR0jBBgwFoAUmTeILVuBtv70fTGkXWGAueDp5kAw\nDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAyVtq9XAvW7nxSW/8\nhp30z6xbzGiuviXhy/Jo91VEa8IRsWCCn3OmDFiVduTEowx76tf8clJP0gk7Pozi\n6dg/7Fin+FqQGXfCk8bLAh9gXKAikQ2GK8yRN3slRFwYC2mm23HrLdKXZHUqJcpB\nMz2zsSrOGPj1YsYOl/U8FU6KA7Yj7U3q7kDMYTAgzUPZAH+d1DISGWpZsMa0RYid\nvigCCLByiccmS/Co4Sb1esF58H+YtV5+nFBRwx881U2g2TgDKF1lPMK/y3d8B8mh\nUtW+lFxRpvyNUDpsMjOErOrtNFEYbgoUJLtqwBMmyGR+nmmh6xna331QWcRAmw0P\nnDO4ew==\n-----END CERTIFICATE-----\n","encryptedMetadataKey":"A3lvWSgIC4MI/ijEVpzaAOlzvqQf1Hnu78PYUCnzpHBhZqpYR6GgA4Wd+hBoZF/gamGoeGX+4wcEPdAGTgKbUVmD1vebXNlaLGDtcO5VmPLlvCx0X71Tg5gg9oEGKbtuDFOpxdA8aqOT5u+cX4xL8rKcKA/CVrA34XGPcG1H+9Q62k2eiXnMhsxpovoI/t2S0lORh239/r1j7RvINornpB3lFdUJ/UAyUHbOjQceBfVxoYSePiPNWdvX6aibFnviTZxwnq35Lduauy/5noSaTkYAeZWvNK2a+FtZOy9m7niVXgzZPNRvEdHH/ZiWR79o01WFw2tKeVxC8cwDtReQfw==","userId":"john"}],"version":"2.0"}""" - val metadataBase64Server = - "eyJtZXRhZGF0YSI6eyJhdXRoZW50aWNhdGlvblRhZyI6IkY4cjRLcUt1WDJ4d1ZyTmhyRGZvQkE9PSIsImNpcGhlcnRleHQiOiJITjkzRC9maXdpbmN2LzRhbjRvVUkyZ3E2SjdrdzQyTDNveEdMUFhja2VacHV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FlAwQBKjALBglghkgBZQMEARYwCwYJYIZIAWUDBAECMAoGCCqGSIb3DQMHMA4GCCqGSIb3DQMCAgIAgDANBggqhkiG9w0DAgIBQDAHBgUrDgMCBzANBggqhkiG9w0DAgIBKDANBgkqhkiG9w0BAQEFAASCAQDlJioK04kwfCHsl6P14WjqNvyiP2I92FL+zAFSHfDHD7hNARQcrj3hlK1Ww5/cTWrurnT4nxN6q8LE5CtgZR4IzqGJefoMowLA/yHnWZgRd/uraIh+RTZCaeOWhRNgxAzG6RxReRrJNZKLRxePZ/ehEWdr54mLMV/jEpPczha0hxHzq2AG//KVKcAKNAVc6hQCLa/oimcfxx7PZ0EJFvPb50V10lQoM1fJiNKbslhsa/omsLKjNO2ezr6fR1vFxb2naSZ85w5cYmn230quAKaSQMp4o00Ym8StfTfJ7qzD3hwaaCpTFFL1CF0CJLhzpqFi+v85KNhdTDT+rrRngdF7" - - val metadata64 = EncryptionUtils.encodeStringToBase64String(metadata) - assertEquals(metadataBase64Server, metadata64) - - assertTrue( - encryptionUtilsV2.verifySignedMessage( - signature, - metadata64, - listOf(EncryptionUtils.convertCertFromString(johnCert)) - ) - ) - } - private fun generateDecryptedFileV1(): com.owncloud.android.datamodel.e2e.v1.decrypted.DecryptedFile { return com.owncloud.android.datamodel.e2e.v1.decrypted.DecryptedFile().apply { encrypted = Data().apply { @@ -512,11 +450,7 @@ nDO4ew== val encryptedMetadataFile = encryptionUtilsV2.encryptFolderMetadataFile( metadataFile, - folder, - storageManager, - client, client.userId, - enc1PrivateKey, enc1Cert ) @@ -713,37 +647,37 @@ nDO4ew== // assertTrue(encryptionUtilsV2.verifySignedMessage(signature1, metadata1, listOf(certJohn, t1cert))) // } - @Test - fun testMarino() { - val metadata = - """{"filedrop":{},"users":[{"certificate":"-----BEGIN CERTIFICATE-----\nMIIDkDCCAnigAwIBAgIBADANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJERTEb\nMBkGA1UECAwSQmFkZW4tV3VlcnR0ZW1i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BRwx881U2g2TgDKF1lPMK\/y3d8B8mh\nUtW+lFxRpvyNUDpsMjOErOrtNFEYbgoUJLtqwBMmyGR+nmmh6xna331QWcRAmw0P\nnDO4ew==\n-----END CERTIFICATE-----\n","userId":"john","encryptedMetadataKey":"zW63bgTlsxhqzBUHFA4KLG+\/TP6mimg56JMnrOssNY3rDtdRAo19kr8CzFSGPx9M4elpBxp3OtJbarT02E\/+Bz9RqH3zVqSJyvjA2sg\/q32p1O2ausVfORtkpQTMgf+KgmeHqvg5PHF0sVeUn\/udx4i8kK8G+r6OjyhZqXns4C\/sRlZzbo3onVYYGygXWW2S+kFfnC7BWIva3R75gyUIaXOl8EEsgOQi94gIEt13v6tO9O1BhXdIhhFXA6EblKTiLhondpHDzbXLzwGgT9riynJoIOVVd4y6PiHbulEXfG5x0cGLhvdJwOIElPoydgLpQ6bvKmHYazWHuQXU4eECkQ=="}],"metadata":{"nonce":"q7Xt1gBr4qL96VlsqxspCg==","ciphertext":"ks4xnkISO+3Nh+2938cRv2gWSxRFie3Q9juBNgqhaW1Ed5T4BnBi3bRv8\/C2vzhHIisQIDZqctBRJ\/O2r0VNSqUSMvj65gtAmUmfg4B+r1V9Z9ftIHTrLyMFDofCs+2Bn+vaU86TfSIu\/Z3dGmWyLJRC6WKMT6St3bKhL3YZqX70DnjsjC8wqq59IY0ietangg+LAKyxVwtW3E75AMXA2SdLC\/+qWfRuNLvcXGTWy6s6IDvZHI3+pidHglMmRM7q5JiJAdMHOBmFTiqt+UYqPiuFCFBKMRR1HQY3bRAvpsDxemWHKL6QBna6BjrYkBXUDPam93OyA2WTRe0uLB81lAMUokLc0g8wSwTxRa5KrZAeMTO1XPf0zlljVvuf1Jq7PFxZ\/4GNXRPKw9Zt8SlnXW0gA2\/+cjMrcp0KiS5+jDZf+kR9P9BXVsLBjqEgTxTqP6DkJu4qp0ns7ofzr+p2zef0HOBX26gLOJ4aZ1gaq6wi|q7Xt1gBr4qL96VlsqxspCg==","authenticationTag":"9BzgV9uoCzieGmdYGqusIg=="},"version":"2.0"}""" - val base64Metadata = EncryptionUtils.encodeStringToBase64String(metadata) - - val privateKey = EncryptionUtils.PEMtoPrivateKey(encryptionTestUtils.johnPrivateKey) - val certificateJohn = EncryptionUtils.convertCertFromString(encryptionTestUtils.johnPublicKey) - val certificateEnc2 = EncryptionUtils.convertCertFromString(enc2Cert) - - val signed = encryptionUtilsV2.signMessage( - certificateJohn, - privateKey, - metadata - ) - - val base64Ans = encryptionUtilsV2.extractSignedString(signed) - - // verify - val certs = listOf( - certificateEnc2, - certificateJohn - ) - assertTrue(encryptionUtilsV2.verifySignedMessage(signed, certs)) - assertTrue(encryptionUtilsV2.verifySignedMessage(base64Ans, base64Metadata, certs)) - } - @Test fun testSigning() { val metadata = - """{"metadata": {"authenticationTag": "zMozev5R09UopLrq7Je1lw==","ciphertext": "j0OBtUrEt4IveGiexjmGK7eKEaWrY70ZkteA5KxHDaZT/t2wwGy9j2FPQGpqXnW6OO3iAYPNgwFikI1smnfNvqdxzVDvhavl/IXa9Kg2niWyqK3D9zpz0YD6mDvl0XsOgTNVyGXNVREdWgzGEERCQoyHI1xowt/swe3KCXw+lf+XPF/t1PfHv0DiDVk70AeWGpPPPu6yggAIxB4Az6PEZhaQWweTC0an48l2FHj2MtB2PiMHtW2v7RMuE8Al3PtE4gOA8CMFrB+Npy6rKcFCXOgTZm5bp7q+J1qkhBDbiBYtvdsYujJ52Xa5SifTpEhGeWWLFnLLgPAQ8o6bXcWOyCoYfLfp4Jpft/Y7H8qzHbPewNSyD6maEv+xljjfU7hxibbszz5A4JjMdQy2BDGoTmJx7Mas+g6l6ZuHLVbdmgQOvD3waJBy6rOg0euux0Cn4bB4bIFEF2KvbhdGbY1Uiq9DYa7kEmSEnlcAYaHyroTkDg4ew7ER0vIBBMzKM3r+UdPVKKS66uyXtZc=","nonce": "W+lxQJeGq7XAJiGfcDohkg=="},"users": [{"certificate": "-----BEGIN CERTIFICATE-----\nMIIDkDCCAnigAwIBAgIBADANB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zUPZAH+d1DISGWpZsMa0RYid\nvigCCLByiccmS/Co4Sb1esF58H+YtV5+nFBRwx881U2g2TgDKF1lPMK/y3d8B8mh\nUtW+lFxRpvyNUDpsMjOErOrtNFEYbgoUJLtqwBMmyGR+nmmh6xna331QWcRAmw0P\nnDO4ew==\n-----END CERTIFICATE-----\n","encryptedMetadataKey": "HVT49bYmwXbGs/dJ2avgU9unrKnPf03MYUI5ZysSR1Bz5pqz64gzH2GBAuUJ+Q4VmHtEfcMaWW7VXgzfCQv5xLBrk+RSgcLOKnlIya8jaDlfttWxbe8jJK+/0+QVPOc6ycA/t5HNCPg09hzj+gnb2L89UHxL5accZD0iEzb5cQbGrc/N6GthjgGrgFKtFf0HhDVplUr+DL9aTyKuKLBPjrjuZbv8M6ZfXO93mOMwSZH3c3rwDUHb/KEaTR/Og4pWQmrqr1VxGLqeV/+GKWhzMYThrOZAUz+5gsbckU2M5V9i+ph0yBI5BjOZVhNuDwW8yP8WtyRJwQc+UBRei/RGBQ==","userId": "john"}],"version": "2"}""" + """{"metadata": {"authenticationTag": "zMozev5R09UopLrq7Je1lw==","ciphertext": "j0OBtUrEt4IveGiexjm + |GK7eKEaWrY70ZkteA5KxHDaZT/t2wwGy9j2FPQGpqXnW6OO3iAYPNgwFikI1smnfNvqdxzVDvhavl/IXa9Kg2niWyqK3D9 + |zpz0YD6mDvl0XsOgTNVyGXNVREdWgzGEERCQoyHI1xowt/swe3KCXw+lf+XPF/t1PfHv0DiDVk70AeWGpPPPu6yggAIxB4 + |Az6PEZhaQWweTC0an48l2FHj2MtB2PiMHtW2v7RMuE8Al3PtE4gOA8CMFrB+Npy6rKcFCXOgTZm5bp7q+J1qkhBDbiBYtv + |dsYujJ52Xa5SifTpEhGeWWLFnLLgPAQ8o6bXcWOyCoYfLfp4Jpft/Y7H8qzHbPewNSyD6maEv+xljjfU7hxibbszz5A4Jj + |MdQy2BDGoTmJx7Mas+g6l6ZuHLVbdmgQOvD3waJBy6rOg0euux0Cn4bB4b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CAQEAyVtq9XAvW7nxSW/8\nhp30z6xbzGiuviXhy/Jo91VEa8IRsWCCn3OmDFiVduTEowx76tf8clJP0gk7Pozi\n6dg/ + |7Fin+FqQGXfCk8bLAh9gXKAikQ2GK8yRN3slRFwYC2mm23HrLdKXZHUqJcpB\nMz2zsSrOGPj1YsYOl/U8FU6KA7Yj7U3q + |7kDMYTAgzUPZAH+d1DISGWpZsMa0RYid\nvigCCLByiccmS/Co4Sb1esF58H+YtV5+nFBRwx881U2g2TgDKF1lPMK/y3d8 + |B8mh\nUtW+lFxRpvyNUDpsMjOErOrtNFEYbgoUJLtqwBMmyGR+nmmh6xna331QWcRAmw0P\nnDO4ew==\n-----END CER + |TIFICATE-----\n","encryptedMetadataKey": "HVT49bYmwXbGs/dJ2avgU9unrKnPf03MYUI5ZysSR1Bz5pqz64gz + |H2GBAuUJ+Q4VmHtEfcMaWW7VXgzfCQv5xLBrk+RSgcLOKnlIya8jaDlfttWxbe8jJK+/0+QVPOc6ycA/t5HNCPg09hzj+g + |nb2L89UHxL5accZD0iEzb5cQbGrc/N6GthjgGrgFKtFf0HhDVplUr+DL9aTyKuKLBPjrjuZbv8M6ZfXO93mOMwSZH3c3rw + |DUHb/KEaTR/Og4pWQmrqr1VxGLqeV/+GKWhzMYThrOZAUz+5gsbckU2M5V9i+ph0yBI5BjOZVhNuDwW8yP8WtyRJwQc+UB + |Rei/RGBQ==","userId": "john"}],"version": "2"} + """.trimMargin() + val base64Metadata = EncryptionUtils.encodeStringToBase64String(metadata) val privateKey = EncryptionUtils.PEMtoPrivateKey(encryptionTestUtils.t1PrivateKey) @@ -770,7 +704,7 @@ nDO4ew== @Test fun sign() { val enc1 = MockUser("enc1", "Nextcloud") - //val sut = generateDecryptedFolderMetadataFile(enc1, enc1Cert) + // val sut = generateDecryptedFolderMetadataFile(enc1, enc1Cert) // val json = EncryptionUtils.serializeJSON(sut, true) val sut = "randomstring123" @@ -797,30 +731,6 @@ nDO4ew== assertTrue(encryptionUtilsV2.verifySignedMessage(base64Ans, jsonBase64, certs)) } - @Test - fun signWindows() { - val enc1 = MockUser("enc1", "Nextcloud") - //val sut = generateDecryptedFolderMetadataFile(enc1, enc1Cert) - // val json = EncryptionUtils.serializeJSON(sut, true) - - val sut = "windowsrandomstring123" - val json = "windowsrandomstring123" - - val privateKey = EncryptionUtils.PEMtoPrivateKey(encryptionTestUtils.t1PrivateKey) - val certificate = EncryptionUtils.convertCertFromString(encryptionTestUtils.t1PublicKey) - - val base64Ans = - """MIIFSAYJKoZIhvcNAQcCoIIFOTCCBTUCAQExDTALBglghkgBZQMEAgEwCwYJKoZIhvcNAQcBoIIC7DCCAugwggHQoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwDTELMAkGA1UEAwwCdDEwHhcNMjMwNzI1MDc1NzEyWhcNNDMwNzIwMDc1NzEyWjANMQswCQYDVQQDDAJ0MTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALWnx5gwXAaiLuB5jMTA1t49EsvktGGisB5wUbfOSksHBKL9AeRTi7i5J6ARseA597vd4pU4V18WnDzB3ly+1j7gLNtfxu77KsL60UZwnbn/hVDvwGXgwjRK86bEPC5k2uD1JaCz1HCJqUo6x8ITLPRJLxGy0Y23kpkqfV7zPtX1f945E+Y5DkpwhceUxsBjebh6sFIq+FFl2rL4NudzStl5loqSggwkfU5h9W2j96TXaIgoXZhK09XOhOA2wV6U8PF4D+WW2B/qoNVEP4QvJ0Sdw8gnBy/nYPxmK2gTIQ5+MNlb6u+8TTaDVkPXE+QMunCW0CwUKCUIq8oEBa6G2EUCAwEAAaNTMFEwHQYDVR0OBBYEFBPcwngPf0DALVYC8Q9t1+mXKHYTMB8GA1UdIwQYMBaAFBPcwngPf0DALVYC8Q9t1+mXKHYTMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAGXcv2IyZb589xUMMaeqFbTCXHKXcb3hD3y84Gr3q4bXf7z/DgLw8zi4ECR5qw0vdUhudN3lOHGBsrjSsHe+zsk56jIPhlBJiYRnz6UlaxCHYeuY76utU+KKgXXoXr1ZgaueKxosC9Axr9Q5V0JcIiWT+Kp4tipzhBXJ7y94FbUZ0I10PpB75TLIZCusNNtRDFeTX4xts4Ou8Auuay2no+X+krKdku4NlbZhOGl6tW4wLhG6pOE4smRyw3bCbqs8hssjqTFe4vbnFw6GmbfXBkvYU9r0cU60h+t7ykfF3ooPfrLS8LfTjXFKgij+4XfK2o7cTOCSCERMcA/DpIAEVhoxggIiMIICHgIBATASMA0xCzAJBgNVBAMMAnQxAgEAMAsGCWCGSAFlAwQCAaCB5DAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMzA3MjgxMjIwMTNaMC8GCSqGSIb3DQEJBDEiBCDKmcDaHONFCK8DWr0lJwfBQdlmVSyyqgzpplVlVIndxzB5BgkqhkiG9w0BCQ8xbDBqMAsGCWCGSAFlAwQBKjALBglghkgBZQMEARYwCwYJYIZIAWUDBAECMAoGCCqGSIb3DQMHMA4GCCqGSIb3DQMCAgIAgDANBggqhkiG9w0DAgIBQDAHBgUrDgMCBzANBggqhkiG9w0DAgIBKDANBgkqhkiG9w0BAQEFAASCAQCcaKwRe3TPumGkPEXrOgk4kJuNLrF7GLI+wGwaM8rwOxlfC6mG/Oz+v66WJok2LdvH64wwl/hdJO1n1PYQxVm0FHMntwGKjyuXMdo+VZEbEE6+T36hHTh1y0tDf4Z/DM0/QyEegqqw59+H9crzNMyw8r8xx6dAjiB3zku7QXBN3bkBfeilRELRN5HHUiMAuqXkYMPWQzNcTNC8VCqGMwlHKu6FcXFrnXiqd9O2AidvUI8vp3b4GKQEfhKxyiUzJYyk68+KQA3MaM6ybrWZ126aAUUQ4MdqYTxqHQnG09D9bFpKS7zIrLC7TIUhnkM1PLygLz46ekIIn2IJlsvZ6ZsH""" - - // verify - val certs = listOf( - EncryptionUtils.convertCertFromString(enc2Cert), - certificate - ) - //assertTrue(encryptionUtilsV2.verifySignedMessage(signed, certs)) - assertTrue(encryptionUtilsV2.verifySignedMessage(base64Ans, json, certs)) - } - /** * DecryptedFolderMetadata -> EncryptedFolderMetadata -> JSON -> encrypt -> decrypt -> JSON -> * EncryptedFolderMetadata -> DecryptedFolderMetadata @@ -842,11 +752,7 @@ nDO4ew== // encrypt val encryptedFolderMetadata1 = encryptionUtilsV2.encryptFolderMetadataFile( decryptedFolderMetadata1, - folder, - fileDataStorageManager, - client, client.userId, - EncryptionTestIT.privateKey, EncryptionTestIT.publicKey ) diff --git a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2ServerIT.kt b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2ServerIT.kt index 87dfb1ee1c7b..dcd7067e9736 100644 --- a/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2ServerIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/utils/EncryptionUtilsV2ServerIT.kt @@ -64,7 +64,6 @@ class EncryptionUtilsV2ServerIT : AbstractOnServerIT() { metadataFile, token, client, - storageManager, false, targetContext, user @@ -87,7 +86,6 @@ class EncryptionUtilsV2ServerIT : AbstractOnServerIT() { metadataFile, token, client, - storageManager, true, targetContext, user diff --git a/app/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/app/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java index 8bcf1be9f90f..d4176e25e9b6 100644 --- a/app/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java @@ -300,7 +300,6 @@ private RemoteOperationResult encryptedCreateV2(OCFile parent, OwnCloudClient cl updatedMetadataFile, token, client, - getStorageManager(), metadataExists, context, user); diff --git a/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java b/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java index 40dac34fa23a..ef3038671ea0 100644 --- a/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java @@ -218,7 +218,6 @@ protected RemoteOperationResult run(OwnCloudClient client) { newMetadata, token, client, - getStorageManager(), metadataExists, context, user); diff --git a/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java b/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java index ae02e183b0aa..d1f9ce00f780 100644 --- a/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java @@ -26,7 +26,6 @@ import com.nextcloud.client.account.User; import com.owncloud.android.datamodel.ArbitraryDataProvider; import com.owncloud.android.datamodel.ArbitraryDataProviderImpl; -import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.e2e.v2.decrypted.DecryptedFolderMetadataFile; import com.owncloud.android.lib.common.OwnCloudClient; @@ -134,7 +133,6 @@ protected RemoteOperationResult run(OwnCloudClient client) { metadata, token, client, - new FileDataStorageManager(user, context.getContentResolver()), metadataExists, context, user); diff --git a/app/src/main/java/com/owncloud/android/operations/UnshareOperation.java b/app/src/main/java/com/owncloud/android/operations/UnshareOperation.java index 3ef7f66305c4..4dc5298263a3 100644 --- a/app/src/main/java/com/owncloud/android/operations/UnshareOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/UnshareOperation.java @@ -115,7 +115,6 @@ protected RemoteOperationResult run(OwnCloudClient client) { newMetadata, token, client, - getStorageManager(), true, context, user); diff --git a/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java index b08c63a4e15d..c0a866502699 100644 --- a/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java @@ -645,7 +645,6 @@ private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile pare metadata, token, client, - getStorageManager(), metadataExists, mContext, user); diff --git a/app/src/main/java/com/owncloud/android/ui/asynctasks/SecureShareTask.kt b/app/src/main/java/com/owncloud/android/ui/asynctasks/SecureShareTask.kt deleted file mode 100644 index 91b4aea4eb4b..000000000000 --- a/app/src/main/java/com/owncloud/android/ui/asynctasks/SecureShareTask.kt +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Nextcloud Android client application - * - * @author Tobias Kaminsky - * Copyright (C) 2023 Tobias Kaminsky - * Copyright (C) 2023 Nextcloud GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package com.owncloud.android.ui.asynctasks - -import android.os.AsyncTask -import com.nextcloud.client.account.User -import com.nextcloud.client.network.ClientFactory -import com.nextcloud.common.NextcloudClient -import com.owncloud.android.R -import com.owncloud.android.datamodel.ArbitraryDataProvider -import com.owncloud.android.datamodel.OCFile -import com.owncloud.android.lib.resources.shares.OCShare -import com.owncloud.android.lib.resources.shares.ShareType -import com.owncloud.android.lib.resources.users.GetPublicKeyRemoteOperation -import com.owncloud.android.ui.activity.FileActivity -import com.owncloud.android.ui.helpers.FileOperationsHelper -import com.owncloud.android.utils.DisplayUtils -import com.owncloud.android.utils.EncryptionUtils -import java.lang.ref.WeakReference - -class SecureShareTask( - val currentUser: User, - val clientFactory: ClientFactory, - private val shareeName: String, - val arbitraryDataProvider: ArbitraryDataProvider, - private val fileOperationsHelper: FileOperationsHelper, - val file: OCFile, - private val activityWeakReference: WeakReference -) : AsyncTask() { - override fun onPreExecute() { - super.onPreExecute() - - activityWeakReference.get()?.let { - it.showLoadingDialog(it.getString(R.string.wait_a_moment)) - } - } - - override fun doInBackground(vararg params: Void): Int { - return share() - } - - override fun onPostExecute(result: Int) { - super.onPostExecute(result) - - if (result != 0) { - activityWeakReference.get()?.let { - DisplayUtils.showSnackMessage(it, result) - } - } - } - - private fun share(): Int { - // secure share, first check if user has e2e - try { - val nextcloudClient: NextcloudClient = clientFactory.createNextcloudClient(currentUser) - val result = GetPublicKeyRemoteOperation(shareeName).execute(nextcloudClient) - if (result.isSuccess) { // TODO check first if we already have it, TOFU! - // store it - EncryptionUtils.savePublicKey( - currentUser, - result.resultData, - shareeName, - arbitraryDataProvider - ) - } else { - return R.string.secure_share_not_set_up - } - - // no option, thus directly share it - fileOperationsHelper.shareFileWithSharee( - file, - shareeName, - ShareType.USER, - OCShare.SHARE_PERMISSION_FLAG, - false, - null, - -1, - "", - null, - false - ) - } catch (e: Exception) { - R.string.secure_sharing_failed - } - - return 0 - } -} diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 11779b34057b..13a424a34f39 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1784,7 +1784,6 @@ private void encryptFolder(OCFile folder, metadata, token, client, - storageManager, metadataExists, requireContext(), user); diff --git a/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt b/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt index 2cb07f24648e..1a261d29fa15 100644 --- a/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt +++ b/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt @@ -70,6 +70,7 @@ import java.security.cert.X509Certificate import java.util.zip.GZIPInputStream import java.util.zip.GZIPOutputStream +@Suppress("TooManyFunctions") class EncryptionUtilsV2 { @VisibleForTesting fun encryptMetadata(metadata: DecryptedMetadata, metadataKey: ByteArray): EncryptedMetadata { @@ -101,11 +102,7 @@ class EncryptionUtilsV2 { fun encryptFolderMetadataFile( metadataFile: DecryptedFolderMetadataFile, - ocFile: OCFile, - storageManager: FileDataStorageManager, - client: OwnCloudClient, userId: String, - privateKey: String, certificate: String ): EncryptedFolderMetadataFile { val encryptedUsers: List @@ -168,6 +165,7 @@ class EncryptionUtilsV2 { } @Throws(IllegalStateException::class) + @Suppress("LongParameterList") fun decryptFolderMetadataFile( metadataFile: EncryptedFolderMetadataFile, userId: String, @@ -221,6 +219,7 @@ class EncryptionUtilsV2 { } @Throws(IllegalStateException::class) + @Suppress("ThrowsCount") fun retrieveTopMostMetadataKey( folder: OCFile, storageManager: FileDataStorageManager, @@ -355,6 +354,7 @@ class EncryptionUtilsV2 { return metadataFile } + @Suppress("LongParameterList") fun addFileToMetadata( encryptedFileName: String, ocFile: OCFile, @@ -472,6 +472,7 @@ class EncryptionUtilsV2 { } @Throws(IllegalStateException::class) + @Suppress("TooGenericExceptionCaught") fun parseAnyMetadata( metadataResponse: MetadataResponse, user: User, @@ -565,8 +566,8 @@ class EncryptionUtilsV2 { // } // // // upload metadata -// EncryptedFolderMetadataFile encryptedFolderMetadataNew = encryptFolderMetadata(decryptedFolderMetadata, -// privateKey); +// EncryptedFolderMetadataFile encryptedFolderMetadataNew = +// encryptFolderMetadata(decryptedFolderMetadata, privateKey); // // String serializedFolderMetadata = EncryptionUtils.serializeJSON(encryptedFolderMetadataNew); // @@ -607,7 +608,8 @@ class EncryptionUtilsV2 { // user, // folder.getLocalId()); // -// boolean transferredFiledrop = filesDropCountBefore > 0 && decryptedFolderMetadata.getFiles().size() == +// boolean transferredFiledrop = filesDropCountBefore > 0 && +// decryptedFolderMetadata.getFiles().size() == // encryptedFolderMetadata.getFiles().size() + filesDropCountBefore; // // if (transferredFiledrop) { @@ -615,11 +617,12 @@ class EncryptionUtilsV2 { // String token = EncryptionUtils.lockFolder(folder, client); // // // upload metadata -// EncryptedFolderMetadata encryptedFolderMetadataNew = encryptFolderMetadata(decryptedFolderMetadata, -// publicKey, -// arbitraryDataProvider, -// user, -// folder.getLocalId()); +// EncryptedFolderMetadata encryptedFolderMetadataNew = +// encryptFolderMetadata(decryptedFolderMetadata, +// publicKey, +// arbitraryDataProvider, +// user, +// folder.getLocalId()); // } @@ -661,12 +664,12 @@ class EncryptionUtilsV2 { } @Throws(UploadException::class) + @Suppress("LongParameterList") fun serializeAndUploadMetadata( parentFile: OCFile, metadata: DecryptedFolderMetadataFile, token: String, client: OwnCloudClient, - storageManager: FileDataStorageManager, metadataExists: Boolean, context: Context, user: User @@ -677,11 +680,7 @@ class EncryptionUtilsV2 { val encryptedFolderMetadata = encryptFolderMetadataFile( metadata, - parentFile, - storageManager, - client, client.userId, - privateKeyString, publicKeyString ) val serializedFolderMetadata = EncryptionUtils.serializeJSON(encryptedFolderMetadata, true) @@ -718,6 +717,7 @@ class EncryptionUtilsV2 { } @Throws(IllegalStateException::class) + @Suppress("ThrowsCount") @VisibleForTesting fun verifyMetadata( encryptedFolderMetadataFile: EncryptedFolderMetadataFile, @@ -760,6 +760,7 @@ class EncryptionUtilsV2 { /** * SHA-256 hash of metadata-key */ + @Suppress("MagicNumber") fun hashMetadataKey(metadataKey: ByteArray): String { val bytes = MessageDigest .getInstance("SHA-256")