Hamoon
A digital-signature app that moves certificate issuance and document signing onto an iPhone. The private key is created on the device and never leaves it. I built the whole iOS app.
- Role
- iOS Engineer (built the complete app)
- Company
- Informatics Services Corporation (ISC)
- Stack
- Swift · SwiftUI/UIKit · CryptoKit · swift-certificates · Core Data
- Scope
- X.509 issuance · in-person and remote intake · PDF/CMS signing
A signing certificate on your phone
Hamoon is a digital-signature app from Informatics Services Corporation (ISC). A registered user can get a personal X.509 signing certificate on their iPhone and use it, behind Face ID or Touch ID, to sign documents issued through a certificate authority's backend.
I built the complete iOS app: the MVVM-C structure, the cryptographic core, and the two identity-proofing paths that lead into certificate issuance.
Signing certificates usually live on a USB token, in a desktop tool, or behind a visit to a registration office. The goal was to move that whole lifecycle onto a phone without the private key ever leaving it, and without lowering the bar a legally meaningful signature has to meet.
The rules we started with
- iPhone only, iOS 15 and up.
- Keys tied to one device. They are created with a passcode-required, non-synced access policy, so a certificate does not survive a device restore. That was a choice, not an accident.
- No offline signing. Every signature starts by fetching a hash from the server, before the private key is touched.
- Two ways to prove identity. Attended issuance assumes the person already registered in person. Unattended issuance asks for a face-scan video and a national ID serial, checked on the server first.
- Persian, right to left. The whole UI is RTL, and every certificate date is shown on the Persian calendar.
MVVM-C, with a crypto core that checks the server
Each feature has its own coordinator, view models, repository and views. Under all of them sits a small security core that creates keys, signs hashes and double-checks what the server sends back.
Issuing a certificate starts with an RSA key pair created directly in the Keychain, tagged with a server order ID and protected by passcode plus biometrics. The app sends the public key, along with either a registration password (attended) or a face video and ID serial (unattended). The server returns two hashes to sign: one for the certificate signing request and one for the acceptance form. Both are signed on the device, and that is the moment Face ID appears. The server then issues the certificate.
Before the app trusts it, it hashes and compares three things: the public key in the Keychain, a copy cached at creation time, and the public key inside the new certificate. All three have to match.
What we chose, and what we paid for it
The server computes hashes, the device only signs
The private key and the full document never exist off the device at the same time. CSR, acceptance form, PDF and CMS signing all use the same small "sign this hash" function.
No offline signing. Even re-signing something already downloaded needs a network round trip.
Keys that cannot be recovered
A stolen backup or a synced iCloud Keychain has nothing to leak.
Lose the phone and you enroll again from zero. We decided that up front.
Check the returned certificate instead of trusting it
A certificate bound to the wrong key gets caught on the client and marked invalid.
It is a check after the fact. It stops a bad certificate from being used, not from being issued.
A real X.509 parser
Expiry and structure come straight from the parsed certificate using Apple's swift-certificates library.
This replaced an earlier hand-written expiry calculation, and we only switched after that one drifted. More on that below.
Where keeping the key on the phone gets difficult
An expiry date that could lie
An early version stored certificate expiry as a separate, derived value instead of reading it from the certificate. That value could quietly disagree with the real one. We deleted about 110 lines of that logic and read the date from the parsed X.509 structure instead, the same day we found it. I wrote this up in X.509 on iOS.
The same handshake, four times
CSR, acceptance form, PDF and CMS signing all follow the same pattern (fetch a hash, sign it, submit it), but each one has its own encoding and its own moment when the biometric prompt should appear. Keeping all four consistent caused rework more than once.
Retry and recovery came late
Retry and recovery screens for issuance shipped a few months after the happy path. Real usage made the gap obvious. I would build them earlier next time.
Small app, tested where it matters
Here the security model is the product
- Private key extraction. The key is created in the Keychain with a device-only, passcode-required policy and a biometric requirement on every use. There is no code path that exports the raw key.
- Signing without the user. Face ID or Touch ID is enforced in the app and again at the Keychain and Security framework layer. Two checks, not one.
- A certificate for the wrong key. Caught by the three-way key comparison.
- Password interception. The login password is encrypted on the client against a pinned server public key before it is sent.
- Remote identity spoofing. Unattended issuance needs a face video and ID serial before anything starts. The deeper liveness checks run on the server.
This app is one half of a trust relationship. It verifies everything it can about its own keys. Liveness, document validation and certificate authority policy live on the server side.
What signing software teaches you
- Build the signing primitive once, early. Every later feature reused it instead of inventing its own cryptography.
- Verify what the server sends back. A certificate is only as trustworthy as the client's willingness to check it.
- Don't leave recovery for later. It is easy to postpone and expensive to postpone for too long.