Struct botan::Privkey[][src]

pub struct Privkey { /* fields omitted */ }

A private key object

Implementations

impl Privkey[src]

pub fn create(
    alg: &str,
    params: &str,
    rng: &RandomNumberGenerator
) -> Result<Privkey>
[src]

Create a new private key

pub fn load_rsa(p: &MPI, q: &MPI, e: &MPI) -> Result<Privkey>[src]

Load an RSA private key (p,q,e)

Examples

use std::str::FromStr;
let p = botan::MPI::from_str("289698020102256958291511331409682926199").unwrap();
let q = botan::MPI::from_str("293497288893125842977275290547344412783").unwrap();
let e = botan::MPI::from_str("65537").unwrap();
let rsa = botan::Privkey::load_rsa(&p, &q, &e).unwrap();

pub fn load_ed25519(key: &[u8]) -> Result<Privkey>[src]

Load an Ed25519 private key

Examples

let v = vec![0x42; 32];
let key = botan::Privkey::load_ed25519(&v).unwrap();

pub fn load_x25519(key: &[u8]) -> Result<Privkey>[src]

Load an X25519 private key

Examples

let v = vec![0x42; 32];
let key = botan::Privkey::load_x25519(&v).unwrap();

pub fn load_rsa_pkcs1(pkcs1: &[u8]) -> Result<Privkey>[src]

Load a PKCS#1 encoded RSA private key

pub fn load_dh(p: &MPI, g: &MPI, x: &MPI) -> Result<Privkey>[src]

Load an DH private key (p,g,x)

pub fn load_ecdsa(s: &MPI, curve_name: &str) -> Result<Privkey>[src]

Load an ECDSA private key with specified curve and secret scalar

pub fn load_ecdh(s: &MPI, curve_name: &str) -> Result<Privkey>[src]

Load an ECDH private key with specified curve and secret scalar

pub fn load_der(der: &[u8]) -> Result<Privkey>[src]

Load DER bytes as an unencrypted PKCS#8 private key

pub fn load_pem(pem: &str) -> Result<Privkey>[src]

Load PEM string as an unencrypted PKCS#8 private key

pub fn load_encrypted_der(der: &[u8], passphrase: &str) -> Result<Privkey>[src]

Load DER bytes as an encrypted PKCS#8 private key

pub fn load_encrypted_pem(pem: &str, passphrase: &str) -> Result<Privkey>[src]

Load PEM string as an encrypted PKCS#8 private key

pub fn check_key(&self, rng: &RandomNumberGenerator) -> Result<bool>[src]

Check if the key seems to be valid

pub fn pubkey(&self) -> Result<Pubkey>[src]

Return the public key associated with this private key

pub fn algo_name(&self) -> Result<String>[src]

Return the name of the algorithm

pub fn der_encode(&self) -> Result<Vec<u8>>[src]

DER encode the key (unencrypted)

pub fn der_encode_encrypted(
    &self,
    passphrase: &str,
    rng: &RandomNumberGenerator
) -> Result<Vec<u8>>
[src]

DER encode the key (encrypted)

pub fn der_encode_encrypted_with_options(
    &self,
    passphrase: &str,
    cipher: &str,
    pbkdf: &str,
    pbkdf_iter: usize,
    rng: &RandomNumberGenerator
) -> Result<Vec<u8>>
[src]

DER encode the key (encrypted), specifying cipher/hash options

pub fn pem_encode_encrypted(
    &self,
    passphrase: &str,
    rng: &RandomNumberGenerator
) -> Result<String>
[src]

PEM encode the key (encrypted)

pub fn pem_encode_encrypted_with_options(
    &self,
    passphrase: &str,
    cipher: &str,
    pbkdf: &str,
    pbkdf_iter: usize,
    rng: &RandomNumberGenerator
) -> Result<String>
[src]

PEM encode the key (encrypted), specifying cipher/hash options

pub fn pem_encode(&self) -> Result<String>[src]

PEM encode the private key (unencrypted)

pub fn key_agreement_key(&self) -> Result<Vec<u8>>[src]

Return the key agrement key, only valid for DH/ECDH

pub fn get_field(&self, which: &str) -> Result<MPI>[src]

Get a value for the private key The which parameter selects a field which is algorithm specific

pub fn get_ed25519_key(&self) -> Result<(Vec<u8>, Vec<u8>)>[src]

Get the public and private key associated with this key

pub fn get_x25519_key(&self) -> Result<Vec<u8>>[src]

Get the X25519 private key

Trait Implementations

impl Debug for Privkey[src]

impl Drop for Privkey[src]

Auto Trait Implementations

impl RefUnwindSafe for Privkey

impl !Send for Privkey

impl !Sync for Privkey

impl Unpin for Privkey

impl UnwindSafe for Privkey

Blanket Implementations

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

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

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

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.