At a glance
- Challenge
- Implement the client side of defined cryptographic flows for sensitive user data.
- Keep the app compatible with iOS 12, which could not run CryptoKit’s AES-GCM API.
- Contribution
- Implement and test key handling, encryption, signing and verification components in Swift.
- Use CryptoSwift for AES-GCM and key derivation in the iOS 12-compatible implementation.
- Implement ASCII85 and Z85 encoding and decoding; Z85 represented an early QR payload. This was encoding, not encryption.
- Evolution
- The QR payload later moved from Z85 to Base32 as the format changed.
- The app’s minimum supported version rose from iOS 12 to iOS 14 in April 2022.
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.