Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / communicate-dev / src / main / java / com / vayunmathur / communicate / data / whatsapp / registration / WhatsAppRegistrationConstants.kt
WhatsAppRegistrationConstants.kt83 lines · 4.0 KiBRaw
| 1 | package com.vayunmathur.communicate.data.whatsapp.registration |
| 2 | |
| 3 | /** |
| 4 | * Pinned constants for WhatsApp primary-client registration attestation. |
| 5 | * |
| 6 | * ⚠️ ALL of these are recovered from ONE specific WhatsApp APK build and must stay in sync: |
| 7 | * apk-analysis/whatsapp — versionName 2.26.29.73, versionCode 262907320. |
| 8 | * |
| 9 | * The registration `token` (see [RegistrationAttestation.computeToken]) binds: |
| 10 | * - the app package name ("com.whatsapp"), |
| 11 | * - the app's `about_logo.png` bytes (bundled at assets/whatsapp/about_logo.png), |
| 12 | * - the app signing certificate DER (bundled at assets/whatsapp/signing_cert.der), |
| 13 | * - MD5(classes.dex) of the pinned APK ([CLASSES_DEX_MD5_HEX]), |
| 14 | * so if you re-pin to a newer APK you MUST re-extract the logo, cert, dex MD5 and update |
| 15 | * [WhatsAppProtocol.WA_VERSION]/[WA_VERSION_NAME]. |
| 16 | * |
| 17 | * Evidence: p000X/C34029EuU.java (token), p000X/ES3.java (salt), p000X/ES4.java (server pubkey), |
| 18 | * core/http/retry/RetryingHttpClient.java (ENC/H). See communicate/whatsapp-documentation.md. |
| 19 | */ |
| 20 | object WhatsAppRegistrationConstants { |
| 21 | |
| 22 | /** Official WhatsApp package name — first component of the token password. */ |
| 23 | const val PACKAGE_NAME = "com.whatsapp" |
| 24 | |
| 25 | /** PBKDF2 salt, Base64 (p000X/ES3.java:7). */ |
| 26 | const val TOKEN_SALT_B64 = |
| 27 | "PkTwKSZqUfAUyR0rPQ8hYJ0wNsQQ3dW1+3SCnyTXIfEAxxS75FwkDf47wNv/c8pP3p0GXKR6OOQmhyERwx74fw1RYSU10I4r1gy" + |
| 28 | "BVDbRJ40pidjM41G1I1oN" |
| 29 | |
| 30 | /** PBKDF2 iteration count (C34029EuU.A01 → C00L.A08 arg 128). */ |
| 31 | const val TOKEN_PBKDF2_ITERATIONS = 128 |
| 32 | |
| 33 | /** PBKDF2 derived-key length in BITS (C00L.A08 arg 512). */ |
| 34 | const val TOKEN_PBKDF2_KEYLEN_BITS = 512 |
| 35 | |
| 36 | /** MD5(classes.dex) of the pinned base.apk, lower-case hex (16 bytes). */ |
| 37 | const val CLASSES_DEX_MD5_HEX = "eda19e0c342f17d7aae9ae5e4d50e439" |
| 38 | |
| 39 | /** |
| 40 | * Official-identity values for the `_gi` device-integrity blob, so it describes the REAL |
| 41 | * WhatsApp app rather than this client. Extracted from the SAME pinned APK as everything else |
| 42 | * (com.whatsapp base.apk, versionName 2.26.29.73 / versionCode 262907320, pulled from the device |
| 43 | * via `adb pull` — NOT committed). Keep in sync with [CLASSES_DEX_MD5_HEX], the bundled |
| 44 | * signing cert + about_logo.png, and [WhatsAppProtocol.WA_VERSION] (all one APK). |
| 45 | */ |
| 46 | const val OFFICIAL_APK_SHA256_B64 = "38wasuL4WBcWVxf5K0p6dc6ELF+OvBqshecYAn1awkM=" |
| 47 | |
| 48 | /** Official com.whatsapp base.apk size in bytes (same pinned APK), for the `_gi` blob. */ |
| 49 | const val OFFICIAL_APK_SIZE = 120328807L |
| 50 | |
| 51 | /** Canonical official install path for the `_gi` blob (the real path is per-install random). */ |
| 52 | const val OFFICIAL_SOURCE_DIR = "/data/app/com.whatsapp/base.apk" |
| 53 | |
| 54 | /** Registration server static X25519 public key, hex (p000X/ES4.java). Used by the ENC wrapper. */ |
| 55 | const val REG_SERVER_X25519_PUBKEY_HEX = |
| 56 | "8e8c0f74c3ebc5d7a6865c6c3c843856b06121cce8ea774d22fb6f122512302d" |
| 57 | |
| 58 | /** Bundled asset paths. */ |
| 59 | const val ASSET_ABOUT_LOGO = "whatsapp/about_logo.png" |
| 60 | const val ASSET_SIGNING_CERT_DER = "whatsapp/signing_cert.der" |
| 61 | |
| 62 | /** Registration REST host. Endpoints live under https://<host>/v2/ endpoints . */ |
| 63 | const val REG_HOST = "v.whatsapp.net" |
| 64 | |
| 65 | fun endpoint(path: String): String = "https://$REG_HOST/v2/$path" |
| 66 | |
| 67 | /** e_keytype for Curve25519 (djb type). */ |
| 68 | const val KEY_TYPE_CURVE25519: Byte = 0x05 |
| 69 | |
| 70 | /** |
| 71 | * Key type byte for the post-quantum (Kyber1024 / ML-KEM) last-resort prekey. Mirrors the |
| 72 | * curve25519 `0x05` type-byte convention: the PQ signed-prekey signature is computed over |
| 73 | * `0x08 || pqPublicKey` (see [RegistrationKeys]/`WhatsAppPqPreKey`). Ref w2.md §2.1 |
| 74 | * (`e_pq_last_resort_sig` = `Ed25519(sign(e_ident+0x08+e_pq_val))`). |
| 75 | */ |
| 76 | const val KEY_TYPE_KYBER: Byte = 0x08 |
| 77 | |
| 78 | /** The fixed id assigned to our single PQ last-resort prekey (3B BE on the wire). */ |
| 79 | const val PQ_LAST_RESORT_KEY_ID = 1 |
| 80 | |
| 81 | /** Expected Kyber1024 public key length in bytes (`e_pq_last_resort_val`, w2.md §2.1). */ |
| 82 | const val PQ_KYBER1024_PUBLIC_LEN = 1568 |
| 83 | } |