mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-27 04:04:43 +01:00
Refactor and simplify attachment archiving.
This commit is contained in:
committed by
Cody Henthorne
parent
816006c67e
commit
e80ebd87fe
@@ -87,6 +87,12 @@ class ArchiveApi(private val pushServiceSocket: PushServiceSocket) {
|
||||
|
||||
/**
|
||||
* Fetches an upload form you can use to upload your main message backup file to cloud storage.
|
||||
*
|
||||
* Responses
|
||||
* 200: Success
|
||||
* 400: Bad args, or made on an authenticated channel
|
||||
* 403: Insufficient permissions
|
||||
* 429: Rate-limited
|
||||
*/
|
||||
fun getMessageBackupUploadForm(backupKey: BackupKey, aci: ACI, serviceCredential: ArchiveServiceCredential): NetworkResult<AttachmentUploadForm> {
|
||||
return NetworkResult.fromFetch {
|
||||
@@ -200,6 +206,7 @@ class ArchiveApi(private val pushServiceSocket: PushServiceSocket) {
|
||||
* 400: Bad arguments, or made on an authenticated channel
|
||||
* 401: Invalid presentation or signature
|
||||
* 403: Insufficient permissions
|
||||
* 410: The source object was not found
|
||||
* 413: No media space remaining
|
||||
* 429: Rate-limited
|
||||
*/
|
||||
|
||||
@@ -5,16 +5,22 @@
|
||||
|
||||
package org.whispersystems.signalservice.api.crypto
|
||||
|
||||
class AttachmentCipherStreamUtil {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getCiphertextLength(plaintextLength: Long): Long {
|
||||
return 16 + (plaintextLength / 16 + 1) * 16 + 32
|
||||
}
|
||||
object AttachmentCipherStreamUtil {
|
||||
|
||||
@JvmStatic
|
||||
fun getPlaintextLength(ciphertextLength: Long): Long {
|
||||
return ((ciphertextLength - 16 - 32) / 16 - 1) * 16
|
||||
}
|
||||
/**
|
||||
* Given the size of the plaintext, this will return the length of ciphertext output.
|
||||
* @param inputSize Size of the plaintext fed into the stream. This does *not* automatically include padding. Add that yourself before calling if needed.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getCiphertextLength(plaintextLength: Long): Long {
|
||||
val ivLength: Long = 16
|
||||
val macLength: Long = 32
|
||||
val blockLength: Long = (plaintextLength / 16 + 1) * 16
|
||||
return ivLength + macLength + blockLength
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPlaintextLength(ciphertextLength: Long): Long {
|
||||
return ((ciphertextLength - 16 - 32) / 16 - 1) * 16
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user