Modern Apps git

← Modern-Apps.git

messages & passwords: remove bouncy castle

Commit
11e207bbd361c185ba24c0b15a1cb09b215b092c
Author
Vayun Mathur <[email protected]>
When
2026-07-25 05:04 UTC (4 months ago)
Parents
681c5bd

Diff

messages/build.gradle.kts
diff --git a/messages/build.gradle.kts b/messages/build.gradle.ktsindex a8ac901853..e8cd91c9cd 100644--- a/messages/build.gradle.kts+++ b/messages/build.gradle.kts@@ -180,10 +180,9 @@ dependencies {     implementation(libs.androidx.camera.lifecycle)     implementation(libs.androidx.camera.view) -    // Bouncy Castle — AES-IGE for MTProto encryption, X25519 for WhatsApp Noise-    implementation(libs.bouncycastle)--    // Signal protocol crypto (Double Ratchet, sealed sender, pre-keys, etc.)+    // Signal protocol crypto (Double Ratchet, sealed sender, pre-keys, etc.).+    // Also provides constant-time X25519 (org.signal.libsignal.protocol.ecc.Curve)+    // used by the WhatsApp Noise handshake — no Bouncy Castle needed.     implementation("org.signal:libsignal-android:0.86.5")     // Classic pure-Java Signal protocol (X3DH) for the WhatsApp bridge. libsignal-android 0.86     // removed X3DH (PQXDH-only), which WhatsApp companion sessions require. This artifact has no
messages/src/main/java/com/vayunmathur/messages/telegram/mtproto/crypto/AesIge.kt
diff --git a/messages/src/main/java/com/vayunmathur/messages/telegram/mtproto/crypto/AesIge.kt b/messages/src/main/java/com/vayunmathur/messages/telegram/mtproto/crypto/AesIge.ktindex a29f00ebb5..6f973f0338 100644--- a/messages/src/main/java/com/vayunmathur/messages/telegram/mtproto/crypto/AesIge.kt+++ b/messages/src/main/java/com/vayunmathur/messages/telegram/mtproto/crypto/AesIge.kt@@ -1,38 +1,45 @@ package com.vayunmathur.messages.telegram.mtproto.crypto -import org.bouncycastle.crypto.engines.AESEngine-import org.bouncycastle.crypto.params.KeyParameter+import javax.crypto.Cipher+import javax.crypto.spec.SecretKeySpec +/**+ * AES-256-IGE (MTProto) built on the platform AES block cipher (Conscrypt,+ * `AES/ECB/NoPadding` as the raw single-block primitive) — no Bouncy Castle. The+ * IGE chaining is implemented here; ECB is used only to apply the AES permutation+ * to one 16-byte block at a time.+ */ object AesIge {+    private const val BLOCK = 16++    private fun cipher(encrypt: Boolean, key: ByteArray): Cipher =+        Cipher.getInstance("AES/ECB/NoPadding").apply {+            init(if (encrypt) Cipher.ENCRYPT_MODE else Cipher.DECRYPT_MODE, SecretKeySpec(key, "AES"))+        }+     fun encrypt(data: ByteArray, key: ByteArray, iv: ByteArray): ByteArray {         require(key.size == 32) { "AES-256 key must be 32 bytes" }         require(iv.size == 32) { "IGE IV must be 32 bytes" }-        require(data.size % 16 == 0) { "Data must be aligned to 16 bytes" }+        require(data.size % BLOCK == 0) { "Data must be aligned to 16 bytes" } -        val aes = AESEngine.newInstance()-        aes.init(true, KeyParameter(key))-        val blockSize = 16--        val ivP1 = iv.copyOfRange(0, 16)-        val ivP2 = iv.copyOfRange(16, 32)+        val aes = cipher(encrypt = true, key = key)          val result = ByteArray(data.size)-        val xorBuf = ByteArray(blockSize)-        val outBlock = ByteArray(blockSize)+        val xorBuf = ByteArray(BLOCK) -        var prevCiphertext = ivP1-        var prevPlaintext = ivP2+        var prevCiphertext = iv.copyOfRange(0, BLOCK)+        var prevPlaintext = iv.copyOfRange(BLOCK, 32) -        for (i in data.indices step blockSize) {-            for (j in 0 until blockSize) {+        for (i in data.indices step BLOCK) {+            for (j in 0 until BLOCK) {                 xorBuf[j] = (data[i + j].toInt() xor prevCiphertext[j].toInt()).toByte()             }-            aes.processBlock(xorBuf, 0, outBlock, 0)-            for (j in 0 until blockSize) {+            val outBlock = aes.doFinal(xorBuf)+            for (j in 0 until BLOCK) {                 result[i + j] = (outBlock[j].toInt() xor prevPlaintext[j].toInt()).toByte()             }-            prevCiphertext = result.copyOfRange(i, i + blockSize)-            prevPlaintext = data.copyOfRange(i, i + blockSize)+            prevCiphertext = result.copyOfRange(i, i + BLOCK)+            prevPlaintext = data.copyOfRange(i, i + BLOCK)         }         return result     }@@ -40,32 +47,26 @@ object AesIge {     fun decrypt(data: ByteArray, key: ByteArray, iv: ByteArray): ByteArray {         require(key.size == 32) { "AES-256 key must be 32 bytes" }         require(iv.size == 32) { "IGE IV must be 32 bytes" }-        require(data.size % 16 == 0) { "Data must be aligned to 16 bytes" }--        val aes = AESEngine.newInstance()-        aes.init(false, KeyParameter(key))-        val blockSize = 16+        require(data.size % BLOCK == 0) { "Data must be aligned to 16 bytes" } -        val ivP1 = iv.copyOfRange(0, 16)-        val ivP2 = iv.copyOfRange(16, 32)+        val aes = cipher(encrypt = false, key = key)          val result = ByteArray(data.size)-        val xorBuf = ByteArray(blockSize)-        val outBlock = ByteArray(blockSize)+        val xorBuf = ByteArray(BLOCK) -        var prevCiphertext = ivP1-        var prevPlaintext = ivP2+        var prevCiphertext = iv.copyOfRange(0, BLOCK)+        var prevPlaintext = iv.copyOfRange(BLOCK, 32) -        for (i in data.indices step blockSize) {-            for (j in 0 until blockSize) {+        for (i in data.indices step BLOCK) {+            for (j in 0 until BLOCK) {                 xorBuf[j] = (data[i + j].toInt() xor prevPlaintext[j].toInt()).toByte()             }-            aes.processBlock(xorBuf, 0, outBlock, 0)-            for (j in 0 until blockSize) {+            val outBlock = aes.doFinal(xorBuf)+            for (j in 0 until BLOCK) {                 result[i + j] = (outBlock[j].toInt() xor prevCiphertext[j].toInt()).toByte()             }-            prevPlaintext = result.copyOfRange(i, i + blockSize)-            prevCiphertext = data.copyOfRange(i, i + blockSize)+            prevPlaintext = result.copyOfRange(i, i + BLOCK)+            prevCiphertext = data.copyOfRange(i, i + BLOCK)         }         return result     }
messages/src/main/java/com/vayunmathur/messages/whatsapp/WhatsAppProtocol.kt
diff --git a/messages/src/main/java/com/vayunmathur/messages/whatsapp/WhatsAppProtocol.kt b/messages/src/main/java/com/vayunmathur/messages/whatsapp/WhatsAppProtocol.ktindex df64c9e1e3..ca2bc039b6 100644--- a/messages/src/main/java/com/vayunmathur/messages/whatsapp/WhatsAppProtocol.kt+++ b/messages/src/main/java/com/vayunmathur/messages/whatsapp/WhatsAppProtocol.kt@@ -10,12 +10,7 @@ import javax.crypto.Mac import javax.crypto.spec.GCMParameterSpec import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.SecretKeySpec-import org.bouncycastle.crypto.agreement.X25519Agreement-import org.bouncycastle.crypto.params.X25519PrivateKeyParameters-import org.bouncycastle.crypto.params.X25519PublicKeyParameters-import org.bouncycastle.crypto.generators.HKDFBytesGenerator-import org.bouncycastle.crypto.params.HKDFParameters-import org.bouncycastle.crypto.digests.SHA256Digest+import org.whispersystems.libsignal.ecc.Curve import org.signal.libsignal.protocol.ecc.ECPublicKey  /**@@ -167,15 +162,8 @@ object WhatsAppProtocol {         }          private fun extractAndExpand(salt: ByteArray, data: ByteArray): Pair<ByteArray, ByteArray> {-            val hkdf = HKDFBytesGenerator(SHA256Digest())-            hkdf.init(HKDFParameters(data, salt, null))--            val writeKey = ByteArray(32)-            val readKey = ByteArray(32)-            hkdf.generateBytes(writeKey, 0, 32)-            hkdf.generateBytes(readKey, 0, 32)--            return Pair(writeKey, readKey)+            val out = hkdfSha256(data, salt, ByteArray(0), 64)+            return Pair(out.copyOfRange(0, 32), out.copyOfRange(32, 64))         }          fun finish(): Pair<SecretKeySpec, SecretKeySpec> {@@ -197,29 +185,40 @@ object WhatsAppProtocol {      // -- Cryptography helpers -- +    // X25519 via libsignal (Rust, constant-time; already shipped as libsignal_jni.so).+    // WhatsApp uses raw 32-byte keys; libsignal public keys carry a 0x05 DJB type prefix.     fun x25519(privateKey: ByteArray, publicKey: ByteArray): ByteArray {-        val privParams = X25519PrivateKeyParameters(privateKey, 0)-        val pubParams = X25519PublicKeyParameters(publicKey, 0)-        val agreement = X25519Agreement()-        agreement.init(privParams)-        val sharedSecret = ByteArray(32)-        agreement.calculateAgreement(pubParams, sharedSecret, 0)-        return sharedSecret+        val priv = Curve.decodePrivatePoint(privateKey)+        val pub = Curve.decodePoint(byteArrayOf(0x05) + publicKey, 0)+        return Curve.calculateAgreement(pub, priv)     }      fun generateX25519KeyPair(): Pair<ByteArray, ByteArray> {-        val random = SecureRandom()-        val privateKey = ByteArray(32)-        random.nextBytes(privateKey)-        privateKey[0] = (privateKey[0].toInt() and 248).toByte()-        privateKey[31] = (privateKey[31].toInt() and 127).toByte()-        privateKey[31] = (privateKey[31].toInt() or 64).toByte()--        val privParams = X25519PrivateKeyParameters(privateKey, 0)-        val publicKey = privParams.generatePublicKey().encoded+        val kp = Curve.generateKeyPair()+        val privateKey = kp.privateKey.serialize()               // 32-byte scalar+        val publicKey = kp.publicKey.serialize().copyOfRange(1, 33) // strip 0x05 prefix -> raw 32         return Pair(privateKey, publicKey)     } +    /** HKDF-SHA256 (RFC 5869) on the platform Mac. null/empty salt = zero salt. */+    private fun hkdfSha256(ikm: ByteArray, salt: ByteArray?, info: ByteArray, length: Int): ByteArray {+        val actualSalt = if (salt == null || salt.isEmpty()) ByteArray(32) else salt+        val prk = Mac.getInstance("HmacSHA256").apply { init(SecretKeySpec(actualSalt, "HmacSHA256")) }.doFinal(ikm)+        val out = ByteArray(length)+        var t = ByteArray(0)+        var pos = 0+        var counter = 1+        while (pos < length) {+            val mac = Mac.getInstance("HmacSHA256").apply { init(SecretKeySpec(prk, "HmacSHA256")) }+            mac.update(t); mac.update(info); mac.update(counter.toByte())+            t = mac.doFinal()+            val n = minOf(t.size, length - pos)+            System.arraycopy(t, 0, out, pos, n)+            pos += n; counter+++        }+        return out+    }+     fun sha256(data: ByteArray): ByteArray {         val digest = MessageDigest.getInstance("SHA-256")         return digest.digest(data)@@ -238,10 +237,7 @@ object WhatsAppProtocol {      * snapshotMac, patchMac. Ref whatsmeow appstate/keys.go expandAppStateKeys.      */     fun expandAppStateKeys(keyData: ByteArray): Array<ByteArray> {-        val hkdf = HKDFBytesGenerator(SHA256Digest())-        hkdf.init(HKDFParameters(keyData, null, "WhatsApp Mutation Keys".toByteArray(Charsets.UTF_8)))-        val out = ByteArray(160)-        hkdf.generateBytes(out, 0, 160)+        val out = hkdfSha256(keyData, null, "WhatsApp Mutation Keys".toByteArray(Charsets.UTF_8), 160)         return arrayOf(             out.copyOfRange(0, 32),             out.copyOfRange(32, 64),@@ -275,10 +271,7 @@ object WhatsAppProtocol {      * From whatsmeow/download.go getMediaKeys()      */     fun getMediaKeys(mediaKey: ByteArray, mediaType: String): MediaKeys {-        val hkdf = HKDFBytesGenerator(SHA256Digest())-        hkdf.init(HKDFParameters(mediaKey, null, mediaType.toByteArray(Charsets.UTF_8)))-        val expanded = ByteArray(112)-        hkdf.generateBytes(expanded, 0, 112)+        val expanded = hkdfSha256(mediaKey, null, mediaType.toByteArray(Charsets.UTF_8), 112)         return MediaKeys(             iv = expanded.copyOfRange(0, 16),             cipherKey = expanded.copyOfRange(16, 48),@@ -1897,10 +1890,7 @@ object WhatsAppProtocol {             creator.toByteArray(Charsets.UTF_8) +             voter.toByteArray(Charsets.UTF_8) +             "Poll Vote".toByteArray(Charsets.UTF_8)-        val hkdf = HKDFBytesGenerator(SHA256Digest())-        hkdf.init(HKDFParameters(pollSecret, null, info))-        val key = ByteArray(32)-        hkdf.generateBytes(key, 0, 32)+        val key = hkdfSha256(pollSecret, null, info, 32)         val aad = pollMessageId.toByteArray(Charsets.UTF_8) +             byteArrayOf(0) +             voter.toByteArray(Charsets.UTF_8)
passwords/build.gradle.kts
diff --git a/passwords/build.gradle.kts b/passwords/build.gradle.ktsindex e16fac9de2..6b5c5f3f5c 100644--- a/passwords/build.gradle.kts+++ b/passwords/build.gradle.kts@@ -27,8 +27,6 @@ dependencies {     implementation(libs.androidx.credentials.lib)     implementation(libs.androidx.autofill)     implementation(libs.keepassjava2.dom)-    implementation(libs.bouncycastle)-    implementation(libs.bouncycastle.pkix)     implementation(libs.ktor.client.core)     implementation(libs.ktor.client.cio)     implementation(libs.ktor.client.websockets)
passwords/src/main/java/com/vayunmathur/passwords/cable/CableKeys.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/cable/CableKeys.kt b/passwords/src/main/java/com/vayunmathur/passwords/cable/CableKeys.ktindex a818e0f5b2..5f8607bd8a 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/cable/CableKeys.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/cable/CableKeys.kt@@ -1,8 +1,7 @@ package com.vayunmathur.passwords.cable -import org.bouncycastle.crypto.digests.SHA256Digest-import org.bouncycastle.crypto.generators.HKDFBytesGenerator-import org.bouncycastle.crypto.params.HKDFParameters+import javax.crypto.Mac+import javax.crypto.spec.SecretKeySpec  /**  * caBLE v2 key derivations from the 16-byte QR secret.@@ -34,13 +33,40 @@ object CableKeys {     const val PSK_SIZE = 32     const val NONCE_SIZE = 10        // BLE EID nonce -    /** HKDF-SHA256 as used by caBLE. Empty/`null` salt = RFC 5869 zero salt (BoringSSL parity). */+    private const val HMAC = "HmacSHA256"+    private const val HASH_LEN = 32++    /**+     * HKDF-SHA256 (RFC 5869) as used by caBLE, on the platform [Mac] (Conscrypt) —+     * no Bouncy Castle. Empty/`null` salt = RFC 5869 zero salt (BoringSSL parity).+     */     fun hkdf(ikm: ByteArray, salt: ByteArray?, info: ByteArray, length: Int): ByteArray {-        val generator = HKDFBytesGenerator(SHA256Digest())-        generator.init(HKDFParameters(ikm, salt, info))-        return ByteArray(length).also { generator.generateBytes(it, 0, length) }+        require(length <= 255 * HASH_LEN) { "HKDF length too large" }+        // Extract.+        val actualSalt = if (salt == null || salt.isEmpty()) ByteArray(HASH_LEN) else salt+        val prk = hmac(actualSalt, ikm)+        // Expand.+        val out = ByteArray(length)+        var t = ByteArray(0)+        var pos = 0+        var counter = 1+        while (pos < length) {+            val mac = Mac.getInstance(HMAC).apply { init(SecretKeySpec(prk, HMAC)) }+            mac.update(t)+            mac.update(info)+            mac.update(counter.toByte())+            t = mac.doFinal()+            val n = minOf(t.size, length - pos)+            System.arraycopy(t, 0, out, pos, n)+            pos += n+            counter+++        }+        return out     } +    private fun hmac(key: ByteArray, data: ByteArray): ByteArray =+        Mac.getInstance(HMAC).apply { init(SecretKeySpec(key, HMAC)) }.doFinal(data)+     /** Chromium `Derive<N>(secret, salt, purpose)`. */     fun derive(secret: ByteArray, salt: ByteArray?, purpose: Purpose, length: Int): ByteArray =         hkdf(secret, salt, leUint32(purpose.value), length)
passwords/src/main/java/com/vayunmathur/passwords/cable/P256.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/cable/P256.kt b/passwords/src/main/java/com/vayunmathur/passwords/cable/P256.ktindex 34f0455036..a21c2ba85a 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/cable/P256.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/cable/P256.kt@@ -1,20 +1,22 @@ package com.vayunmathur.passwords.cable -import org.bouncycastle.jce.ECNamedCurveTable-import org.bouncycastle.jce.spec.ECNamedCurveSpec import java.math.BigInteger+import java.security.AlgorithmParameters import java.security.KeyFactory import java.security.KeyPair import java.security.KeyPairGenerator import java.security.PrivateKey import java.security.PublicKey import java.security.interfaces.ECPublicKey+import java.security.spec.ECFieldFp import java.security.spec.ECGenParameterSpec+import java.security.spec.ECParameterSpec import java.security.spec.ECPoint import java.security.spec.ECPublicKeySpec  /**  * P-256 (secp256r1 / prime256v1) helpers used by the caBLE Noise handshake and EID handling.+ * Uses only the platform JCA (Conscrypt) — no Bouncy Castle.  *  * Point encodings follow X9.62: compressed = `02|03 || X` (33 bytes), uncompressed =  * `04 || X || Y` (65 bytes). ECDH returns the 32-byte big-endian X coordinate of the shared@@ -26,8 +28,13 @@ object P256 {     const val COORD_SIZE = 32     const val DH_OUTPUT_SIZE = 32 -    private val bcSpec = ECNamedCurveTable.getParameterSpec("secp256r1")-    private val jcaSpec = ECNamedCurveSpec("secp256r1", bcSpec.curve, bcSpec.g, bcSpec.n, bcSpec.h)+    // secp256r1 domain parameters, obtained from the platform (no BC).+    private val ecSpec: ECParameterSpec = run {+        val params = AlgorithmParameters.getInstance("EC")+        params.init(ECGenParameterSpec("secp256r1"))+        params.getParameterSpec(ECParameterSpec::class.java)+    }+    private val prime: BigInteger = (ecSpec.curve.field as ECFieldFp).p      fun generateKeyPair(): KeyPair = KeyPairGenerator.getInstance("EC").run {         initialize(ECGenParameterSpec("secp256r1"))@@ -49,12 +56,35 @@ object P256 {      /** Parses a 33-byte compressed or 65-byte uncompressed point into a [PublicKey]. */     fun decodePoint(encoded: ByteArray): PublicKey {-        val point = bcSpec.curve.decodePoint(encoded).normalize()-        val ecPoint = ECPoint(-            point.affineXCoord.toBigInteger(),-            point.affineYCoord.toBigInteger(),-        )-        return KeyFactory.getInstance("EC").generatePublic(ECPublicKeySpec(ecPoint, jcaSpec))+        val ecPoint = when (encoded[0].toInt() and 0xFF) {+            0x04 -> {+                require(encoded.size == UNCOMPRESSED_SIZE) { "bad uncompressed point" }+                ECPoint(+                    BigInteger(1, encoded.copyOfRange(1, 1 + COORD_SIZE)),+                    BigInteger(1, encoded.copyOfRange(1 + COORD_SIZE, UNCOMPRESSED_SIZE)),+                )+            }+            0x02, 0x03 -> {+                require(encoded.size == COMPRESSED_SIZE) { "bad compressed point" }+                val x = BigInteger(1, encoded.copyOfRange(1, COMPRESSED_SIZE))+                ECPoint(x, decompressY(x, wantOdd = (encoded[0].toInt() and 1) == 1))+            }+            else -> throw IllegalArgumentException("unsupported point encoding")+        }+        return KeyFactory.getInstance("EC").generatePublic(ECPublicKeySpec(ecPoint, ecSpec))+    }++    /**+     * Recover Y from a compressed point: y² = x³ + a·x + b (mod p). secp256r1's p ≡ 3 (mod 4),+     * so y = (rhs)^((p+1)/4) mod p; flip parity to match the requested sign bit.+     */+    private fun decompressY(x: BigInteger, wantOdd: Boolean): BigInteger {+        val a = ecSpec.curve.a+        val b = ecSpec.curve.b+        val rhs = (x.modPow(BigInteger.valueOf(3), prime) + a.multiply(x) + b).mod(prime)+        var y = rhs.modPow((prime + BigInteger.ONE).shiftRight(2), prime)+        if (y.testBit(0) != wantOdd) y = prime.subtract(y)+        return y     }      /** Raw ECDH: returns the 32-byte big-endian X coordinate of `priv * pub`. */
passwords/src/test/java/com/vayunmathur/passwords/cable/CryptoParityTest.kt
diff --git a/passwords/src/test/java/com/vayunmathur/passwords/cable/CryptoParityTest.kt b/passwords/src/test/java/com/vayunmathur/passwords/cable/CryptoParityTest.ktnew file mode 100644index 0000000000..8ec8e7820f--- /dev/null+++ b/passwords/src/test/java/com/vayunmathur/passwords/cable/CryptoParityTest.kt@@ -0,0 +1,69 @@+package com.vayunmathur.passwords.cable++import org.bouncycastle.crypto.digests.SHA256Digest+import org.bouncycastle.crypto.generators.HKDFBytesGenerator+import org.bouncycastle.crypto.params.HKDFParameters+import org.bouncycastle.jce.ECNamedCurveTable+import org.junit.Assert.assertArrayEquals+import org.junit.Assert.assertEquals+import org.junit.Test+import java.security.interfaces.ECPublicKey++/**+ * Verifies the platform-crypto (Conscrypt/SunEC) replacements for the former Bouncy Castle+ * code produce byte-identical results. BC stays on the *test* classpath as the oracle only.+ */+class CryptoParityTest {++    private fun bcHkdf(ikm: ByteArray, salt: ByteArray?, info: ByteArray, len: Int): ByteArray {+        val gen = HKDFBytesGenerator(SHA256Digest())+        gen.init(HKDFParameters(ikm, salt, info))+        return ByteArray(len).also { gen.generateBytes(it, 0, len) }+    }++    @Test+    fun hkdf_matches_bouncycastle() {+        val ikm = ByteArray(16) { it.toByte() }+        val info = "test-info".toByteArray()+        val cases = listOf<ByteArray?>(null, ByteArray(0), "some-salt".toByteArray())+        for (salt in cases) {+            for (len in intArrayOf(10, 16, 32, 64, 100)) {+                assertArrayEquals(+                    "salt=${salt?.size} len=$len",+                    bcHkdf(ikm, salt, info, len),+                    CableKeys.hkdf(ikm, salt, info, len),+                )+            }+        }+    }++    @Test+    fun p256_compressed_decode_matches_bouncycastle() {+        val bcCurve = ECNamedCurveTable.getParameterSpec("secp256r1").curve+        repeat(20) {+            val kp = P256.generateKeyPair()+            val compressed = P256.toCompressed(kp.public)+            // Our decode.+            val mine = P256.decodePoint(compressed) as ECPublicKey+            // BC decode of the same bytes.+            val bc = bcCurve.decodePoint(compressed).normalize()+            assertEquals(bc.affineXCoord.toBigInteger(), mine.w.affineX)+            assertEquals(bc.affineYCoord.toBigInteger(), mine.w.affineY)+            // Round-trip: uncompressed decode too.+            val uncompressed = P256.toUncompressed(kp.public)+            val mine2 = P256.decodePoint(uncompressed) as ECPublicKey+            assertEquals(mine.w.affineX, mine2.w.affineX)+            assertEquals(mine.w.affineY, mine2.w.affineY)+        }+    }++    @Test+    fun p256_ecdh_is_symmetric() {+        val a = P256.generateKeyPair()+        val b = P256.generateKeyPair()+        val ab = P256.ecdh(a.private, P256.decodePoint(P256.toUncompressed(b.public)))+        val ba = P256.ecdh(b.private, P256.decodePoint(P256.toUncompressed(a.public)))+        assertArrayEquals(ab, ba)+        assertEquals(P256.DH_OUTPUT_SIZE, ab.size)+    }+}
photos/src/main/res/values/strings.xml
diff --git a/photos/src/main/res/values/strings.xml b/photos/src/main/res/values/strings.xmlindex 8672c0cf33..4486106c56 100644--- a/photos/src/main/res/values/strings.xml+++ b/photos/src/main/res/values/strings.xml@@ -79,9 +79,9 @@     <string name="apply">Apply</string>     <string name="tap_to_add_points">Tap to add points (%1$s)</string>     <!-- GalleryPage -->-    <string name="of_photos_processed">%1$s% of photos processed</string>-    <string name="photos_indexed_for_visual_search">%1$s / %2$s photos indexed for visual search</string>-    <string name="photos_indexed_for_text_search">%1$s / %2$s photos indexed for text search</string>+    <string name="of_photos_processed">%1$d%% of photos processed</string>+    <string name="photos_indexed_for_visual_search">%1$d / %2$d photos indexed for visual search</string>+    <string name="photos_indexed_for_text_search">%1$d / %2$d photos indexed for text search</string>     <!-- HealingPanel -->     <string name="brush_size">Brush Size</string>     <!-- MainActivity -->