Skip to content

UTS: encryption specs (RSE1, RSE2, RSL5) and a TB3 fix - #580

Open
maratal wants to merge 2 commits into
mainfrom
uts-encryption
Open

maratal wants to merge 2 commits into
mainfrom
uts-encryption

Conversation

@maratal

@maratal maratal commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

The UTS suite has no encryption tests: completion-status.md lists RSE1, RSE2, RSL5, TZ and CO as uncovered, although RSL5c requires tests against ably-common's crypto fixtures. This adds them.

rest/unit/encoding/crypto.md (9 tests)

  • Crypto.getDefaultParams (RSE1a–e):
    • the AES/CBC defaults (compared case-insensitively, as SDKs report AES or aes);
    • keyLength calculated from the key;
    • base64 and base64url string keys (RSE1c's leniency, with a key whose base64 form contains + and /);
    • rejection of a key length AES doesn't support, and of a keyLength that contradicts the key.
  • Crypto.generateRandomKey (RSE2a–b): 256 bits by default, an explicit 128, and binary keys that differ.

realtime/unit/channels/channel_encryption.md (7 tests)

Every test runs over both crypto-data-128.json and crypto-data-256.json (RSL5b, RSL5c).

Spec Test
RSL5a, RTL6a Publishing encrypts each fixture item to its encrypted form over JSON, and to its msgpack form (binary ciphertext, no final base64) over MessagePack
RTL7d A subscriber receives each item's encrypted form, over JSON and over MessagePack, decrypted to the publisher's data
RSL6a history() returns the encrypted items decrypted
RSL6b A channel without a cipher delivers the payload base64-decoded but still encrypted, with encoding utf-8/cipher+aes-256-cbc, and logs an error
TB2b2 A CipherParamOptions cipher is resolved with getDefaultParams: checked by the ciphertext's shape and a round trip, as its IV is random

The Fixtures section defines the harness helpers:

  • load_fixtures reads a fixture file.
  • fixture_data turns an encoded message into what a publisher passes.
  • set_fixed_iv is a test hook that makes encryption deterministic. The features spec has the IV come from a secure random source, so how a test fixes it is SDK-specific; TZ2 allows extra CipherParams attributes.

TB3

realtime/unit/TB3/with-cipher-key-0 asserted algorithm == "aes", while TZ2a gives the default as AES. It now compares case-insensitively.

completion-status.md and the README's file counts are updated.

Written for, and derived into, ably-pubsub-swift, where all 16 tests pass against both fixtures.

🤖 Generated with Claude Code

maratal and others added 2 commits November 16, 2026 02:31
- rest/unit/encoding/crypto.md: Crypto::getDefaultParams (RSE1a-e: the
  defaults, keyLength from the key, base64 and base64url keys, invalid and
  inconsistent key lengths) and Crypto::generateRandomKey (RSE2a-b).
- realtime/unit/channels/channel_encryption.md: the RSL5c tests over
  ably-common's crypto-data-128.json and crypto-data-256.json. Publishing
  encrypts to the fixtures over JSON and MessagePack (RTL6a), subscribing
  and history decrypt them (RTL7d, RSL6a), a channel without a cipher
  delivers the payload still encrypted and logs an error (RSL6b), and a
  CipherParamOptions cipher is resolved with getDefaultParams (TB2b2).
  Encrypting reproduces the fixtures through a set_fixed_iv test hook.
- completion-status.md and the README's file counts are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TZ2a gives the default algorithm as `AES`, but realtime/unit/TB3/with-cipher-key-0
asserted "aes". SDKs report it in either case, as crypto.md's tests allow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
staging/pull/580 — dd18d605 Deployed Nov 15, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant