CipherLink

Optional encryption and signing of the whole Connect answer.

Optional. Enable in Connect Settings > Response > Encryption. The entire JSON response is encrypted, for both success and error responses.

Keep in mind

Payload
AES-256-CBC with PKCS#7 padding, then Base64.
Signature
RSA-SHA256 over the Base64 payload string, then Base64.
Marked answers
Encrypted answers carry the X-CipherLink header.
Random field
The decrypted JSON holds an extra random field at the root. Ignore it.

Envelope

Encrypted answer
{
    "sig": "<BASE64_RSA_SIGNATURE>",
    "payload": "<BASE64_AES_CIPHERTEXT>"
}

Decoding

  1. Decode sig from Base64.
  2. Verify RSA-SHA256 over the payload string.
  3. Decode payload from Base64.
  4. Decrypt AES-256-CBC.
  5. Parse the JSON and ignore the unknown random field at the root.
$envelope = json_decode($body, true);
$signature = base64_decode($envelope['sig']);

if (openssl_verify($envelope['payload'], $signature, RSA_PUBLIC_KEY, OPENSSL_ALGO_SHA256) !== 1) {
    throw new RuntimeException('Bad signature');
}

$json = openssl_decrypt($envelope['payload'], 'aes-256-cbc', AES_KEY, 0, AES_IV);
$answer = json_decode($json, true);

Client config

Copy these from Connect Settings into the mod. The values below are placeholders.

Name Value Size
aes_key <AES_KEY_FROM_CONNECT_SETTINGS> 32 bytes
aes_iv <AES_IV_FROM_CONNECT_SETTINGS> 16 bytes
rsa_public_key <RSA_PUBLIC_KEY_FROM_CONNECT_SETTINGS> —
tls_public_key_pin <TLS_PIN_IF_CONFIGURED> —

TLS pin

If your settings show a TLS public key pin, check it on every connection before sending the key.

Esc