docs

v0.1.0 문서를 보고 있습니다. 이 버전은 더 이상 지원하지 않습니다. 최신 릴리스: v0.1.3 →

core::crypto::rsa

이 페이지의 내용

API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.

RSA (RFC 8017): PKCS #1 v1.5 and PSS verification and signing (MGF1 with the message hash), moduli of 2048 to 4096 bits.

Structs

PublicKeySource

pub struct PublicKey

An RSA public key (n, e).

  • pub fn new<N: AsBytes, E: AsBytes>(n: N, e: E) throws (ValueError) -> PublicKey§

    Source

    From big-endian n and e: n odd, 2048 to 4096 bits; e odd, 3 <= e < 2^33 (verification costs a square and a multiply per exponent bit; a peer's certificate must not choose that).

  • pub fn from_pkcs1_der<B: AsBytes>(der: B) throws (ValueError) -> PublicKey§

    Source

    From a DER RSAPublicKey ::= SEQUENCE { modulus INTEGER, publicExponent INTEGER }.

  • pub const fn bits(self) -> usize§

    Source

    The modulus length in bits.

  • pub const fn modulus(self) -> List<u8>§

    Source

    The modulus, big-endian without leading zeros.

  • pub const fn exponent(self) -> List<u8>§

    Source

    The public exponent, big-endian without leading zeros.

  • pub fn verify_pkcs1v15<M: AsBytes, S: AsBytes>(self, hash: HashAlgorithm, msg: M, signature: S) -> bool§

    Source

    RSASSA-PKCS1-v1_5 verification: the whole encoding is rebuilt and compared.

  • pub fn verify_pss<M: AsBytes, S: AsBytes>(self, hash: HashAlgorithm, msg: M, signature: S, salt_len: usize | none = none) -> bool§

    Source

    RSASSA-PSS verification, MGF1 with hash; the salt is salt_len bytes (none: the hash length).

Trait implementations 5

PrivateKeySource

pub struct PrivateKey

An RSA private key with its CRT parameters (RFC 8017 3.2, two primes), big-endian in secret storage.

  • pub fn from_pkcs1_der<B: AsBytes>(der: B) throws (ValueError) -> PrivateKey§

    Source

    From a DER RSAPrivateKey (RFC 8017 A.1.2, version 0: n, e, d, p, q, d mod (p - 1), d mod (q - 1), q^-1 mod p).

  • pub fn wipe(self)§

    Source

    Overwrite the private values with zeros now (every copy shares them); signing is meaningless afterwards.

  • pub const fn public_key(self) -> PublicKey§

    Source

    The public half.

  • pub const fn bits(self) -> usize§

    Source

    The modulus length in bits.

  • pub fn sign_pss<M: AsBytes, S: AsBytes>(self, hash: HashAlgorithm, msg: M, salt: S) throws (ValueError) -> List<u8>§

    Source

    An RSASSA-PSS signature of msg: MGF1 with hash, salt as long as the hash. salt must be fresh random bytes; the blinding factor is derived from it, the message and the key.

  • pub fn sign_pkcs1v15<B: AsBytes>(self, hash: HashAlgorithm, msg: B) throws (ValueError) -> List<u8>§

    Source

    An RSASSA-PKCS1-v1_5 signature of msg (deterministic: the blinding factor is derived from the message and the key).

Trait implementations 3
  • impl !Sync for PrivateKey
  • impl Drop for PrivateKey
  • impl Debug for PrivateKey