Files
swift-crypto/Sources/CryptoExtras/EC
Si Beaumont 40ca846975 Reject Curve25519 private keys labelled with the wrong algorithm (#506)
### Motivation:

Curve25519 `PrivateKey(derRepresentation:)` and
`PrivateKey(pemRepresentation:)` in CryptoExtras never compare the
PKCS#8 `privateKeyAlgorithm` to the key type. An X25519 PKCS#8 loads as
an Ed25519 signing key, and an Ed25519 PKCS#8 loads as an X25519 key
agreement key. The public key initializers already check the OID.

### Modifications:

- Throw `invalidASN1Object` when the PKCS#8 OID doesn't match the key
type, for `Signing` and `KeyAgreement`, DER and PEM
- Add a test that loads each key type's key under the other's OID

### Result:

Keys labelled with the wrong algorithm now throw.
2026-11-23 16:24:10 +00:00
..