NAV

Conversation & visitor data encryption

Overview

Conversation and visitor data encryption is an extra feature in our service. If it is enabled you can toggle encryption for any room in your company.

When encryption is on, whenever a new chat session is created, an AES key is also generated and stored to two places. A plaintext version of the key is stored in cache with a 90-minute expiration time. Another copy of this key is encrypted with customer provided RSA public key and stored to our database.

During chat session this AES key is used to encrypt all message content. Every time a new chat log is saved to database, the cached AES key is given a new expiration time of 90 minutes. While the cached key exist, all chat logs are automatically decrypted.

Visitor API data values are also encrypted. The AES key used in encryption is different from the one used with chat sessions. This key is also cached but only for 30 minutes. The timer resets on every visitor pageload. An RSA encrypted version of this AES key is stored as an API data entry with name _encrypted_aes_key.

Symmetric AES encryption

Our implementation of AES encryption uses https://github.com/pyca/cryptography library maintained by Python Cryptographic Authority (PyCA). We use 256-bit AES keys and encryption is done in CBC mode.

Keys are stored in json format.

Example of an encryption key

{
    "hmacKey": {
        "hmacKeyString": "4PTHmiELMFxA_O8yYTtl6mhdkNBi01TYSUe8vsD6NV4",
        "size": 256
    },
    "aesKeyString": "gIhuVsdgLYnsko6h-3GTIe2PIkB3W0hyUtQYG0A2WUw",
    "mode": "CBC",
    "size": 256
}

Encrypted data is also signed with a HMAC key. The ciphertext resulting from encryption has following format:

Please note that the signature is generated over already encrypted data. Before storing the ciphertext it is base64 encoded.

Asymmetric RSA encryption

After generating the AES key it is encrypted with customer’s RSA public key and stored. Our implementation uses PyCryptodome’s RSA module. RSA key has to be at least 2048-bits long. RSA encryption follows PKCS #1 OAEP standard

How to generate keys?

To generate RSA key pair you can use following openssl commands.

How to generate keys with OpenSSL

openssl genrsa -des3 -out private.pem 2048
openssl rsa -in private.pem -outform PEM -pubout -out public.pem

These will generate you a RSA key pair and save them to files private.pem and public.pem. Public key from public.pem can be pasted to our public key settings interface as is.

How to decrypt?

While the AES key exists in our cache chat logs are decrypted automatically. After that decryption has to be done by customer.

The easiest way

Use Giosg’s Vault Decrypt app.

The other way

Another way to decrypt your data is to install Giosg Crypter python package and follow the guide it provides. Familiarity with python and our HTTP API and Public HTTP API documentations are recommended.

First install the required dependencies and either use the installed command line tool or create your own script with the python library.

Installing dependencies

pip install git+https://github.com/giosg/giosg_crypter.git#egg=giosg.crypter==0.0.1

Command line tool

decrypt path/to/your/private/key/file https://url/to/the/chat/<chat_session_id> -t <your_user_api_token>

Create your own script

import subprocess
from giosg.crypter import AESKey, asymmetric_decrypt, symmetric_decrypt

private_key = subprocess.check_output(['openssl', 'rsa', '-in', 'path/to/your/private/key/file'])
aes_key = asymmetric_decrypt(private_key, encrypted_key_from_chat_session)
key = AESKey.from_json(aes_key)
decrypted_message = symmetric_decrypt(key, message_field_to_be_decrypted])

Decryption before & after

In case you want or need to implement your own decryption app, here are inputs and outputs to test its functionality

Example input

If you implement your own decryption you can use these keys and inputs to verify that the your decryption code works

Decryption process:

Example data 1: Example RSA private key (do not use in production)

-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAw3XH/gCi6AvM19+lMxl1/AqRWq5PxJyWSBT/UMpjrIUlE/ET
e/aZ2skB8YqT+CPVpNY/2+xUnKhnqwZzoDlkw/vsGeEJLaMCsN3eWzO4IdK9cV6s
gf/XfiJIYgd6QCVAtww7hzn83aoKUyL7fWFvN8s0Bi9OsVLXEyEk3ZqeBeoSPv3b
PZsPjmi3cTxdsSRRsYXItrjxNIu8CD6SxHwrswTwknFzldCQ/GgsTMRblJYb80UM
dZLIJeQuXt948jVwU+OttSmld9jExXDIESjeyH0mUidTjg/w4rKi6DXqdfxevSxq
G/pD1101Zmun8WdtlTPD93V5ZGKRM3H3OiqQUwIDAQABAoIBAQCpJiVzuANCwut7
qcxiA1eqTU7q5cycPlKDgMBOn0dQxkyHDGqrLYaJ4sfuytkwtXou00aiQMwcYlSM
meG4N9LvE/WHk8qIlvg+LVM/I+vmQWS2VpL9UXWgb3SqeQQfvN1bS5e8d79P6NZU
igKPx6Ei7JRSAeCc7i64HEe2CxdTz26cSYjyfPDaS952af1VwVBVBCcb8TIyx5mc
iQBt8PWpw+wT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T2cN7v3yzldk+YkYjwB92Nyk41cQyFf0eGFZ9DmVXQ0NbACan4v71+z
ulothiDQVQ8I94xTgJmRK16Vu0FhFYfW15grYmVMnnPG9pp0PUFIMd3VWZHKMkkBVmX9l02Irzne
MunalUjKQTCO5HZaJTDIbAIsRiFKAw0bQZyvv5X5WDY1s888WRYXQikJRwqjKYxKqncd6F9dy+6a
0pzNe+ZUNOKST6dc4phWCoxxGXgWcZNG1eTagzM9WScLvJPwkYawQi385oENPzjLU3P477pVjFDm
Hd3KZvEHjJ6IFUgm6FNxee6XsxiYXITSPVxJ0g==

Example data 3: Output RSA decrypted AES key

{
    "hmacKey": {
        "hmacKeyString": "Wf7oZEWQTpspt0g1ZISN0SNFS21w5DdVOp579RqBg20",
        "size": 256
    },
    "aesKeyString": "dIz4N3wn4V3RfRjyteWRS5_fkXzuo8fFP1ZLMgck_wg",
    "mode": "CBC",
    "size": 256
}

Example data 4: AES encrypted message content

AJxNkp3ZS9McVTYPDyckR7ub7ri5oIObzl0a45t13owvG8ouGfAdfZiosw4hxCgc1iYg88v1xZRL
Ff0/UJr/CcqfCzJjSA4ZWg==

Example data 5: AES decrypted message content

The Line is Open!