Introduce Wire for proto codegen.

This commit is contained in:
Greyson Parrelli
2023-02-02 10:10:00 -05:00
committed by Nicholas Tinsley
parent 72449fd73e
commit a91a13cead
11 changed files with 215 additions and 31 deletions

View File

@@ -1,10 +1,10 @@
package org.thoughtcrime.securesms.registration.secondary
import com.google.protobuf.ByteString
import okio.ByteString.Companion.toByteString
import org.signal.libsignal.protocol.IdentityKeyPair
import org.signal.libsignal.protocol.ecc.Curve
import org.signal.libsignal.protocol.ecc.ECKeyPair
import org.thoughtcrime.securesms.devicelist.DeviceNameProtos
import org.thoughtcrime.securesms.devicelist.protos.DeviceName
import java.nio.charset.Charset
import javax.crypto.Cipher
import javax.crypto.Mac
@@ -30,12 +30,11 @@ object DeviceNameCipher {
cipher.init(Cipher.ENCRYPT_MODE, SecretKeySpec(cipherKey, "AES"), IvParameterSpec(ByteArray(16)))
val cipherText = cipher.doFinal(plaintext)
return DeviceNameProtos.DeviceName.newBuilder()
.setEphemeralPublic(ByteString.copyFrom(ephemeralKeyPair.publicKey.serialize()))
.setSyntheticIv(ByteString.copyFrom(syntheticIv))
.setCiphertext(ByteString.copyFrom(cipherText))
.build()
.toByteArray()
return DeviceName(
ephemeralPublic = ephemeralKeyPair.publicKey.serialize().toByteString(),
syntheticIv = syntheticIv.toByteString(),
ciphertext = cipherText.toByteString()
).encode()
}
private fun computeCipherKey(masterSecret: ByteArray, syntheticIv: ByteArray): ByteArray {