Android instant messaging method and system based on dynamic key management and privacy protection
Through device fingerprint binding and dynamic key rotation mechanism, combined with two-factor authentication and end-to-end encryption, the static key risks and device cloning problems of instant messaging software are solved, and communication security and privacy protection are improved.
Patent Information
- Application Number
- CN202510743391.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-10-03
AI Technical Summary
Existing instant messaging software has risks of static keys, insufficient device binding, lack of key rotation mechanism and privacy leakage, and cannot effectively deal with security threats such as key leakage and device cloning.
It adopts device fingerprint binding, dynamic key rotation and two-factor verification mechanism, generates a unique master key through hash algorithm, dynamically derives session key with timestamp obfuscation mechanism, encrypts information transmission between client and server, sets up blacklist mechanism and end-to-end encrypted transmission.
Significantly improve communication security and privacy protection, prevent keys from being used on other devices, reduce user experience overhead, and prevent data leakage and abuse.
Smart Images

Figure CN120751376A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of mobile communication technology, and in particular to an Android instant messaging method based on dynamic key management and privacy protection, and also to an Android instant messaging system based on dynamic key management and privacy protection. Background Art
[0002] Instant messaging systems have become an indispensable part of social communication. Whether it's work communication, social interaction, or information transmission, IM systems play a vital role. However, with the increasing incidence of privacy breaches and data security issues, how to protect user privacy and manage user permissions while providing convenient services has become a core challenge for IM system developers. The privacy protection and key management methods and problems of existing IM software are as follows:
[0003] Static key risk: Most instant messaging apps use fixed keys (such as the long-term identity key of the Signal protocol). Once the key is leaked, all historical messages can be decrypted.
[0004] Insufficient device binding: Traditional solutions rely on account and password binding to devices, which cannot prevent device cloning attacks (such as extracting keys through Android backups);
[0005] Lack of key rotation mechanism: 90% of instant messaging software do not implement automatic key rotation (data source: OWASP 2023 report), resulting in long-term key validity and increasing security risks;
[0006] Privacy leakage risk: The centralized storage model allows the server to access user data, which may be vulnerable to hacker attacks or abuse by insiders;
[0007] In the existing technology, although some instant messaging software uses end-to-end encryption technology, its key management mechanism still has the above-mentioned defects and cannot effectively deal with security threats such as key leakage and device cloning.
[0008] In view of this, it is necessary to propose an instant messaging method and system that can effectively protect user privacy, manage user permissions, and identify cloned devices. Summary of the Invention
[0009] The purpose of the present invention is to provide an Android instant messaging method and system based on dynamic key management and privacy protection. The method achieves the technical effect of significantly improving communication security and privacy protection levels through device fingerprint binding, dynamic key rotation and two-factor authentication mechanism.
[0010] To achieve the above functions, the present invention designs an Android instant messaging method based on dynamic key management and privacy protection, and executes the following steps S1 to S6 to complete the information transmission between the client and the server:
[0011] Step S1: Collect the client's device hardware fingerprint, generate a unique master key through a hash algorithm, store it on the client, and proceed to step S2;
[0012] Step S2: The master key is called, and based on the timestamp obfuscation mechanism and the preset trigger conditions, the session key is dynamically derived. The client and the server synchronize the currently valid session key and proceed to step S3.
[0013] Step S3: The client encrypts the message body using the session key, appends the device hardware fingerprint hash value, and sends the message to the server, proceeding to step S4;
[0014] Step S4: The server sets up a two-factor authentication mechanism, using the first factor and the second factor respectively to verify the legitimacy of the client sending the information. If the client is not legitimate, the information is intercepted, otherwise step S5 is performed;
[0015] Step S5: The server sets up a blacklist mechanism to verify the legitimacy of the client sending the information. If the client matches the blacklist, the information is intercepted, otherwise step S6 is performed;
[0016] Step S6: The server receives the information sent by the client using an end-to-end encrypted transmission method, encrypts the information, and stores it locally.
[0017] As a preferred technical solution of the present invention: in step S1, the client's device hardware fingerprint is collected, including the device's IMEI code, CPU serial number, and SELinux status hash value; and the master key K_master is generated by the HMAC-SHA256 method.
[0018] As a preferred technical solution of the present invention, the timestamp obfuscation mechanism in step S2 is specifically as follows:
[0019] Divide the system timestamp into time blocks with a granularity of 5 minutes;
[0020] Perform XOR confusion operation on each time block to generate a dynamic salt value Salt for dynamic derivation of session keys;
[0021] The specific steps for dynamically deriving a session key are as follows:
[0022] Step S2.1: When the client sends the first message, it generates a dynamic salt value Salt based on the current timestamp and uses the master key K_master to derive the session key K_session: K_session = HKDF(K_master, Salt, "SESSION");
[0023] Step S2.2: Encrypt the message body using the AES-256-GCM method using the session key K_session, append the hash value of the device hardware fingerprint, and send it to the server;
[0024] Step S2.3: When the client reaches the preset pre-generation condition, it pre-generates the next set of session keys K_session_new and asynchronously synchronizes the next set of session keys K_session_new to the server through the ECDH key exchange protocol;
[0025] Step S2.4: If the client meets the preset trigger condition, it automatically switches to the next set of session keys K_session_new, and the old session key K_session is automatically destroyed after being retained for a preset period of time.
[0026] As a preferred technical solution of the present invention: the preset pre-generation conditions described in step S2.3 include:
[0027] The client sends a total of n messages;
[0028] The current session key K_session has 30 minutes left in continuous use, and the preset duration is greater than 30 minutes.
[0029] The preset trigger conditions described in step S2.4 include:
[0030] The cumulative number of encrypted messages reaches the preset N, where N>n;
[0031] The current session key K_session is used continuously for more than the preset duration;
[0032] If a change in the client device environment or abnormal operation is detected, the next set of session keys K_session_new is immediately generated and triggered.
[0033] As a preferred technical solution of the present invention: in the two-factor authentication mechanism of step S4, the device hardware fingerprint hash value is used as the first factor, which is obtained by taking the first 8 characters after performing SHA-1 digest calculation on the master key K_master, and is attached to the message body when the client sends the message.
[0034] As a preferred technical solution of the present invention: in the two-factor authentication mechanism of step S4, the second factor includes one or more of a text message verification code and a biometric feature.
[0035] As a preferred technical solution of the present invention: the blacklist mechanism in step S5 includes a three-level protection strategy:
[0036] Level 1 interception: triggers secondary verification when the client's device hardware fingerprint hash value does not match;
[0037] Secondary interception: After three consecutive secondary verification failures, the client account will be frozen for 24 hours;
[0038] Level 3 interception: If a client is confirmed to be a cloned device, the client's device hardware fingerprint will be permanently blocked and reported to the Security Center.
[0039] As a preferred technical solution of the present invention: if the client has any one of the following characteristics: abnormal device weak characteristic factors, conflicting behavior patterns, and virtualized device environment, the client is determined to be a cloned device. The specific method is as follows:
[0040] Abnormal device weak signature factors: If the client's device hardware fingerprint deviates from the historical record by more than 70%, the client is determined to be a cloned device;
[0041] Behavior pattern conflict: If the same client's device hardware fingerprint initiates requests at different geofences within a preset time period, the client is determined to be a cloned device;
[0042] Virtualized device environment: If the SDK identifies the client as a customized device environment, the client is determined to be a cloned device.
[0043] As a preferred technical solution of the present invention, the end-to-end encrypted transmission method in step S6 is specifically as follows:
[0044] The client generates a random initialization vector IV;
[0045] Use the current session key K_session to encrypt the message body with AES-6-GCM and generate an authentication tag Tag;
[0046] Send the encrypted message body, authentication tag, and device hardware fingerprint hash value to the server;
[0047] After receiving the information, the server uses the corresponding session key K_session stored locally and the same initialization vector IV to decrypt the information body, and confirms that the information has not been tampered with by verifying the integrity of the authentication tag Tag.
[0048] The present invention also designs an Android instant messaging system based on dynamic key management and privacy protection, which implements the Android instant messaging method based on dynamic key management and privacy protection based on a device fingerprint key generation module, a dynamic session key rotation module, a key verification and synchronization module, and a privacy protection module:
[0049] Device fingerprint key generation module: collects the client's device hardware fingerprint, generates a unique master key through a hash algorithm, and stores it on the client;
[0050] Dynamic session key rotation module: calls the master key and dynamically derives the session key based on the timestamp obfuscation mechanism and preset trigger conditions;
[0051] Key verification and synchronization module: Synchronizes the currently valid session key between the client and the server, and verifies the legitimacy of the client through a two-factor authentication mechanism and a blacklist mechanism on the server;
[0052] Privacy protection module: Use end-to-end encryption to transmit information, encrypt the information, and store it locally.
[0053] Beneficial effects: Compared with the prior art, the advantages of the present invention include:
[0054] 1. Anti-cracking: Dynamic key management ensures that a single crack cannot affect historical messages, significantly improving privacy protection.
[0055] 2. Anti-cloning: Device fingerprint binding makes the key unusable on other devices, preventing 99.2% of backup extraction attacks (measured data);
[0056] 3. Low overhead: Key rotation takes less than 15ms (tested on the Snapdragon 865 platform), with no impact on user experience;
[0057] 4. Privacy protection: End-to-end encryption combined with local storage encryption ensures that user data is not leaked or abused. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 is a flowchart of an Android instant messaging method based on dynamic key management and privacy protection provided in accordance with an embodiment of the present invention;
[0059] Figure 2 2 is a schematic diagram of an Android instant messaging system based on dynamic key management and privacy protection provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention.
[0061] The Android instant messaging method based on dynamic key management and privacy protection provided by the embodiment of the present invention is described in detail. Figure 1 , execute the following steps S1 to S6 to complete the information transmission between the client and the server:
[0062] Step S1: Collect the client's device hardware fingerprint, generate a unique master key through a hash algorithm, store it on the client, and proceed to step S2;
[0063] In step S1, the client's device hardware fingerprint is collected, including the device's IMEI code, CPU serial number, and SELinux status hash value; and the master key K_master is generated using the HMAC-SHA256 method.
[0064] The master key K_master is a 6-bit binary number, typically expressed in hexadecimal notation, a 4-character string. K_master is stored in the Android system's secure enclave and is called only through a secure channel during the dynamic derivation of session keys. The temporary key copy in memory is cleared after each call.
[0065] Step S2: The master key is called, and based on the timestamp obfuscation mechanism and the preset trigger conditions, the session key is dynamically derived. The client and the server synchronize the currently valid session key and proceed to step S3.
[0066] The timestamp obfuscation mechanism in step S2 is as follows:
[0067] Divide the system timestamp into time blocks with a granularity of 5 minutes;
[0068] Perform XOR confusion operation on each time block to generate a dynamic salt value Salt for dynamic derivation of session keys;
[0069] The specific steps for dynamically deriving a session key are as follows:
[0070] Step S2.1: When the client sends the first message, it generates a dynamic salt value Salt based on the current timestamp and uses the master key K_master to derive the session key K_session: K_session = HKDF(K_master, Salt, "SESSION");
[0071] Step S2.2: Encrypt the message body using the AES-256-GCM method using the session key K_session, append the hash value of the device hardware fingerprint, and send it to the server;
[0072] Step S2.3: When the client meets the preset pre-generation conditions, it pre-generates the next set of session keys K_session_new and asynchronously synchronizes the next set of session keys K_session_new to the server through the ECDH (Elliptic Curve Diffie-Hellman key Exchange) key exchange protocol;
[0073] The preset pre-generation conditions include:
[0074] The client sends a total of n messages, which is a preset number. In this embodiment, n is set to 80.
[0075] The current session key K_session is in continuous use for 30 minutes before the preset duration, and the preset duration is greater than 30 minutes.
[0076] Step S2.4: If the client meets the preset trigger condition, the client and the server automatically switch to the next set of session keys K_session_new. The old session key K_session is retained for a preset period of time and is automatically destroyed after being used to decrypt historical information. In this embodiment, the preset period is set to 24 hours or 48 hours.
[0077] The preset trigger conditions include:
[0078] The cumulative number of encrypted messages reaches a preset N, where N>n. In the embodiment, N=100;
[0079] In the embodiment where the current session key K_session is continuously used for a period exceeding a preset time, the preset time is set to 24 hours;
[0080] If a change in the client device environment or abnormal operation is detected, the next set of session keys K_session_new is immediately generated and triggered.
[0081] Step S3: The client encrypts the message body using the session key, appends the device hardware fingerprint hash value, and sends the message to the server, proceeding to step S4;
[0082] Step S4: The server sets up a two-factor authentication mechanism, using the first factor and the second factor respectively to verify the legitimacy of the client sending the information. If the client is not legitimate, the information is intercepted, otherwise step S5 is performed;
[0083] In the two-factor authentication mechanism, the device's hardware fingerprint hash value is used as the first factor. This is obtained by calculating the SHA-1 digest of the master key K_master and taking the first 8 characters. This is then appended to the message body when the client sends the message. The second factor can be a text message verification code or one or more biometric features. If the client is found to be illegal using the first or second factor, the message will be intercepted, the exception log will be recorded, and it will be reported to the security center.
[0084] Step S5: The server sets up a blacklist mechanism to verify the legitimacy of the client sending the information. If the client matches the blacklist, the information is intercepted, otherwise step S6 is performed;
[0085] The blacklist mechanism includes three levels of protection strategies:
[0086] Level 1 interception: When the client's device hardware fingerprint hash value does not match, secondary verification is triggered. That is, the first verification is performed on the device hardware fingerprint hash value of the client sending the message. If the result does not match, the legitimacy of the client is verified again. The verification methods include SMS verification code, biometric recognition, etc.
[0087] Secondary interception: After three consecutive secondary verification failures, the client account will be frozen for 24 hours;
[0088] Level 3 interception: When a client is confirmed to be a cloned device, the client's device hardware fingerprint is permanently blocked, information is intercepted, and abnormal logs are recorded and reported to the security center.
[0089] If a client has any of the following characteristics: abnormal weak device signature factors, conflicting behavior patterns, or virtualized device environment, the client is determined to be a cloned device. The specific method is as follows:
[0090] Abnormal device weak signature factors: If the client's device hardware fingerprint (such as Canvas fingerprint, WebGL fingerprint) deviates from the historical record by more than 70%, the client is determined to be a cloned device;
[0091] Behavior pattern conflict: If the hardware fingerprint of the same client device initiates requests in different geographic fences (such as across provinces) within a preset time period, the client is determined to be a cloned device;
[0092] Virtualized device environment: If the SDK (Software Development Kit) identifies the client as a customized device environment (such as a simulator or automation tool), the client is determined to be a cloned device.
[0093] The above process can be summarized as follows:
[0094] The first device hardware fingerprint verification fails → triggering secondary verification;
[0095] Secondary verification (dynamic code / biometrics) fails 3 times in a row → triggers a 24-hour freeze;
[0096] This mechanism prevents brute force attacks and avoids false positives caused by non-malicious behaviors such as network delays.
[0097] Step S6: The server receives the information sent by the client using an end-to-end encrypted transmission method, encrypts the information, and stores it locally.
[0098] The end-to-end encrypted transmission method is as follows:
[0099] The client generates a random initialization vector IV;
[0100] Use the current session key K_session to encrypt the message body with AES-6-GCM and generate an authentication tag Tag;
[0101] Send the encrypted message body, authentication tag, and device hardware fingerprint hash value to the server;
[0102] After receiving the message, the server uses the corresponding session key K_session stored locally and the same initialization vector IV to decrypt the message body and verify the integrity of the authentication tag to confirm that the message has not been tampered with. This encryption method ensures the confidentiality and integrity of the message during transmission, effectively preventing data leakage and tampering.
[0103] The embodiment of the present invention also provides an Android instant messaging system based on dynamic key management and privacy protection, referring to Figure 2 Based on the device fingerprint key generation module, dynamic session key rotation module, key verification and synchronization module, and privacy protection module, the Android instant messaging method based on dynamic key management and privacy protection is implemented:
[0104] Device fingerprint key generation module: collects the client's device hardware fingerprint, generates a unique master key through a hash algorithm, and stores it on the client;
[0105] Dynamic session key rotation module: calls the master key and dynamically derives the session key based on the timestamp obfuscation mechanism and preset trigger conditions;
[0106] Key verification and synchronization module: Synchronizes the currently valid session key between the client and the server, and verifies the legitimacy of the client through a two-factor authentication mechanism and a blacklist mechanism on the server;
[0107] Privacy protection module: Use end-to-end encryption to transmit information, encrypt the information, and store it locally.
[0108] The embodiments of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Various changes can be made within the scope of knowledge possessed by ordinary technicians in this field without departing from the spirit of the present invention.
Claims
1. An Android instant messaging method based on dynamic key management and privacy protection, characterized in that: Execute the following steps S1 to S6 to complete the information transmission between the client and the server: Step S1: Collect the client's device hardware fingerprint, generate a unique master key through a hash algorithm, store it on the client, and proceed to step S2; Step S2: The master key is called, and based on the timestamp obfuscation mechanism and the preset trigger conditions, the session key is dynamically derived. The client and the server synchronize the currently valid session key and proceed to step S3. Step S3: The client encrypts the message body using the session key, appends the device hardware fingerprint hash value, and sends the message to the server, proceeding to step S4; Step S4: The server sets up a two-factor authentication mechanism, using the first factor and the second factor respectively to verify the legitimacy of the client sending the information. If the client is not legitimate, the information is intercepted, otherwise step S5 is performed; Step S5: The server sets up a blacklist mechanism to verify the legitimacy of the client sending the information. If the client matches the blacklist, the information is intercepted, otherwise step S6 is performed; Step S6: The server receives the information sent by the client using an end-to-end encrypted transmission method, encrypts the information, and stores it locally.
2. The Android instant messaging method based on dynamic key management and privacy protection according to claim 1, characterized in that: In step S1, the client's device hardware fingerprint is collected, including the device's IMEI code, CPU serial number, and SELinux status hash value; and the master key K_master is generated using the HMAC-SHA256 method.
3. The Android instant messaging method based on dynamic key management and privacy protection according to claim 1, characterized in that: The timestamp obfuscation mechanism in step S2 is as follows: Divide the system timestamp into time blocks with a granularity of 5 minutes; Perform XOR confusion operation on each time block to generate a dynamic salt value Salt for dynamic derivation of session keys; The specific steps for dynamically deriving a session key are as follows: Step S2.1: When the client sends the first message, it generates a dynamic salt value Salt based on the current timestamp and uses the master key K_master to derive the session key K_session: K_session = HKDF(K_master, Salt, "SESSION"); Step S2.2: Encrypt the message body using the AES-256-GCM method using the session key K_session, append the hash value of the device hardware fingerprint, and send it to the server; Step S2.3: When the client reaches the preset pre-generation condition, it pre-generates the next set of session keys K_session_new and asynchronously synchronizes the next set of session keys K_session_new to the server through the ECDH key exchange protocol; Step S2.4: If the client meets the preset trigger condition, it automatically switches to the next set of session keys K_session_new, and the old session key K_session is automatically destroyed after being retained for a preset period of time.
4. The Android instant messaging method based on dynamic key management and privacy protection according to claim 3, characterized in that: The preset pre-generation conditions described in step S2.3 include: The client sends a total of n messages; The current session key K_session has 30 minutes left in continuous use, and the preset duration is greater than 30 minutes. The preset trigger conditions described in step S2.4 include: The cumulative number of encrypted messages reaches the preset N, where N>n; The current session key K_session is used continuously for more than the preset duration; If a change in the client device environment or abnormal operation is detected, the next set of session keys K_session_new is immediately generated and triggered.
5. The Android instant messaging method based on dynamic key management and privacy protection according to claim 1, characterized in that: In the two-factor authentication mechanism of step S4, the device hardware fingerprint hash value is used as the first factor. It is obtained by taking the first 8 characters after performing SHA-1 digest calculation on the master key K_master and appended to the message body when the client sends the message.
6. The Android instant messaging method based on dynamic key management and privacy protection according to claim 1, characterized in that: In the two-factor authentication mechanism of step S4, the second factor includes one or more of a text message verification code and a biometric feature.
7. The Android instant messaging method based on dynamic key management and privacy protection according to claim 1, characterized in that: The blacklist mechanism in step S5 includes three levels of protection strategies: Level 1 interception: triggers secondary verification when the client's device hardware fingerprint hash value does not match; Secondary interception: After three consecutive secondary verification failures, the client account will be frozen for 24 hours; Level 3 interception: If a client is confirmed to be a cloned device, the client's device hardware fingerprint will be permanently blocked and reported to the Security Center.
8. The Android instant messaging method based on dynamic key management and privacy protection according to claim 7, characterized in that: If a client has any of the following characteristics: abnormal weak device signature factors, conflicting behavior patterns, or virtualized device environment, the client is determined to be a cloned device. The specific method is as follows: Abnormal device weak signature factors: If the client's device hardware fingerprint deviates from the historical record by more than 70%, the client is determined to be a cloned device; Behavior pattern conflict: If the same client's device hardware fingerprint initiates requests at different geofences within a preset time period, the client is determined to be a cloned device; Virtualized device environment: If the SDK identifies the client as a customized device environment, the client is determined to be a cloned device.
9. The Android instant messaging method based on dynamic key management and privacy protection according to claim 1, characterized in that: The end-to-end encrypted transmission method in step S6 is specifically as follows: The client generates a random initialization vector IV; Use the current session key K_session to encrypt the message body with AES-6-GCM and generate an authentication tag Tag; Send the encrypted message body, authentication tag, and device hardware fingerprint hash value to the server; After receiving the information, the server uses the corresponding session key K_session stored locally and the same initialization vector IV to decrypt the information body, and confirms that the information has not been tampered with by verifying the integrity of the authentication tag Tag.
10. An Android instant messaging system based on dynamic key management and privacy protection, characterized in that: Based on the device fingerprint key generation module, the dynamic session key rotation module, the key verification and synchronization module, and the privacy protection module, the Android instant messaging method based on dynamic key management and privacy protection as described in any one of claims 1 to 9 is implemented: Device fingerprint key generation module: collects the client's device hardware fingerprint, generates a unique master key through a hash algorithm, and stores it on the client; Dynamic session key rotation module: calls the master key and dynamically derives the session key based on the timestamp obfuscation mechanism and preset trigger conditions; Key verification and synchronization module: Synchronizes the currently valid session key between the client and the server, and verifies the legitimacy of the client through a two-factor authentication mechanism and a blacklist mechanism on the server; Privacy protection module: Use end-to-end encryption to transmit information, encrypt the information, and store it locally.
Citation Information
Cited By
KNX system instruction encryption method and KNX system target device instruction execution method
CN122316799A