|
1 | | -# **CryptoKit** |
| 1 | +CryptoKit |
2 | 2 |
|
3 | | - |
4 | | - |
5 | | - |
6 | | -[](https://snyk.io/test/github/RomanTsisyk/CryptoKit) |
| 3 | +Production-grade Android cryptography library built on Android Keystore. Focus on safe defaults, explicit error modeling, and clear security boundaries. |
7 | 4 |
|
8 | | - |
9 | | - |
10 | | - |
11 | | - |
| 5 | +## Problem |
12 | 6 |
|
| 7 | +Android Keystore APIs are low-level and error-prone. CryptoKit solves specific problems: |
13 | 8 |
|
14 | | -**CryptoKit** is a comprehensive Kotlin cryptography library designed to secure modern applications. It simplifies encryption, decryption, secure key management, QR code handling, and more, making cryptography accessible for developers. |
| 9 | +- Keystore integration requires understanding multiple APIs with fragmented error handling |
| 10 | +- Key lifecycle (generation, storage, invalidation) edge cases are often overlooked |
| 11 | +- Authentication state changes and device credential updates can silently break encryption flows |
| 12 | +- Developers must write boilerplate code to enforce cryptographic best practices |
15 | 13 |
|
16 | | ---- |
| 14 | +CryptoKit provides constrained abstractions that remove these footguns without hiding necessary control. |
17 | 15 |
|
18 | | -## **Features** |
19 | | -- AES and RSA Encryption/Decryption |
20 | | -- Secure Key Management and Rotation |
21 | | -- Digital Signatures for Data Authenticity |
22 | | -- QR Code Generation and Decoding |
23 | | -- Robust Error Handling Framework |
| 16 | +## Design Goals |
24 | 17 |
|
25 | | ---- |
| 18 | +- Explicit security boundaries and failure modes |
| 19 | +- Safe cryptographic defaults (AES-256-GCM, RSA-OAEP, SHA-256) |
| 20 | +- Minimal, stable public API |
| 21 | +- No exposure of low-level crypto primitives or raw key material |
| 22 | +- Sealed exception hierarchy for exhaustive error handling |
| 23 | +- Synchronous operations with explicit threading requirements |
26 | 24 |
|
27 | | -## CryptoLib Documentation |
| 25 | +## Core Capabilities |
28 | 26 |
|
29 | | -CryptoLib provides a comprehensive set of cryptographic operations, and with this release, we have also generated full API documentation to help developers integrate it into their projects seamlessly. |
| 27 | +- Symmetric encryption (AES-256-GCM) and decryption with authenticated encryption |
| 28 | +- Asymmetric key operations (RSA-OAEP) and digital signatures (RSA-SHA256) |
| 29 | +- Secure key generation, storage, and lifecycle management via Android Keystore |
| 30 | +- Biometric and device credential authentication integration |
| 31 | +- Key rotation with configurable validity windows |
| 32 | +- QR-based key distribution (generation and parsing) |
| 33 | +- Sealed error model with typed exceptions for predictable handling |
30 | 34 |
|
31 | | -The documentation covers the following: |
| 35 | +## Architecture |
32 | 36 |
|
33 | | -- **Key Management**: Generate, retrieve, and delete keys securely from the Keystore. |
34 | | -- **Cryptographic Operations**: Encrypt, decrypt, and sign data with ease. |
35 | | -- **Error Handling**: Detailed error messages and exception handling tailored to cryptographic operations. |
36 | | -- **Usage Examples**: Simple, easy-to-follow examples to get started quickly. |
| 37 | +CryptoKit separates public API from Android Keystore implementation details: |
37 | 38 |
|
38 | | -You can access the full documentation [here](docs), which includes: |
| 39 | +- All key material remains in Android Keystore; plaintext keys are never exposed |
| 40 | +- Cryptographic operations are performed by hidden, hardened crypto implementations |
| 41 | +- Public methods return sealed exceptions only; no raw Java exceptions leak |
| 42 | +- Configuration is explicit: every security-relevant parameter is named and typed |
39 | 43 |
|
40 | | -- Function and method signatures |
41 | | -- Descriptions of parameters and return values |
42 | | -- Exception handling details |
43 | | -- Code examples for various use cases |
| 44 | +## Threading Model |
44 | 45 |
|
45 | | -## 🚀 Get Started |
| 46 | +CryptoKit does not manage threading. All cryptographic operations are synchronous and blocking. The caller is responsible for executing operations off the main thread. Long-running operations (key generation, biometric authentication, key rotation) will block the calling thread. |
46 | 47 |
|
47 | | -1. Clone this repository. |
48 | | -2. Check out the `docs/` folder for local documentation. |
49 | | -3. Refer to the API docs for in-depth technical details on each class and method. |
| 48 | +## Error Handling |
50 | 49 |
|
51 | | ---- |
| 50 | +All failures return sealed subtypes of `CryptoLibException`: |
| 51 | +- `CryptoOperationException`: encryption, decryption, signing failures |
| 52 | +- `KeyNotFoundException`: requested key does not exist |
| 53 | +- `KeyGenerationException`: key creation failed |
| 54 | +- `AuthenticationException`: biometric or device credential flow failed |
| 55 | + |
| 56 | +No raw Java exceptions escape the public API. Callers must handle the sealed exception type and pattern-match on subtypes. |
| 57 | + |
| 58 | +## Security Boundaries |
| 59 | + |
| 60 | +CryptoKit is intentionally scoped. It is NOT: |
| 61 | + |
| 62 | +- A TLS or network security library |
| 63 | +- A protocol implementation (no OAuth, JWT, etc.) |
| 64 | +- A key backup or synchronization solution |
| 65 | +- A general-purpose cryptography framework |
| 66 | + |
| 67 | +Key material is managed by Android Keystore only. Encrypted data and keys must be managed by the caller. No automatic secure deletion of plaintext intermediates is guaranteed outside Keystore boundaries. |
| 68 | + |
| 69 | +## Status & Documentation |
| 70 | + |
| 71 | +This library is pre-1.0. API stability is not guaranteed until 1.0 release. |
| 72 | + |
| 73 | +For security policies, threat model, and best practices, see [SECURITY.md](SECURITY.md). |
| 74 | +For threading guarantees and blocking behavior, see [CONTRIBUTING.md](CONTRIBUTING.md). |
| 75 | + |
| 76 | +Core API documentation is available in generated Kotlin docs. |
0 commit comments