[][src]Struct gbl::P256KeyPair

pub struct P256KeyPair { /* fields omitted */ }

An elliptic curve key pair (on P-256 / secp256r1 / prime256v1).

This struct contains the private key and the corresponding public key.

Methods

impl P256KeyPair[src]

pub fn from_der<D: AsRef<[u8]>>(der: D) -> Result<Self, Error>[src]

Decodes a P-256 key pair from a DER-encoded ECPrivateKey structure.

The ECPrivateKey ASN.1 structure is specified in RFC 5915.

Examples

let der = [
    0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0x2b, 0xef, 0xab, 0x60, 0x58,
    0x50, 0xdb, 0x0b, 0x3b, 0x8e, 0xf7, 0xe0, 0x54, 0xd5, 0xc5, 0xfe, 0x63,
    0x95, 0x68, 0xb8, 0xcd, 0xfb, 0x86, 0x9b, 0x45, 0xd0, 0xb0, 0xb3, 0x50,
    0x2c, 0xa3, 0xf5, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
    0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0xdc, 0xc7, 0xaf,
    0xdd, 0x92, 0xe7, 0xc2, 0x0b, 0xfe, 0xbb, 0xd7, 0x08, 0x45, 0xb3, 0x4e,
    0x92, 0xea, 0x2d, 0x52, 0xc3, 0x38, 0xaa, 0x9b, 0x68, 0xe8, 0x2b, 0x6c,
    0x82, 0x37, 0x77, 0x29, 0x8f, 0x23, 0x69, 0x39, 0xef, 0x32, 0x72, 0x4c,
    0x43, 0x44, 0xc8, 0x5f, 0x06, 0x6a, 0x6f, 0x37, 0xb1, 0x3e, 0x35, 0x8f,
    0x8a, 0xe5, 0x99, 0x61, 0x99, 0x3d, 0x1e, 0x63, 0x6d, 0x68, 0x5c, 0xc1,
    0xe2
];
let keypair = P256KeyPair::from_der(&der[..])?;

pub fn from_pem<P: AsRef<str>>(pem: P) -> Result<Self, Error>[src]

Decodes a P-256 key pair from a PEM-encoded ECPrivateKey structure.

The ECPrivateKey ASN.1 structure is specified in RFC 5915.

Examples

let pem = r#"
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEICvvq2BYUNsLO4734FTVxf5jlWi4zfuGm0XQsLNQLKP1oAoGCCqGSM49
AwEHoUQDQgAE3Mev3ZLnwgv+u9cIRbNOkuotUsM4qpto6Ctsgjd3KY8jaTnvMnJM
Q0TIXwZqbzexPjWPiuWZYZk9HmNtaFzB4g==
-----END EC PRIVATE KEY-----
"#;
let keypair = P256KeyPair::from_pem(pem)?;

pub fn to_public(&self) -> P256PublicKey[src]

Returns the public component of this key pair.

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]