Package zeroecho.core.alg.rsa


package zeroecho.core.alg.rsa
RSA encryption and signature integration.

This package wires RSA into the core layer, covering asymmetric encryption (OAEP or PKCS#1 v1.5) and digital signatures (PKCS#1 v1.5 or RSASSA-PSS). It provides the algorithm descriptor, streaming contexts for cipher and signature operations, small utilities for block sizing, and key specifications for generation and encoded-key import.

Scope and responsibilities

  • Register RSA with roles for ENCRYPT/DECRYPT and SIGN/VERIFY and expose defaults that favor OAEP (SHA-256) and PSS (SHA-256).
  • Provide streaming contexts that attach to input streams and transform data on-the-fly without buffering entire messages.
  • Expose immutable specifications for cipher padding, signature mode and hashing, and key generation parameters.
  • Offer encoded key specs for X.509 (public) and PKCS#8 (private) with defensive copying and compact marshalling helpers.

Components

  • RsaAlgorithm: algorithm descriptor that declares capabilities, selects secure defaults, and registers key builders.
  • RsaCipherContext: streaming encryption/decryption context that initializes an RSA cipher according to RsaEncSpec and enforces block geometry.
  • RsaSignatureContext: streaming sign/verify context driven by RsaSigSpec, emitting a trailer in SIGN mode or verifying at end-of-stream in VERIFY mode.
  • BlockGeometry: utility describing per-block input/output sizes derived from modulus length, padding, and direction.
  • RsaEncSpec: cipher specification (OAEP with selectable hash and optional label, or PKCS#1 v1.5).
  • RsaSigSpec: signature specification (PKCS#1 v1.5 or PSS with selectable hash and salt length).
  • RsaKeyGenSpec: key generation parameters (modulus size and public exponent).
  • RsaPublicKeySpec and RsaPrivateKeySpec: encoded-key carriers for import/export.

Design notes

  • Algorithm descriptors are immutable and thread-safe.
  • Streaming contexts are stateful and not thread-safe; create a new instance per pipeline.
  • Defaults prioritize modern schemes (OAEP, PSS). Legacy PKCS#1 v1.5 is available primarily for interoperability and should be used with care.
Since:
1.0
  • Class
    Description
    Describes block sizing rules for RSA encryption and decryption.
    RSA algorithm binding for encryption/decryption and signature/verification.
    Streaming RSA cipher context that transforms data block-by-block using OAEP or PKCS#1 v1.5 padding.
    Specification of RSA encryption parameters including padding mode, hash function, and optional OAEP label.
    Hash algorithms usable within OAEP padding.
    Supported RSA padding schemes.
    Key generation specification for RSA key pairs.
    Encoded RSA private key specification in PKCS#8 format.
    Encoded RSA public key specification in X.509 SubjectPublicKeyInfo format.
    Streaming RSA signature context for signing or verifying data in a pull pipeline.
    Specification of RSA signature parameters including padding mode, hash function, and (for PSS) salt length.
    Supported hash algorithms for RSA signatures.
    Signature padding modes supported by RSA.