Client-side cryptography with iOS 12 support

I implemented and tested the iOS client side of luca's defined security protocol while supporting iOS 12. The 2021 implementation used CryptoSwift for AES-GCM and key derivation because CryptoKit's AES-GCM API required iOS 13. I also implemented Z85 encoding for an early QR payload; the format later changed.

  • Swift
  • iOS
  • Cryptography

At a glance

Context

The luca iOS app handled sensitive user data through a cryptographic system shared across several components. The security design defined the protocol; the iOS task was to implement its client-side behavior and fit it into the application. The app still supported iOS 12 during this work. CryptoKit’s AES-GCM API required iOS 13, so it could not serve as the only AES-GCM implementation on supported devices.

Implementation

The Swift client contained components for key creation and storage, encryption and decryption, signatures, and data assembled for application flows. The 2021 AES-GCM implementation used CryptoSwift for encryption and HKDF-based key derivation. The implementation had focused tests for symmetric and asymmetric operations, signatures, and key derivation. The work evolved through multiple revisions, including changes to key handling and encrypted data assembly.

An early QR payload also needed a compact text representation of binary data. An ASCII85 implementation was explored, and a Z85 encoder and decoder were applied to the version-2 QR payload. The implementation included round-trip tests for short, long and awkward byte sequences. This encoding did not provide confidentiality; it represented already assembled bytes in a QR-compatible text form. In a later payload version, Base32 replaced Z85 and the custom Base85-family code was removed.

In the Z85 path, the encoder read binary data in four-byte blocks and mapped each block to five characters. The decoder reversed that mapping; both paths handled a shorter final block.

Platform constraint and trade-off

The project supported iOS 12 throughout this early work. CryptoKit could be imported when building against a newer SDK, but its iOS 13 AES-GCM API could not run on every device the app supported. The minimum supported version changed to iOS 14 in April 2022, while AES-GCM remained backed by CryptoSwift.

The case illustrates implementation under a long-lived mobile compatibility constraint and the revision of supporting formats as a protocol evolves.