pub struct Pubkey { /* private fields */ }
Expand description
A public key object
Implementations§
Source§impl Pubkey
impl Pubkey
Sourcepub fn load_dsa(p: &MPI, q: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>
pub fn load_dsa(p: &MPI, q: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>
Load an DSA public key (p,q,g,y)
Sourcepub fn load_elgamal(p: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>
pub fn load_elgamal(p: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>
Load an ElGamal public key (p,g,y)
Sourcepub fn load_ecdsa(pub_x: &MPI, pub_y: &MPI, curve_name: &str) -> Result<Pubkey>
pub fn load_ecdsa(pub_x: &MPI, pub_y: &MPI, curve_name: &str) -> Result<Pubkey>
Load an ECDSA public key (x,y) for the specified curve
Sourcepub fn load_ecdh(pub_x: &MPI, pub_y: &MPI, curve_name: &str) -> Result<Pubkey>
pub fn load_ecdh(pub_x: &MPI, pub_y: &MPI, curve_name: &str) -> Result<Pubkey>
Load an ECDH public key (x,y) for the specified curve
Sourcepub fn load_ed25519(key: &[u8]) -> Result<Pubkey>
pub fn load_ed25519(key: &[u8]) -> Result<Pubkey>
Load an Ed25519 public key
Sourcepub fn load_x25519(key: &[u8]) -> Result<Pubkey>
pub fn load_x25519(key: &[u8]) -> Result<Pubkey>
Load an X25519 key
Sourcepub fn load_ml_kem(key: &[u8]) -> Result<Pubkey>
pub fn load_ml_kem(key: &[u8]) -> Result<Pubkey>
Load a ML-KEM public key from the raw byte encoding
The exact type can be determined by the length and does not need to be specified
This requires botan_ffi_20250506
, otherwise a not implemented error is returned
Sourcepub fn estimated_strength(&self) -> Result<usize>
pub fn estimated_strength(&self) -> Result<usize>
Return estimated bit strength of this key
Sourcepub fn check_key(&self, rng: &mut RandomNumberGenerator) -> Result<bool>
pub fn check_key(&self, rng: &mut RandomNumberGenerator) -> Result<bool>
Check key for problems
Sourcepub fn der_encode(&self) -> Result<Vec<u8>>
pub fn der_encode(&self) -> Result<Vec<u8>>
DER encode this public key
Sourcepub fn pem_encode(&self) -> Result<String>
pub fn pem_encode(&self) -> Result<String>
PEM encode this public key
Sourcepub fn ec_public_point(&self) -> Result<Vec<u8>>
pub fn ec_public_point(&self) -> Result<Vec<u8>>
Return the encoded elliptic curve point associated with this key
Only valid for EC based keys
This requires botan_ffi_20230403
, otherwise a not implemented error is returned
Sourcepub fn get_field(&self, which: &str) -> Result<MPI>
pub fn get_field(&self, which: &str) -> Result<MPI>
Get a value for the public key The which parameter selects a field which is algorithm specific
Sourcepub fn raw_bytes(&self) -> Result<Vec<u8>>
pub fn raw_bytes(&self) -> Result<Vec<u8>>
Return the raw byte encoding of this key
This requires botan_ffi_20250506
, otherwise a not implemented error is returned
Sourcepub fn get_ed25519_key(&self) -> Result<Vec<u8>>
pub fn get_ed25519_key(&self) -> Result<Vec<u8>>
Return the 32-byte Ed25519 public key
Sourcepub fn get_x25519_key(&self) -> Result<Vec<u8>>
pub fn get_x25519_key(&self) -> Result<Vec<u8>>
Get the X25519 public key