|
| 1 | +# 🧩 commons-security Backlog |
| 2 | + |
| 3 | +A modernization and quality-improvement plan for the **commons-security** library. |
| 4 | +Goal: complete modernization, testing, and documentation for internal and educational use. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 🔒 Tier 1 – Critical correctness & security fixes |
| 9 | +*(Must be completed before any internal or external use)* |
| 10 | + |
| 11 | +- [ ] **Fix Shamir’s Secret hardcoded parameters** |
| 12 | + - Replace `new Scheme(new SecureRandom(), 100, 100)` with dynamic `(n, k)` from input. |
| 13 | + - Add validation: ensure at least `k` shares are provided when joining. |
| 14 | + |
| 15 | +- [ ] **Upgrade RSA to OAEP-SHA256** |
| 16 | + - Use `"RSA/ECB/OAEPWithSHA-256AndMGF1Padding"`. |
| 17 | + - Update `RsaCipher` and `EncryptBuilder` accordingly. |
| 18 | + |
| 19 | +- [ ] **Upgrade signatures to RSASSA-PSS** |
| 20 | + - Use `"SHA256withRSAandMGF1"` (RSASSA-PSS) in `SignatureUtils`. |
| 21 | + |
| 22 | +- [ ] **Fix DigestUtils hex encoding bug** |
| 23 | + - `hexDigest()` currently Base64-encodes output. Replace with `EncodingUtils.hexEncode()`. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## ⚙️ Tier 2 – Security robustness & modernization |
| 28 | + |
| 29 | +- [ ] **Use binary entropy for AES keys** |
| 30 | + - Replace `RandomUtils.randomString(20)` with secure random bytes. |
| 31 | + - Encode to Base64 and size by `EncryptionStrength`. |
| 32 | + |
| 33 | +- [ ] **Default AES strength to 256-bit** |
| 34 | + |
| 35 | +- [ ] **Rename builder `optional()` methods** |
| 36 | + - `.optional(EncryptionMode)` → `.withMode(EncryptionMode)` |
| 37 | + - `.optional(EncryptionStrength)` → `.withStrength(EncryptionStrength)` |
| 38 | + |
| 39 | +- [ ] **Reuse single SecureRandom instance** |
| 40 | + - `private static final SecureRandom RNG = SecureRandom.getInstanceStrong();` |
| 41 | + |
| 42 | +- [ ] **Prioritize BouncyCastle provider** |
| 43 | + - Use `Security.insertProviderAt(new BouncyCastleProvider(), 1)`. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## 🧱 Tier 3 – API & developer-experience improvements |
| 48 | + |
| 49 | +- [ ] **Add JSON serialization for `HybridEncryptionResult`** |
| 50 | + - Include `toJson()` / `fromJson()` helpers (Gson or Jackson). |
| 51 | + - Add optional `version` field for future compatibility. |
| 52 | + |
| 53 | +- [ ] **Rename `encryptedSymmetricalKey` → `encryptedKey`** |
| 54 | + |
| 55 | +- [ ] **Add `describe()` helper** |
| 56 | + - Return human-readable AES summary, e.g. `"GCM@256-bit"`. |
| 57 | + |
| 58 | +- [ ] **Add digest/signature helpers in `CryptoUtils`** |
| 59 | + - `digest(String data)` |
| 60 | + - `sign(String data, PrivateKey)` |
| 61 | + - `verify(byte[] sig, String data, PublicKey)` |
| 62 | + |
| 63 | +- [ ] **Add hybrid encrypt/decrypt helpers in `CryptoUtils`** |
| 64 | + - `hybridEncrypt(PlainText, PublicKey)` |
| 65 | + - `hybridDecrypt(HybridEncryptionResult, PrivateKey)` |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 🧩 Tier 4 – Password encoding improvements |
| 70 | + |
| 71 | +- [ ] **Cache `DelegatingPasswordEncoder` instances** |
| 72 | + - Build once per `PasswordEncoderType`. |
| 73 | + |
| 74 | +- [ ] **Make encoder map unmodifiable** |
| 75 | + - Wrap with `Collections.unmodifiableMap()`. |
| 76 | + |
| 77 | +- [ ] **Add `matchesAuto()` helper** |
| 78 | + - Auto-detect encoder type from `{id}` prefix. |
| 79 | + |
| 80 | +- [ ] **Add `needsUpgrade()` helper** |
| 81 | + - Allow checking if encoded password should be re-hashed with stronger algorithm. |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## ✍️ Tier 5 – Documentation & cleanup |
| 86 | + |
| 87 | +- [ ] **Update `README.adoc`** |
| 88 | + - Reflect new AES/RSA defaults and PSS signatures. |
| 89 | + - Add section on hybrid encryption. |
| 90 | + - Include a *“Not for production use”* disclaimer. |
| 91 | + |
| 92 | +- [ ] **Add library version metadata** |
| 93 | + - e.g. `public static final String VERSION = "1.0.0";` |
| 94 | + |
| 95 | +- [ ] **Rename minor typos** |
| 96 | + - e.g. `ciperText` → `cipherText`. |
| 97 | + |
| 98 | +- [ ] **Add/extend unit tests** |
| 99 | + - [ ] AES encrypt/decrypt roundtrip |
| 100 | + - [ ] RSA OAEP encrypt/decrypt |
| 101 | + - [ ] Hybrid encrypt/decrypt roundtrip |
| 102 | + - [ ] Signature sign/verify |
| 103 | + - [ ] Shamir split/join |
| 104 | + - [ ] Password encoder encode/match |
| 105 | + |
| 106 | +- [ ] **Tag release as educational/reference** |
| 107 | + - Clarify in README: |
| 108 | + > “This library is for educational and internal use only. |
| 109 | + > Not intended for production deployment or active maintenance.” |
| 110 | +
|
| 111 | +--- |
| 112 | + |
| 113 | +## 🧭 Optional Future Ideas |
| 114 | + |
| 115 | +- [ ] Add ECC support (ECIES, Ed25519, ECDSA) |
| 116 | +- [ ] Add BLAKE2b/BLAKE3 digests |
| 117 | +- [ ] Add deterministic JSON serialization |
| 118 | +- [ ] Add streaming AES-GCM for large files |
| 119 | +- [ ] Create Vaadin demo UI for encryption/decryption workflow |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +*commons-security – modernization plan © 2025 Avec112* |
0 commit comments