Skip to main content

RsaOaepCrypter

Struct RsaOaepCrypter 

Source
pub struct RsaOaepCrypter { /* private fields */ }
Expand description

RSA-OAEP 非对称加密器(基于 RustCrypto rsa crate)

使用 RSA-OAEP with SHA-256 和 MGF1-SHA256 填充方案。 公钥加密,私钥解密,适用于小数据(如密钥交换、短消息加密)。

Implementations§

Source§

impl RsaOaepCrypter

Source

pub fn generate(key_bits: usize) -> Result<Self, CryptoError>

生成新的 RSA 密钥对(指定位数,推荐 2048 或 3072)

Source

pub fn from_keys(public_key: RsaPublicKey, private_key: RsaPrivateKey) -> Self

从已有密钥对创建

Source

pub fn public_key(&self) -> &RsaPublicKey

返回公钥引用

Source

pub fn private_key(&self) -> &RsaPrivateKey

返回私钥引用

Source

pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, CryptoError>

使用公钥加密数据(RSA-OAEP with SHA-256)

Source

pub fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CryptoError>

使用私钥解密数据(RSA-OAEP with SHA-256)

Trait Implementations§

Source§

impl Crypter for RsaOaepCrypter

Source§

fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, CryptoError>

Source§

fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CryptoError>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V