apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.45k stars 157 forks source link

Fix RSA.Encryption.PublicKey unsafePEMRepresentation incorrect keySizeInBits #234

Open anotheren opened 4 months ago

anotheren commented 4 months ago

In version 3.4, the _RSA.Encryption.PublicKey introduced a set of unsafe APIs to handle cases where keySizeInBits is less than 2048. However, in the implementation, the boundary check for keySizeInBits in init(unsafePEMRepresentation:) was incorrectly set as self.keySizeInBits >= 2048. Similar APIs indicate that it should actually be self.keySizeInBits >= 1024. This PR attempts to correct this issue.

anotheren commented 4 months ago

Just added.

Lukasa commented 4 months ago

@swift-server-bot test this please