pingora_openssl

Module pkey

Source
Expand description

Public/private key processing.

Asymmetric public key algorithms solve the problem of establishing and sharing secret keys to securely send and receive messages. This system uses a pair of keys: a public key, which can be freely distributed, and a private key, which is kept to oneself. An entity may encrypt information using a user’s public key. The encrypted information can only be deciphered using that user’s private key.

This module offers support for five popular algorithms:

  • RSA

  • DSA

  • Diffie-Hellman

  • Elliptic Curves

  • HMAC

These algorithms rely on hard mathematical problems - namely integer factorization, discrete logarithms, and elliptic curve relationships - that currently do not yield efficient solutions. This property ensures the security of these cryptographic algorithms.

§Example

Generate a 2048-bit RSA public/private key pair and print the public key.

use openssl::rsa::Rsa;
use openssl::pkey::PKey;
use std::str;

let rsa = Rsa::generate(2048).unwrap();
let pkey = PKey::from_rsa(rsa).unwrap();

let pub_key: Vec<u8> = pkey.public_key_to_pem().unwrap();
println!("{:?}", str::from_utf8(pub_key.as_slice()).unwrap());

Structs§

  • An identifier of a kind of key.
  • A public or private key.
  • Reference to PKey.

Enums§

  • A tag type indicating that a key only has parameters.
  • A tag type indicating that a key has private components.
  • A tag type indicating that a key only has public components.

Traits§

  • A trait indicating that a key has parameters.
  • A trait indicating that a key has private components.
  • A trait indicating that a key has public components.