#pem #der #ecc #private-key #sec1

sec1_decode

Crate for parsing EcPrivateKey structures as defined in SEC1 section C4 from both PEM and DER encodings

1 unstable release

0.1.0 Aug 17, 2021

#13 in #pem

Download history 379/week @ 2024-03-17 211/week @ 2024-03-24 227/week @ 2024-03-31 243/week @ 2024-04-07 279/week @ 2024-04-14 301/week @ 2024-04-21 349/week @ 2024-04-28 235/week @ 2024-05-05 380/week @ 2024-05-12 614/week @ 2024-05-19 645/week @ 2024-05-26 643/week @ 2024-06-02 465/week @ 2024-06-09 389/week @ 2024-06-16 390/week @ 2024-06-23 183/week @ 2024-06-30

1,459 downloads per month
Used in 3 crates (via web-push)

Apache-2.0 OR MIT

9KB
121 lines

badge

Crate for parsing EcPrivateKey structures as defined in SEC1 section C4. This is the default format generated by openssl for ec keys.

This crate is capable of decoding both PEM and DER encoded keys.

use sec1_decode::parse_pem;
const PEM:&str = "-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIASgox4rXoGc6ajVAjBCsjVIjbfHd8OK3m5v34ZWVBmmoAoGCCqGSM49
AwEHoUQDQgAEUfXAsSR5LH4rVdHbcK1vnYcN9I/6T7u1bl1RprSZFf89aZXL+CeG
G21XVW8IDhjU7HAXgrO1Sqj00zQtluVBTg==
-----END EC PRIVATE KEY-----";

let parsed = parse_pem(PEM.as_bytes()).unwrap();

lib.rs:

Crate for parsing EcPrivateKey structures as defined in SEC1 section C4. This is the default format generated by openssl for ec keys.

const PEM:&str = "-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIASgox4rXoGc6ajVAjBCsjVIjbfHd8OK3m5v34ZWVBmmoAoGCCqGSM49
AwEHoUQDQgAEUfXAsSR5LH4rVdHbcK1vnYcN9I/6T7u1bl1RprSZFf89aZXL+CeG
G21XVW8IDhjU7HAXgrO1Sqj00zQtluVBTg==
-----END EC PRIVATE KEY-----";

let parsed = parse_pem(PEM.as_bytes()).unwrap();

Dependencies

~4–6MB
~106K SLoC