A method and apparatus for security protection of Unity AssetBundles based on dynamic key management and multi-layer encryption.
By employing dynamic key management and multi-layered encryption, the security issues of Unity AssetBundle files are resolved, achieving a balance between high security and good performance, making it suitable for protecting AssetBundle files in the Unity engine.
Patent Information
- Application Number
- CN202611246572.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, Unity AssetBundle files have security weaknesses, are easily parsed and stolen, and it is difficult to strike a balance between ensuring high encryption strength, maintaining good performance, and achieving dynamic and secure key management.
A method based on dynamic key management and multi-layer encryption is adopted. Dynamic keys are generated through a key management server, and the client detects the network status to perform encrypted communication or local decryption. Combined with AES algorithm and LZ4 compression, the security and performance of AssetBundle files are ensured.
It effectively avoids resource cracking caused by static key leakage, balances high online security with offline availability, maintains compatibility with the Unity engine's native loading mechanism, and provides end-to-end security protection.
Smart Images

Figure CN123122890A_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of data encryption technology, and in particular to a security protection method for Unity AssetBundle based on dynamic key management and multi-layer encryption. Background Technology
[0002] In Unity engine game development, AssetBundles (AB packages) are a core technology for dynamic resource loading and hot reloading. They allow developers to bundle resources (such as models, textures, audio, configurations, etc.) and load them when needed, effectively controlling the initial application size and supporting content updates. However, the standard AssetBundle system has inherent weaknesses in terms of security. The bundled AB package files are typically stored in a read-write path within the application (such as StreamingAssets), making them easily accessible to end users.
[0003] These unencrypted or simply encrypted AB packages can be easily parsed and extracted by specialized tools such as AssetStudio. This can lead to the illegal acquisition, alteration, or direct theft of core game art assets, script logic, and even trade secrets, severely infringing on the developer's intellectual property rights. Furthermore, it can potentially disrupt the game's fairness through cheats (such as model modification for perspective), ultimately impacting the developer's revenue. Therefore, encrypting AB packages has become a necessary security measure for game launch.
[0004] Several AB package encryption schemes already exist in the technology. For example, some schemes use XOR operations on the entire AB package or symmetric encryption algorithms such as AES for encryption. Unity also provides built-in encryption support, setting the key using `BuildPipeline.SetAssetBundleEncryptKey` during build and decrypting using `AssetBundle.SetAssetBundleDecryptKey` during loading, but this method usually uses a fixed key. In addition, some methods use offset encryption or encrypt specific parts such as the file header. These methods increase the difficulty of cracking resources to some extent. However, it is difficult to achieve an effective balance between ensuring high encryption strength, maintaining good operational performance, implementing dynamic and secure key management, and adapting to complex network environments.
[0005] Therefore, a better solution is urgently needed. Summary of the Invention
[0006] In view of this, embodiments of this specification provide a security protection method for Unity AssetBundles based on dynamic key management and multi-layer encryption. One or more embodiments of this specification also relate to a security protection device for Unity AssetBundles based on dynamic key management and multi-layer encryption, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.
[0007] According to a first aspect of the embodiments of this specification, a method for security protection of Unity AssetBundles based on dynamic key management and multi-layer encryption is provided, including: The key management server generates dynamic keys; The client requests a dynamic key from the key management server via encrypted communication and receives the dynamic key issued by the key management server. The client checks the network connectivity status. If a network connection exists, it uses the received dynamic key as the decryption key. If no network connection exists, it decrypts the data from the local encryption keybook to obtain the preset general key as the decryption key. The client uses the decryption key to load the encrypted AssetBundle file.
[0008] In one possible implementation, encrypted communication is based on the HTTPS protocol, or encrypted communication is based on a pre-configured asymmetric encryption public key on the client. The key management server encrypts the dynamic key using the asymmetric encryption public key and then distributes it. The client decrypts the dynamic key using the private key corresponding to the asymmetric encryption public key.
[0009] In one possible implementation, the local encryption key is encrypted and stored during the client packaging stage. The encryption protection method of the local encryption key is symmetric encryption or asymmetric encryption. The local encryption key contains at least one preset general key, which is used as a decryption key when the client has no network connection.
[0010] In one possible implementation, the encrypted AssetBundle file is encrypted using the AES algorithm with CBC mode, PKCS7 padding, and a 128-bit key length.
[0011] In one possible implementation, the process of the client loading the encrypted AssetBundle file using the decryption key is implemented through the AssetBundle.LoadFromFile interface provided by the Unity engine, or the client downloads the encrypted AssetBundle file through UnityWebRequestAssetBundle and then loads it using the decryption key.
[0012] In one possible implementation, the encrypted AssetBundle file is compressed using the LZ4 compression format during the build phase before being encrypted.
[0013] In one possible implementation, the key management server sets an expiration date for the dynamic key, and the client requests a new dynamic key from the key management server after the dynamic key expires; or the key management server adds the dynamic key to a blacklist after detecting a dynamic key leak and refuses access to the latest resources to clients using the blacklisted dynamic key.
[0014] According to a second aspect of the embodiments of this specification, a Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption is provided, comprising: The key generation module is configured to generate dynamic keys for the key management server. The key distribution module is configured so that the client requests a dynamic key from the key management server via encrypted communication and receives the dynamic key distributed by the key management server. The key determination module is configured to detect network connectivity status on the client side. If a network connection exists, the received dynamic key is used as the decryption key. If no network connection exists, the preset general key is obtained from the local encryption keybook and used as the decryption key. The file loading module is configured so that the client can load encrypted AssetBundle files using a decryption key.
[0015] According to a third aspect of the embodiments of this specification, a computing device is provided, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the above-described Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption.
[0016] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the above-described UnityAssetBundle security protection method based on dynamic key management and multi-layer encryption.
[0017] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described UnityAssetBundle security protection method based on dynamic key management and multi-layer encryption.
[0018] This specification provides a method and apparatus for security protection of Unity AssetBundles based on dynamic key management and multi-layer encryption. The method includes: a key management server generating a dynamic key; a client requesting and receiving the dynamic key via encrypted communication; the client detecting network status, using the dynamic key as the decryption key when connected to the network, and obtaining a preset universal key from a local encryption keybook when offline; and the client using the decryption key to load the encrypted AssetBundle file. This application constructs a multi-layered defense-in-depth system through a dynamic key distribution and update mechanism, end-to-end encrypted communication, and offline security degradation, effectively avoiding resource breaches caused by static key leakage, balancing high online security with offline availability, and maintaining good compatibility with the Unity engine's native loading mechanism. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating a UnityAssetBundle security protection method based on dynamic key management and multi-layer encryption, provided in one embodiment of this specification. Figure 2 This is a schematic diagram of a UnityAssetBundle security protection method based on dynamic key management and multi-layer encryption, provided in one embodiment of this specification. Figure 3 This is a schematic diagram of a UnityAssetBundle security protection device based on dynamic key management and multi-layer encryption, provided in one embodiment of this specification. Figure 4 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0020] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0021] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0022] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0023] This specification provides a method for protecting Unity AssetBundles based on dynamic key management and multi-layer encryption. This specification also relates to a device for protecting Unity AssetBundles based on dynamic key management and multi-layer encryption, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0024] See Figure 1 , Figure 1 A flowchart is shown of a Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to an embodiment of this specification, which specifically includes the following steps.
[0025] Step 101: The key management server generates a dynamic key; Step 102: The client requests a dynamic key from the key management server via encrypted communication and receives the dynamic key issued by the key management server; Step 103: The client checks the network connectivity status. If a network connection exists, the received dynamic key is used as the decryption key. If no network connection exists, the client decrypts the password from the local encryption keybook to obtain the preset general key as the decryption key. Step 104: The client uses the decryption key to load the encrypted AssetBundle file.
[0026] Dynamic keys refer to symmetric encryption keys that are generated on-demand or periodically on the server side, possessing time-limited or unique characteristics. For example, a 128-bit key generated using the AES algorithm is used for encrypting and decrypting Unity AssetBundle files. Encrypted communication refers to the secure channel used between the client and the key management server to transmit dynamic keys. This channel can be built based on the HTTPS protocol or asymmetric encryption mechanisms to prevent keys from being stolen or tampered with by third parties during transmission. A local encrypted keybook refers to a data file pre-stored on the client's local machine and protected by encryption. It contains at least one pre-set universal key for offline scenarios, and the encryption method can be symmetric or asymmetric. Encrypted AssetBundle files refer to Unity resource bundle files that have been processed by encryption algorithms such as AES and cannot be directly parsed by general resource extraction tools. They undergo encryption during the build phase and are uploaded to the content delivery network for client download.
[0027] In a detailed embodiment, this method is used in a Unity game project to secure AssetBundle resources. During the resource building phase, the developer first configures the AssetBundle build pipeline in the Unity editor and selects the LZ4 compression format to improve loading efficiency. After the build is complete, the developer uses an encryption tool to encrypt the generated AssetBundle file and its manifest file using AES. The encryption key can be a dynamically obtained key from a key management server or a pre-set universal key in a local cryptographic book as a temporary encryption basis.
[0028] The key management server is deployed independently in a public network environment. This server has the functions of key generation, storage, and distribution. When the server receives a legitimate request from a client, it generates a new AES key as a dynamic key using a secure random number generator, and records this key in the database along with information such as the client identifier and generation timestamp for auditing purposes.
[0029] The game client automatically performs a network connectivity check upon startup. Specifically, the client determines whether the current device has internet access capability by sending a lightweight probe packet to a preset connectivity test address. If a normal network connection is detected, the client initiates a request to the key management server to obtain a dynamic key via encrypted communication. This encrypted communication uses HTTPS protocol for transport layer encryption, ensuring that the request parameters and the dynamic key returned by the server are not exposed in plaintext during transmission. After verifying the client's identity, the server returns the newly generated dynamic key in JSON format, and the client obtains the plaintext dynamic key by parsing the response data.
[0030] If the client detects no network connection, it proceeds to the local degradation process. The client reads a local encrypted passwordbook file stored in the application's private directory. This file was encrypted using a fixed symmetric key during the application packaging stage. The client decrypts the passwordbook using a preset decryption key, extracts a preset universal key, and uses this universal key as the decryption key for this resource loading.
[0031] After obtaining the decryption key, the client calls the corresponding interface provided by the Unity engine, depending on the resource acquisition method. For encrypted AssetBundle files pre-downloaded to local storage, the client calls the AssetBundle.LoadFromFile interface, passing in the decryption key parameter. The Unity engine automatically uses this key to decrypt the encrypted content when reading file data at the underlying level and loads the decrypted resource data into memory for use by the game logic. For encrypted AssetBundle files that need to be downloaded from the network in real time, the client uses UnityWebRequestAssetBundle to initiate a download request. After the download is complete, the decryption and loading operations are also completed using the passed decryption key. Throughout the entire process, the decryption key exists only in memory and is not written to persistent storage in plaintext, further reducing the risk of key leakage.
[0032] The beneficial effects of this embodiment are as follows: By introducing a server-side dynamic key generation and distribution mechanism, the decryption key for AssetBundle resources is no longer fixed in the client code, thus effectively avoiding the problem of full resource cracking caused by the reverse extraction of static keys. Simultaneously, the intelligent switching logic between online dynamic keys and offline universal keys ensures the game's availability in offline environments, balancing high security and user experience. Encrypted communication ensures the confidentiality of the dynamic key during transmission, forming end-to-end security protection from the key source to resource loading.
[0033] In one possible implementation, encrypted communication is based on the HTTPS protocol, or encrypted communication is based on a pre-configured asymmetric encryption public key on the client. The key management server encrypts the dynamic key using the asymmetric encryption public key and then distributes it. The client decrypts the dynamic key using the private key corresponding to the asymmetric encryption public key.
[0034] HTTPS stands for Hypertext Transfer Security, a protocol based on Transport Layer Security. It encrypts and verifies the integrity of communication content at the transport layer to prevent data from being eavesdropped on or tampered with during transmission. An asymmetric encryption public key refers to the public portion of an asymmetric key pair, which can be used to encrypt data, but only the holder of the corresponding private key can decrypt it. Pre-installed asymmetric encryption public keys on the client can be embedded in the client code or resource files during application compilation and obfuscated to increase the difficulty of extraction.
[0035] Building upon the foregoing embodiments, this embodiment further defines the specific implementation of encrypted communication. In one implementation, all communication between the client and the key management server is based on the HTTPS protocol. When initiating a dynamic key request, the client constructs an HTTPS POST request, the request body of which includes necessary client identification information and verification fields. The server-side web service is configured with a valid digital certificate, and the client verifies the legitimacy of the server certificate when establishing a connection, thereby preventing man-in-the-middle attacks. The dynamic key generated by the server is returned in encrypted form via an HTTPS response body, and the client obtains the plaintext dynamic key upon receiving it.
[0036] In another implementation, key transmission between the client and server employs an application-layer asymmetric encryption mechanism. Specifically, the client embeds an RSA key pair during application packaging. The public key is distributed with the client, while the private key, after code obfuscation and integrity verification, is stored in a secure area on the client. When the client requests a dynamic key, it first encrypts certain sensitive fields in the request message using the pre-set public key and sends the encrypted request to the key management server. Upon receiving the request, the server uses the pre-set public key to encrypt the dynamic key to be issued, generating a ciphertext dynamic key. After receiving the response, the client decrypts the ciphertext dynamic key using its built-in private key, restoring the plaintext dynamic key. This method ensures that even if the transport layer is monitored by a third party, the plaintext of the dynamic key will not be exposed, further enhancing the security of key transmission.
[0037] The advantages of this embodiment are as follows: by clearly defining two optional implementation methods for encrypted communication, it provides flexible choices for game projects with different security level requirements. HTTPS is simple to implement and has good compatibility; asymmetric encryption provides additional application-layer encryption protection on top of transport layer security. Even if the transport layer encryption is breached in extreme cases, the confidentiality of the dynamic key can still be effectively maintained. Both methods can effectively prevent the key from being stolen during transmission.
[0038] In one possible implementation, the local encryption key is encrypted and stored during the client packaging stage. The encryption protection method of the local encryption key is symmetric encryption or asymmetric encryption. The local encryption key contains at least one preset general key, which is used as a decryption key when the client has no network connection.
[0039] Symmetric encryption refers to encryption algorithms that use the same key for both encryption and decryption, such as AES and DES, and is characterized by fast encryption and decryption speeds. Asymmetric encryption refers to encryption algorithms that use different keys for encryption and decryption, such as RSA and ECC, where the public key is used for encryption and the private key is used for decryption. The pre-set universal key in the local encryption keybook is a backup key used in offline environments to replace the dynamic key. This key is written into the keybook before the application is released and can be changed with application version updates.
[0040] Building upon the foregoing embodiments, this embodiment details the storage and protection mechanism of the local encrypted codebook. During the client-side packaging stage, developers use encryption tools to encrypt the codebook file containing a pre-defined universal key. If symmetric encryption is used, the developer sets a fixed codebook encryption key, which is hidden in the client-side code using techniques such as string obfuscation and segmented storage. The packaging script reads the original plaintext codebook file, performs AES encryption using the fixed key to generate an encrypted codebook file, and places it in the StreamingAssets directory of the Unity project for distribution with the application.
[0041] If asymmetric encryption is used, the developer encrypts the codebook file using the client's built-in asymmetric public key, while the corresponding private key is also securely stored within the client. When the client needs to read the codebook at runtime, it uses the corresponding decryption key (symmetric key or asymmetric private key) to decrypt the ciphertext codebook, obtaining the plaintext content containing the pre-set universal key.
[0042] The codebook stores at least one pre-set universal key, which is itself in AES key format. When the game needs to update the universal key, the key can be replaced by releasing an application version update that includes the new codebook file, thereby reducing the security risks caused by using the same universal key for a long time.
[0043] When the client detects no network connection, it calls the password book decryption logic to obtain the preset general key, and uses it as the decryption key to load the encrypted AssetBundle file according to the aforementioned process.
[0044] The beneficial effects of this embodiment are as follows: By encrypting and storing the local encrypted codebook, attackers are effectively prevented from obtaining the universal key by directly reading the codebook file. Even if the client installation package is unpacked and analyzed, attackers still need to overcome the encryption protection of the codebook itself to obtain the universal key, thereby improving the resource security level in offline scenarios. Furthermore, the codebook supports changing the universal key with version updates, providing continuous offline security for long-term game operation.
[0045] In one possible implementation, the encrypted AssetBundle file is encrypted using the AES algorithm with CBC mode, PKCS7 padding, and a 128-bit key length.
[0046] AES stands for Advanced Encryption Standard, a widely used symmetric block cipher algorithm. CBC mode refers to Cipher Block Chaining, which XORs each plaintext block with the previous ciphertext block before encrypting it, thus producing different ciphertext blocks for the same plaintext block, enhancing encryption strength. PKCS7 padding is a standard padding method that aligns the plaintext length to block boundaries by padding with specific bytes when the plaintext length is not an integer multiple of the block size. The 128-bit key length refers to the 128-bit key used in the AES algorithm, achieving a good balance between security and encryption / decryption efficiency.
[0047] Building upon the aforementioned embodiments, this embodiment clarifies the specific parameters of the encryption algorithm for AssetBundle files. During the resource construction encryption phase, the encryption tool reads the binary data stream of the original AssetBundle file. The tool initializes the AES encryptor, specifying the encryption mode as CBC mode, the padding method as PKCS7, and the key length as 128 bits. The encryption tool uses a currently valid encryption key (dynamic key or general key) and a randomly generated initialization vector to encrypt the file data. The encrypted data consists of two parts: the initialization vector and the ciphertext data. The initialization vector is appended to the header of the ciphertext data in plaintext form for use during decryption.
[0048] When the client loads an encrypted AssetBundle file, it extracts the initialization vector from the file header and initializes the decryptor using the decryption key and the same AES algorithm parameters (CBC mode, PKCS7 padding). At the Unity engine's underlying level, while reading file data, the decryptor decrypts the ciphertext data and submits the decrypted plaintext data stream to the AssetBundle loader for parsing. Due to the use of CBC mode and a random initialization vector, even if two AssetBundle files are encrypted with the same key, their final ciphertext will be different, effectively resisting ciphertext analysis attacks.
[0049] The beneficial effects of this embodiment are as follows: by employing a standardized and sufficiently strong AES encryption algorithm, combined with CBC mode and PKCS7 padding, the confidentiality of the AssetBundle file during storage and transmission is ensured. The use of CBC mode eliminates the risk of plaintext leakage, and the randomization of the initialization vector enhances resistance to ciphertext analysis. The 128-bit key has sufficient security strength under current computing power, while ensuring efficient execution of encryption and decryption operations on mobile devices without significantly impacting game loading performance.
[0050] In one possible implementation, the process of the client loading the encrypted AssetBundle file using the decryption key is implemented through the AssetBundle.LoadFromFile interface provided by the Unity engine, or the client downloads the encrypted AssetBundle file through UnityWebRequestAssetBundle and then loads it using the decryption key.
[0051] Among them, `AssetBundle.LoadFromFile` is an efficient interface provided by the Unity engine for loading AssetBundle files from local storage. This interface supports directly passing in decryption key parameters, allowing the engine to perform streaming decryption while reading the file, avoiding loading the entire encrypted file into memory at once. `UnityWebRequestAssetBundle` is a dedicated interface provided by the Unity engine for downloading AssetBundle files from the network. It integrates download management and caching mechanisms and also supports decryption key parameters to achieve on-the-fly decryption functionality.
[0052] Building upon the aforementioned embodiments, this embodiment specifies the API call method for loading encrypted AssetBundle files by the client. In one implementation scenario, the encrypted AssetBundle file has been pre-downloaded to the client's persistent path via a hot update process. After obtaining the decryption key, the client calls the AssetBundle.LoadFromFile method, passing in the file path and decryption key parameters. The Unity engine, after opening the file, reads the file data in a streaming manner. Each data block read is decrypted using the decryption key and preset AES decryption parameters. The decrypted data is directly used to construct the AssetBundle object. This method's memory usage is only related to the size of the read buffer and does not generate peak memory overhead from reading the entire encrypted file into memory and then decrypting it, making it particularly suitable for mobile devices.
[0053] In another implementation scenario, the encrypted AssetBundle file is stored on a remote content delivery network server, and the client has not yet downloaded it. After obtaining the decryption key, the client creates a UnityWebRequestAssetBundle instance and specifies the download address and decryption key parameters. The client initiates an asynchronous download operation, and the Unity engine decrypts the data packets while receiving them, gradually filling the AssetBundle loading buffer with the decrypted data. After the download is complete, the client retrieves the loaded AssetBundle object through the DownloadHandlerAssetBundle property of UnityWebRequestAssetBundle. This method achieves parallel processing of download and decryption, further reducing waiting time.
[0054] The advantages of this embodiment are as follows: it fully utilizes the native AssetBundle loading interface provided by the Unity engine to support decryption keys, enabling seamless integration of the encryption scheme into the existing resource loading pipeline. The streaming decryption feature of the AssetBundle.LoadFromFile interface significantly reduces memory spikes and avoids stuttering issues caused by overall decryption. UnityWebRequestAssetBundle enables simultaneous network download and decryption, optimizing the user experience in hot update scenarios. The compatibility of the two interfaces ensures that this method can run stably and efficiently under various resource distribution modes.
[0055] In one possible implementation, the encrypted AssetBundle file is compressed using the LZ4 compression format during the build phase before being encrypted.
[0056] LZ4 compression is a lossless compression algorithm with extremely high compression and decompression speeds, making it particularly suitable for game resource loading scenarios that require real-time decompression. The Unity engine supports selecting LZ4 compression when building AssetBundles. This method compresses data in blocks, allowing only the necessary data blocks to be decompressed during loading, thus achieving on-demand reading and memory savings.
[0057] Building upon the foregoing embodiments, this embodiment further specifies the compression format selection during AssetBundle construction. In the Unity editor's AssetBundle build configuration, the developer sets the compression option to ChunkBasedCompression, which corresponds to the LZ4 compression algorithm. The build pipeline first organizes the resource data into the internal AssetBundle format, then uses the LZ4 algorithm to compress the data blocks, generating the compressed AssetBundle file.
[0058] Subsequently, the encryption tool reads the compressed AssetBundle file and encrypts the entire file according to the aforementioned AES encryption parameters. Since the LZ4 compressed data retains its block structure, the encrypted file size is essentially the same as the unencrypted file. During client loading, the Unity engine first uses the AssetBundle.LoadFromFile interface to perform streaming decryption of the file data using the decryption key; the resulting plaintext is the LZ4 compressed data. The engine then decompresses the corresponding data blocks using LZ4 based on resource access requirements, thereby obtaining the final usable resource object.
[0059] The advantage of placing compression before encryption is that compression can effectively reduce file size, lower storage space and network bandwidth consumption, while encryption protects the confidentiality of compressed data. Since LZ4's block compression features are compatible with its streaming decryption mechanism, the combination of the two does not create additional performance bottlenecks.
[0060] The advantages of this embodiment are as follows: by applying LZ4 compression before encryption, the advantage of small AssetBundle file size is maintained without weakening the encryption protection strength. The LZ4 compression format is deeply compatible with the Unity engine's chunked loading mechanism, ensuring efficient resource loading. At the same time, the combination of streaming decryption and on-demand decompression keeps memory usage and CPU load within a controllable range, achieving a balance between security and performance.
[0061] In one possible implementation, the key management server sets an expiration date for the dynamic key, and the client requests a new dynamic key from the key management server after the dynamic key expires; or the key management server adds the dynamic key to a blacklist after detecting a dynamic key leak and refuses access to the latest resources to clients using the blacklisted dynamic key.
[0062] The validity period refers to the time window during which the key management server assigns a dynamic key. After this time window expires, the key will no longer be recognized by the server, and the client must obtain a new key to continue using the resources normally. The blacklist refers to a list of leaked or abnormal keys maintained by the server. When processing client requests, the server checks whether the key carried in the request is on the list. If it is, the server refuses to provide resource access or service response.
[0063] Building upon the aforementioned embodiments, this embodiment adds a lifecycle management mechanism for dynamic keys. When generating a dynamic key, the key management server simultaneously associates it with a validity period timestamp. The validity period is typically set to several hours to several days, with the specific duration adjusted according to the game's security policy. When the server sends the dynamic key to the client, it can include the validity period information in the response data, or the client can have the server verify it during subsequent resource requests.
[0064] When a client needs to access protected resources using a dynamic key during subsequent operation, the server first checks if the key is valid. If it has expired, the server will reject the resource access request and return a specific status code to the client. Upon receiving the status code, the client automatically triggers the process of re-requesting the dynamic key, obtains a new dynamic key following the aforementioned steps, and uses the new key for subsequent resource loading operations. This mechanism ensures that even if the old key is extracted locally on the client, its usable time window is extremely limited.
[0065] In another implementation, when the operations team discovers through security monitoring that a dynamic key may have been compromised, they can add the key to a blacklist via the key management server's management interface. When processing client requests, the server checks if the dynamic key associated with the request is on the blacklist. If it is, the server will refuse to respond and force the client to re-initiate a key request to obtain a new dynamic key that is not on the blacklist. Simultaneously, the server can push notifications to the client, guiding the user to update their client version or take other security measures.
[0066] The beneficial effects of this embodiment are as follows: by introducing an expiration period and a blacklist mechanism, proactive control over the lifecycle of dynamic keys is achieved. The expiration period limits the usable time of a single key; even if an attacker successfully extracts a dynamic key, its effective time window is extremely short, making it difficult to use for batch decryption of resources. The blacklist mechanism provides a rapid response method to deal with sudden key leakage events; the server can immediately invalidate the leaked key, minimizing losses. The combined effect of these two mechanisms greatly enhances the security resilience of the system during long-term operation.
[0067] See Figure 2 , Figure 2 The diagram illustrates a security protection method for UnityAssetBundle based on dynamic key management and multi-layer encryption according to this application. This embodiment is a complete system integrating dynamic key service, secure communication, local secure storage, and flexible loading strategy, specifically including the following.
[0068] AssetBundle Encryption Build Phase: In the Unity editor, complete the regular build of the AssetBundle (LZ4 compression method, ChunkBasedCompression, is recommended). After the build is complete, encrypt the generated AssetBundle files (including the .manifest file) using AES. The encryption key can be a newly obtained dynamic key from the server or a pre-set universal backup key. The AES encryption algorithm can use CBC mode, PKCS7 padding, and a 128-bit key length. The encrypted AssetBundle can then be uploaded to a CDN for clients to download.
[0069] Dynamic Key Service and Management: Deploy a secure key management server that can generate new AES encryption keys (Key_new) on demand (e.g., upon client request or periodically). The server performs security auditing and access control on the generation, storage, and transmission of keys.
[0070] Secure communication and key acquisition on the client: When the game client starts up or needs to update resources, it first checks network connectivity.
[0071] If a network connection is available, the client sends a request to the key server to obtain the key. This communication itself must be encrypted; for example, HTTPS can be used, or the request can be encrypted using an asymmetric encryption public key (such as an RSA public key) pre-installed in the client.
[0072] After the key server generates a new key, Key_new, it sends it to the client using a secure communication protocol (such as HTTPS) or asymmetric encryption (encrypting Key_new using the public key pre-stored by the client). This ensures that the key is not stolen during transmission.
[0073] After receiving the encrypted Key_new, the client decrypts it using the corresponding private key (securely stored within the client and capable of obfuscation and hardening) or session key to obtain the plaintext Key_new.
[0074] Local Encrypted Password Book and Offline Degradation Strategy: An encrypted "password book" (such as an XML, JSON, or binary file) is maintained locally on the client side to store key information. This password book itself is encrypted during packaging (it can be protected using a separate set of fixed symmetric or asymmetric encryption keys). The password book contains at least one or more "backup keys" for degradation in offline environments. When the client detects an offline environment, it does not request a key from the server, but instead decrypts and reads the pre-set backup key from the locally encrypted password book and uses this key to attempt to decrypt the AB package. To ensure offline security, the backup key can be updated periodically through game client patches.
[0075] AB package loading and decryption: After obtaining the corresponding decryption key (Key_new or Key_backup) based on network conditions, the client uses Unity's AB package loading API (such as AssetBundle.LoadFromFile) to load the package. The Unity engine internally uses the set decryption key to decrypt the AB package. For encrypted AB packages downloaded over the network, UnityWebRequestAssetBundle can be used for downloading and loading.
[0076] Key update and expiration mechanism: The server can force clients to update their keys periodically, such as requesting a new key each time the game is launched, or setting a key expiration period. When a key is detected as potentially compromised, the server can add it to a blacklist and refuse access to the latest resources to clients using that key, forcing them to update their keys.
[0077] The beneficial effects of this application include the following: Extremely high security: Dynamic key management ensures that the decryption key for AB packets is no longer fixed and can be changed periodically, effectively preventing mass resource cracking due to static key leakage. Combined with communication encryption and local cryptographic book protection, a multi-layered security defense is constructed, significantly increasing the cost and difficulty of cracking even against experienced attackers, thus powerfully protecting the game's core assets.
[0078] Excellent usability and robustness: The intelligent offline degradation mechanism ensures that the core functions of the game continue to operate normally even in environments with unstable network connections or complete offline conditions, enhancing the user experience. When online, players can enjoy a higher level of security protection provided by dynamic keys.
[0079] Excellent performance: The solution design fully considers performance factors, prioritizing efficient loading methods natively supported by the Unity engine (such as LoadFromFile based on LZ4 compression), avoiding the huge memory and CPU overhead caused by overall decryption and loading. The key update and selection logic is efficient, with negligible impact on game frame rate.
[0080] Flexible deployment and management: Server-side control of key lifecycle enables operations teams to respond quickly to security threats (such as forced key rotation). The solution is easily integrated into existing AssetBundle build pipelines and resource hot update processes, offering excellent scalability and maintainability.
[0081] Comprehensive platform compatibility: This solution is based on standard encryption algorithms and the Unity engine's general API, thus providing excellent support for all major platforms covered by the Unity engine, including Windows, Android, and iOS.
[0082] Corresponding to the above method embodiments, this specification also provides an embodiment of a Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption. Figure 3 This specification illustrates a schematic diagram of a Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption, according to one embodiment of this specification. Figure 3 As shown, the device includes: The key generation module 301 is configured to generate dynamic keys for the key management server. The key distribution module 302 is configured so that the client requests a dynamic key from the key management server through encrypted communication and receives the dynamic key distributed by the key management server. The key determination module 303 is configured to detect the network connectivity status of the client. If a network connection exists, the received dynamic key is used as the decryption key. If no network connection exists, the preset general key is obtained from the local encryption keybook and used as the decryption key. File loading module 304 is configured for the client to load encrypted AssetBundle files using a decryption key.
[0083] In one possible implementation, encrypted communication is based on the HTTPS protocol, or encrypted communication is based on a pre-configured asymmetric encryption public key on the client. The key management server encrypts the dynamic key using the asymmetric encryption public key and then distributes it. The client decrypts the dynamic key using the private key corresponding to the asymmetric encryption public key.
[0084] In one possible implementation, the local encryption key is encrypted and stored during the client packaging stage. The encryption protection method of the local encryption key is symmetric encryption or asymmetric encryption. The local encryption key contains at least one preset general key, which is used as a decryption key when the client has no network connection.
[0085] In one possible implementation, the encrypted AssetBundle file is encrypted using the AES algorithm with CBC mode, PKCS7 padding, and a 128-bit key length.
[0086] In one possible implementation, the process of the client loading the encrypted AssetBundle file using the decryption key is implemented through the AssetBundle.LoadFromFile interface provided by the Unity engine, or the client downloads the encrypted AssetBundle file through UnityWebRequestAssetBundle and then loads it using the decryption key.
[0087] In one possible implementation, the encrypted AssetBundle file is compressed using the LZ4 compression format during the build phase before being encrypted.
[0088] In one possible implementation, the key management server sets an expiration date for the dynamic key, and the client requests a new dynamic key from the key management server after the dynamic key expires; or the key management server adds the dynamic key to a blacklist after detecting a dynamic key leak and refuses access to the latest resources to clients using the blacklisted dynamic key.
[0089] The above is an illustrative scheme of a Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption according to this embodiment. It should be noted that the technical solution of this Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption belongs to the same concept as the technical solution of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption described above. Details not described in detail in the technical solution of the Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption can be found in the description of the technical solution of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption described above.
[0090] Figure 4 A structural block diagram of a computing device 400 according to one embodiment of this specification is shown. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.
[0091] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface.
[0092] In one embodiment of this specification, the aforementioned components of the computing device 400 and Figure 4 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0093] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 400 can also be a mobile or stationary server.
[0094] The processor 420 executes computer-executable instructions, which, when executed by the processor, implement the steps of the aforementioned Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption. The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the aforementioned Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption belong to the same concept. Details not described in detail in the technical solution of the computing device can be found in the description of the aforementioned Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption.
[0095] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the aforementioned UnityAssetBundle security protection method based on dynamic key management and multi-layer encryption.
[0096] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption described above. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption described above.
[0097] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption.
[0098] The above is an illustrative scheme of a computer program according to this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the technical solution of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption described above. For details not described in detail in the technical solution of the computer program, please refer to the description of the technical solution of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption described above.
[0099] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0100] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0101] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0102] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0103] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A security protection method for Unity AssetBundles based on dynamic key management and multi-layer encryption, characterized in that, The method includes: The key management server generates dynamic keys; The client requests the dynamic key from the key management server via encrypted communication and receives the dynamic key issued by the key management server; The client detects the network connectivity status. If a network connection exists, it uses the received dynamic key as the decryption key. If no network connection exists, it decrypts the data from the local encryption keybook to obtain a preset general key as the decryption key. The client uses the decryption key to load the encrypted AssetBundle file.
2. The Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to claim 1, characterized in that, The encrypted communication is implemented based on the HTTPS protocol, or the encrypted communication is implemented based on the asymmetric encryption public key pre-installed on the client. The key management server uses the asymmetric encryption public key to encrypt the dynamic key and then issues it. The client uses the private key corresponding to the asymmetric encryption public key to decrypt and obtain the dynamic key.
3. The Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to claim 1, characterized in that, The local encrypted password book is encrypted and stored during the client packaging stage. The encryption protection method of the local encrypted password book is symmetric encryption or asymmetric encryption. The local encrypted password book contains at least one of the preset general keys, which are used as the decryption key when the client has no network connection.
4. The Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to claim 1, characterized in that, The encrypted AssetBundle file is encrypted using the AES algorithm, which employs CBC mode, PKCS7 padding, and a 128-bit key length.
5. The Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to claim 1, characterized in that, The process of the client loading the encrypted AssetBundle file using the decryption key is implemented through the AssetBundle.LoadFromFile interface provided by the Unity engine, or the client downloads the encrypted AssetBundle file through UnityWebRequestAssetBundle and then loads it using the decryption key.
6. The Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to claim 1, characterized in that, The encrypted AssetBundle file is compressed using LZ4 compression format during the build phase before being encrypted.
7. The Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption according to claim 1, characterized in that, The key management server sets an expiration period for the dynamic key, and the client requests a new dynamic key from the key management server after the dynamic key expires. Alternatively, the key management server may blacklist the dynamic key after detecting its leakage and refuse access to the latest resources to clients using the blacklisted dynamic key.
8. A Unity AssetBundle security protection device based on dynamic key management and multi-layer encryption, characterized in that, include: The key generation module is configured to generate dynamic keys for the key management server. The key distribution module is configured so that the client requests the dynamic key from the key management server through encrypted communication and receives the dynamic key distributed by the key management server. The key determination module is configured to detect the network connectivity status of the client. If a network connection exists, the received dynamic key is used as the decryption key. If no network connection exists, a preset general key is obtained from the local encryption keybook and used as the decryption key. The file loading module is configured so that the client can load the encrypted AssetBundle file using the decryption key.
9. A computing device, characterized in that, include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the Unity AssetBundle security protection method based on dynamic key management and multi-layer encryption as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the UnityAssetBundle security protection method based on dynamic key management and multi-layer encryption as described in any one of claims 1 to 7.
