How vapor/open-crypto works
Project type and purpose
• This is an open-source Swift library (“OpenCrypto”) that re-implements Apple’s CryptoKit API on top of OpenSSL, targeting platforms (e.g., Linux) where CryptoKit isn’t available.
• Its purpose is to expose familiar Swift crypto APIs (Digest, HMAC, SymmetricKey, AES GCM, ChaChaPoly, etc.) while delegating actual crypto work to OpenSSL C functions.
File structure
• Top-level artifacts:
• Package.swift: Swift Package Manager manifest.
• Sources/: holds two modules:
– COpenCrypto (a C wrapper around OpenSSL calls)
– OpenCrypto (the Swift API layer that users import)
• Tests/: unit tests for each API subset (cipher, digest, MAC).
• Docker/test files: docker-compose.yml and test.Dockerfile for CI/test environment setup.
• .github/workflows/test.yml: CI pipeline.
• Patterns:
• Two-layer architecture (Swift ↔ C ↔ OpenSSL).
• SwiftPM for build & module linking.
• Bridging headers (module.modulemap) to expose C code to Swift.
README for additional insights
• Confirms library role as CryptoKit replacement.
• Lists supported algorithms and missing features.
• Mentions dependency on OpenSSL.
Final recommendation
• Every layer: API, implementation, external dependency, packaging, tests, and CI.
• Don’t overcomplicate—focus on how data and control flow from Swift calls into OpenSSL and back, how the library is built, and how it’s validated.