mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
### Motivation: The RSA initializers that take raw numbers, e.g. `init(n:e:)` and friends, do not enforce a minimum key size. Our other public API has two lower bounds: the "safe" APIs, e.g. `init(pemRepresentation:)`, which has a 2048-bit lower bound, and the "unsafe" variants, e.g. `init(unsfafePEMRepresentation:)`, which has a 1024-bit minimum. Given the raw number initializers do not state they are unsafe, they should probably have a 2048-bit minimum too. ### Modifications: - Add a 2048-bit minimum key length check to the raw number initializers. - Update the documentation to match the wording on the PEM and DER initializers. - Extend the tests. ### Result: The RSA initializers that take raw numbers, e.g. `init(n:e:)` and friends, now enforce a 2048-bit minimum key length. Co-authored-by: Cory Benfield <lukasa@apple.com>