RSA-2048 Security-Focused API Documentation

Version: 1.0
Last Updated: 2025-09-08
Security Classification: PUBLIC
Author: Phantom (phantom@metamui.id)

⚠️ CRITICAL WARNING

RSA-2048 is a TRANSITIONAL algorithm vulnerable to quantum attacks. It will be DEPRECATED by 2030.

Overview

RSA-2048 is provided ONLY for backward compatibility and hybrid cryptography during the migration to post-quantum algorithms. This documentation provides security-focused guidance for the transitional use of RSA-2048.

Security Level: 112 bits (classical only)
Key Size: 2048 bits (256 bytes)
Signature Size: 256 bytes
Ciphertext Size: 256 bytes

Security Warnings ⚠️

  1. Quantum Vulnerability: RSA-2048 offers ZERO protection against quantum computers
  2. Deprecation Timeline: Will be removed from the library by 2030
  3. Padding Oracles: MUST use OAEP for encryption and PSS for signatures
  4. Timing Attacks: Implementation uses CRT with blinding for mitigation
  5. Key Generation: ~500ms generation time may leak timing information
  6. Factorization Risk: Advances in classical factorization reduce security margin

API Functions

generate_key() -> PrivateKey

Security Contract:

Attack Resistance: | Attack Type | Protected | Notes | |————-|———–|——-| | Weak RNG | ✅ | Uses system CSPRNG | | Small Prime Factors | ✅ | Enforces minimum prime size | | Timing Attack | ⚠️ | Generation time varies | | Quantum Attack | ❌ | Completely vulnerable to Shor’s algorithm | | Factorization | ⚠️ | 112-bit classical security |

encrypt(message: bytes, public_key: PublicKey) -> bytes

Security Contract:

Attack Resistance: | Attack Type | Protected | Notes | |————-|———–|——-| | Padding Oracle | ✅ | OAEP prevents oracle attacks | | Chosen Ciphertext | ✅ | OAEP-SHA256 is IND-CCA2 | | Timing Attack | ✅ | Public operation is naturally constant-time | | Quantum Attack | ❌ | Broken by quantum computers | | Bleichenbacher | ✅ | OAEP prevents this attack |

decrypt(ciphertext: bytes, private_key: PrivateKey) -> bytes

Security Contract:

Attack Resistance: | Attack Type | Protected | Notes | |————-|———–|——-| | Timing Attack | ✅ | CRT with blinding | | Padding Oracle | ✅ | OAEP validation in constant time | | Fault Injection | ⚠️ | CRT may be vulnerable | | Memory Disclosure | ✅ | Secure memory clearing | | Quantum Attack | ❌ | Private key recovery via Shor’s |

sign(message: bytes, private_key: PrivateKey) -> bytes

Security Contract:

Attack Resistance: | Attack Type | Protected | Notes | |————-|———–|——-| | Forgery | ✅ | PSS prevents existential forgery | | Timing Attack | ✅ | CRT with blinding | | Fault Attack | ⚠️ | Bellcore attack possible on CRT | | Quantum Attack | ❌ | Signatures forgeable with quantum computer |

verify(message: bytes, signature: bytes, public_key: PublicKey) -> bool

Security Contract:

Attack Resistance: | Attack Type | Protected | Notes | |————-|———–|——-| | Signature Malleability | ✅ | PSS prevents malleability | | Timing Attack | ✅ | Public operation | | Quantum Attack | ❌ | Verification broken by quantum computer |

Implementation Security

Memory Security

# Critical: Clear private key material after use
def cleanup_private_key(key):
    key.d = secure_clear(key.d)
    key.p = secure_clear(key.p)
    key.q = secure_clear(key.q)
    key.dp = secure_clear(key.dp)
    key.dq = secure_clear(key.dq)
    key.qinv = secure_clear(key.qinv)

CRT Blinding

# Prevent timing attacks during private key operations
def decrypt_with_blinding(ciphertext, private_key):
    r = random_coprime(private_key.n)
    r_inv = mod_inverse(r, private_key.n)
    
    # Blind the ciphertext
    blinded = (ciphertext * pow(r, e, n)) % n
    
    # Perform CRT decryption
    result = crt_decrypt(blinded, private_key)
    
    # Unblind the result
    plaintext = (result * r_inv) % n
    
    # Clear temporary values
    secure_clear(r, r_inv, blinded, result)
    
    return plaintext

Migration Strategy

Hybrid Mode Implementation

def hybrid_encrypt(message, rsa_key, mlkem_key):
    """Encrypt with both RSA and ML-KEM for transition period"""
    # Generate shared secret with ML-KEM
    mlkem_ct, shared_secret = mlkem_key.encapsulate()
    
    # Derive encryption key
    enc_key = kdf(shared_secret)
    
    # Encrypt message with AES-256-GCM
    aes_ct = aes_gcm_encrypt(message, enc_key)
    
    # Also encrypt key with RSA for compatibility
    rsa_ct = rsa_key.encrypt(enc_key)
    
    return {
        'mlkem_ct': mlkem_ct,      # Quantum-safe
        'rsa_ct': rsa_ct,          # Legacy compatibility
        'aes_ct': aes_ct          # Actual message
    }

Deprecation Warnings

import warnings
from datetime import datetime

def rsa_operation_wrapper(func):
    def wrapper(*args, **kwargs):
        if datetime.now().year >= 2028:
            warnings.warn(
                "RSA-2048 will be deprecated in 2030. "
                "Migrate to ML-KEM immediately.",
                DeprecationWarning,
                stacklevel=2
            )
        return func(*args, **kwargs)
    return wrapper

Security Audit Checklist

Required Validations

Migration Requirements

Threat Summary

Threat Impact Mitigation
Quantum Attack CRITICAL Migrate to PQC immediately
Factorization HIGH Monitor advances, enforce 2030 deadline
Padding Oracle HIGH Strict OAEP/PSS implementation
Timing Attack MEDIUM CRT blinding implemented
Fault Injection MEDIUM Limited mitigation available
Bleichenbacher HIGH OAEP prevents this
Small Factors HIGH Strong prime generation

Compliance Notes

References