Data encryption
Updated
Add Agora built-in encryption method to your app.
Agora places great emphasis on the security of user data and privacy. Signaling provides TLS encryption at the transport layer and 256-bit AES encryption on the client side to effectively protect user data. Signaling is also compliant with GDPR, SOC2 Type II, and other security standards.
Understand the tech
Signaling provides the following security features:
-
Transport layer encryption: Data transmission between the client, the server, and the Signaling server is encrypted using TLS. This feature is enabled by default and cannot be disabled.
-
Message encryption: Each message is protected with end-to-end encryption after you configure the encryption parameters.
-
Token authorization: The SDK incorporates time-based access control strategies to ensure that only authorized users are able to access Signaling resources. For details, see Secure authentication with tokens.
If your application requires enhanced data security, or compliance with HIPAA or SOC2 type II standards, implement message-level encryption. Best practice is to use a combination of TLS encryption for data transmission and end-to-end AES encryption for messages.
Prerequisites
Ensure that you have integrated the Signaling SDK in your project, and implemented the framework functionality from the SDK quickstart page.
Implement end-to-end message encryption
The Signaling SDK includes a built-in AES 256 GCM encryption algorithm. To enable end-to-end encryption and decryption, simply configure the encryption mode, encryption key, and salt parameters when initializing the Signaling client instance. After encryption is enabled, the SDK automatically encrypts messages before transmission and decrypts them upon receipt, using the same encryption parameters. Your data is protected throughout the transmission pipeline. Even if a message is temporarily stored on the Signaling server, it remains cryptographically protected and cannot be accessed without the correct key and salt.
Refer to the following sample code to configure end-to-end encryption:
do {
let rtmConfig = AgoraRtmClientConfig(appId: "your_appid", userId: "your_userid")
let encryptionConfig = AgoraRtmEncryptionConfig()
encryptionConfig.encryptionKey = "your_encryptionKey"
encryptionConfig.encryptionMode = .aes256Gcm
let saltValues: [UInt8] = [ /* your salt values */ ]
let saltData = Data(bytes: saltValues, count: saltValues.count)
encryptionConfig.encryptionSalt = saltData
rtmConfig.encryptionConfig = encryptionConfig
let rtmClient = try AgoraRtmClientKit(rtmConfig, delegate: nil)
if rtmClient != nil {
print("RTM Client initialized successfully!")
}
} catch let error {
print("Failed to initialize RTM client. Error: \\(error)")
}AgoraRtmClientConfig* rtm_cfg = [[AgoraRtmClientConfig alloc] initWithAppId:@"your_appid" userId:@"your_userid"];
AgoraRtmEncryptionConfig* encryption_config = [[AgoraRtmEncryptionConfig alloc] init];
encryption_config.encryptionKey = @"your_encryptionKey";
encryption_config.encryptionMode = AgoraRtmEncryptionAES256GCM;
unsigned char bytes[32] = { /*your salt values*/ };
encryption_config.encryptionSalt = [NSData dataWithBytes:bytes length:32];
rtm_cfg.encryptionConfig = encryption_config;
NSError* initError = nil;
AgoraRtmClientKit* rtm = [[AgoraRtmClientKit alloc] initWithConfig:rtm_cfg delegate:handler error:&initError];When automatic encryption and decryption is enabled, all clients under the same app ID must enable this feature and use the same encryption parameters to communicate smoothly.
Note
Automatic encryption and decryption may impact functionality in some use-cases. For instance, if you use mobile push notifications, Signaling is unable to read the mobile push keys and values provided in the message payload due to encryption. In such use-cases, only encrypt the sensitive data in the message payload and keep other data segments in plain text. This partial encryption feature may be provided in future versions of Signaling SDK.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
