AI Assistant
Help Center AI Assistant is now available
Got questions about Lark? Use our AI chat to find the answers.
00:00
Click and hold to drag
Got It
Try Now
Admin | Import or replace a key (Windows)

Admin | Import or replace a key (Windows)

4 min read
I. Intro
🔖
Purchase information: Separate payment is required for this feature. For more information, contact Support or your Customer Success Manager.
Who can perform these steps: Primary administrators or administrators with "Deployment and Encryption" permission.
Keys are critical for the security of your organization's data. Client data is stored in the database on the cloud after being encrypted using keys. This service not only allows organizations to manage their keys but use their own keys instead of default ones, giving more control to the organization.
Keys can be imported based on business lines, which include messages, online documents, video meetings, events, emails, and more. Organizations can use one key for all business lines, or different keys for different business lines (recommended).
The administrator is able to replace keys. Data generated after the replacement will be encrypted using the new key, while the old key may only be used for the decryption of historical data.
II. Steps
1. Import a key
1.1 Start
Go to Lark Admin Console > Security > Deployment and Encryption > BYOK Advanced.
250px|700px|reset
image.png
250px|700px|reset
1.2 Select a public key algorithm
In Step 1, select the public key algorithm and click Next after confirmation. (RSA2048_RSAES_OAEP_SHA256 is recommended.)
250px|700px|reset
1.3 Download the public key file
In Step 2, you can access a public key by either copying or downloading it. We recommend downloading the public key and naming the file as "PublicKey_base64.txt", and saving it locally. Confirm and click Next.
250px|700px|reset
Note: The public key expires 24 hours after it is generated.
1.4 Generate and encrypt a key locally
  • Create a folder called KeyImport and open it.
  • Download the corresponding script and save it in the KeyImport folder according to your Windows system type.
Click here to download: Script
  • Put the public key file PublicKey_base64.txt downloaded in Step 1.3 to the KeyImport folder.
  • Open the terminal and then KeyImport.
  • How to access KeyImport: Enter cd and a space, use your mouse to select and drag the KeyImport folder to the command line tool, and click Enter to go to KeyImport.
  • Generate a key and use the public key to encrypt it.
  • Enter the encryption command in the terminal. Users are required to select the key type based on the public key algorithm in Step 1.3 and enter the corresponding command. Users can choose between AES_256_GCM (recommended) and SM4_128_GCM, the two key types currently supported by Lark. The corresponding relationships between public key algorithms, key types, and commands are shown in the table:
The public key algorithm selected in Step 1.3
Key type
Command
(Use enc_win64 or enc_win32 according to the script you downloaded)
RSA2048_RSAES_OAEP_SHA256
(recommended)
AES256 (recommended)
.\enc_win64 -t=3 -u=0 -a=0
SM4
.\enc_win64 -t=3 -u=0 -a=2
RSA2048_RSAES_PKCS1_V1_5
AES256
.\enc_win64 -t=1 -u=0 -a=0
SM4
.\enc_win64 -t=1 -u=0 -a=2
RSA2048_RSAES_OAEP_SHA_1
AES256
.\enc_win64 -t=2 -u=0 -a=0
SM4
.\enc_win64 -t=2 -u=0 -a=2
SM2PKE
AES256
.\enc_win64 -t=4 -u=0 -a=0
SM4
.\enc_win64 -t=4 -u=0 -a=2
  • MasterKey_hex (key plaintext) and PublicEncryptedMasterKey_base64.txt (key ciphertext) files will be generated in the KeyImport folder. PublicEncryptedMasterKey_base64.txt contains the ciphertext to be uploaded.
250px|700px|reset
Note: Please make sure to properly save the key ID (displayed after the import) and key plaintext file (contains the key plaintext) so that the information and plaintext relating to the key ID are available when you need it.
1.5 Upload the key
In Step 3, enter the key name, select the corresponding key type and the corresponding business to be encrypted, and copy the content of the encrypted document PublicEncryptedMasterKey_base64.txt to the key upload box. It is recommended to use different keys to encrypt different business lines.
250px|700px|reset
Click Import key and then Import new key in the pop-up window after confirmation.
250px|700px|reset
1.6 Complete import
After importing, the system will check if the key name and ciphertext submitted are legal and if the length of the key complies with the algorithm as the initial key length required varies between different algorithms. If all parameters are valid, a key imported notification will be shown.
If all business lines have been encrypted, the page will look like this:
250px|700px|reset
image.png
If there are still some business lines that have not been encrypted, they will be shown on the page when the key is imported. Users can click Continue to import to import keys for these business lines. The following is the notification page when only the key for the messages business line has been imported.
250px|700px|reset
a1a3a6e2-e12e-481c-a330-993990456972.jpeg
2. View and replace keys
  • The newly uploaded key will be displayed in the list after it is imported.
  • The original Import key button has been moved to the upper-right corner of the interface and renamed as Replace key, but the operation process is exactly the same.
  • The record of the key will also appear in the key list, and the key will be marked as enabled.
250px|700px|reset
image.png
Note: The key is not immediately effective after import or replacement. It comes into effect within 5 minutes when the cache is refreshed. Therefore, if users click Import key or Replace key again within 10 minutes, the import process will not start.
III. FAQs
Can an organization use a custom key to encrypt its data?
Yes. The organization can choose AES_256_GCM (recommended) or SM4_128_GCM as the encryption algorithm.
  1. According to the algorithm, use the following online tool to generate an encryption key with a random byte stream (in hexadecimal encoding) of the specified length.
  • 250px|700px|reset
  1. Save the generated custom key to the "MasterKey_hex.txt" file in your local drive, and place the file under the "KeyImport" folder.
  1. Import the custom key.
  • If you use the key generator, select Already has a local master key, and follow the guidance.
  • If you use a script, change the value of the "-u" parameter to 1 when you enter the command.
  • Parameter
    Description
    -u=0
    The script generates a new random key and saves it to the "MasterKey_hex.txt" file. If the "MasterKey_hex.txt" file already exists, the command will fail.
    -u=1
    The script uses an existing key in the "MasterKey_hex.txt" file. Make sure that you already have a key saved in the file before you use this parameter.
What information do I need a local copy of when using the BYOK feature?
You must have the master key and key name secured locally for some special cases.
Is there a limit to the frequency of importing and replacing keys in the BYOK feature?
Yes. Each service can change the key up to 10 times per month, and once every 10 minutes. The higher the frequency of key changes, the higher the data security. We recommend changing the key once every 3 months.
If you need an urgent key replacement, contact Support.
Is there a limit on the number of keys imported or replaced in the BYOK feature?
No.
What are the different functions of keys uploaded at different times?
For each service, there is only one key with the function of "Encryption/Decryption", that is, the last uploaded key. This key will be used for the encryption of new data and the decryption of this new data. Other historical keys will be used for the decryption of the corresponding encrypted data.
Will the uploaded key in the BYOK feature expire?
No.
What will happen if I submit key names and key ciphertext that is invalid?
If the key name and ciphertext are invalid, users will receive a notification saying that the key import has failed, please check and re-submit.
Written by: Lark Help Center
Updated on 2025-01-08
How satisfied are you with this content?
Thank you for your feedback!
Need more help? Please contact Support.
rangeDom
rangeDom
rangeDom
rangeDom
rangeDom
rangeDom
rangeDom
rangeDom