-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update crypto rust #1105
Update crypto rust #1105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pourquoi supprimes-tu aussi |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C'est quoi cet appel |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,12 @@ package org.matrix.android.sdk.internal.session.contentscanner | |
import org.matrix.android.sdk.api.session.crypto.attachments.ElementToDecrypt | ||
import org.matrix.android.sdk.api.session.crypto.model.EncryptedFileInfo | ||
import org.matrix.android.sdk.api.session.crypto.model.EncryptedFileKey | ||
import org.matrix.android.sdk.internal.crypto.tools.withOlmEncryption | ||
import org.matrix.android.sdk.api.util.fromBase64 | ||
import org.matrix.android.sdk.api.util.toBase64NoPadding | ||
import org.matrix.android.sdk.internal.session.contentscanner.model.DownloadBody | ||
import org.matrix.android.sdk.internal.session.contentscanner.model.EncryptedBody | ||
import org.matrix.android.sdk.internal.session.contentscanner.model.toCanonicalJson | ||
import org.matrix.rustcomponents.sdk.crypto.PkEncryption | ||
|
||
internal object ScanEncryptorUtils { | ||
|
||
|
@@ -43,19 +45,15 @@ internal object ScanEncryptorUtils { | |
v = "v2" | ||
) | ||
return if (publicServerKey != null) { | ||
// We should encrypt | ||
withOlmEncryption { olm -> | ||
olm.setRecipientKey(publicServerKey) | ||
|
||
val olmResult = olm.encrypt(DownloadBody(encryptedInfo).toCanonicalJson()) | ||
DownloadBody( | ||
encryptedBody = EncryptedBody( | ||
cipherText = olmResult.mCipherText, | ||
ephemeral = olmResult.mEphemeralKey, | ||
mac = olmResult.mMac | ||
) | ||
) | ||
} | ||
val pkEncryption = PkEncryption.fromPublicKey(publicServerKey.fromBase64()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test si le |
||
val result = pkEncryption.encrypt(DownloadBody(encryptedInfo).toCanonicalJson().toByteArray()) | ||
DownloadBody( | ||
encryptedBody = EncryptedBody( | ||
cipherText = result.ciphertext.toBase64NoPadding(), | ||
ephemeral = result.ephemeralKey.toBase64NoPadding(), | ||
mac = result.mac.toBase64NoPadding() | ||
) | ||
) | ||
} else { | ||
DownloadBody(encryptedInfo) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu devrais tester ici que tes secrets sont Base64 déchiffrables avant de les utiliser plus bas, je pense.