mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 593
Open
Description
Is your feature request related to a problem or specific use case? Please describe.
The following command:
openssl ecparam -name prime256v1 -genkey -out ec_key.pem
Produces a ECC key in SEC1 format like the following:
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEILvssMloOUDHj0tI5SwZHmCcOwi1AZirx8J4cV5uFH+aoAoGCCqGSM49
AwEHoUQDQgAEh9bOpvg/DH2sdLgFiH5tMneEdm8jPFWRlk2HHvaLTZ07m9AMONfp
kAOlGe1MxyyS72fq9/JVmaP8grnDTpQuww==
-----END EC PRIVATE KEY-----
This key can't be parsed by PemReader with the following code:
using (var strReader = new StreamReader(stream))
{
var pemReader = new PemReader(strReader);
while (strReader.Peek() != -1)
{
var obj = pemReader.ReadObject();
}
}
...as it will crash with System.IO.IOException: unrecognised object: EC PARAMETERS. It seems the Java code for reading those was not ported to bcsharp.
Describe the solution you'd like
PemReader should be able to parse such key.
Describe alternatives you've considered
One can produce a PKCS8 key instead with
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ec_key.pem
Or produce a SEC1 key without specifying the parameters:
openssl ecparam -name prime256v1 -genkey -noout -out ec_key.pem
Product deployment
- Version: 5200dfd
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels