Asymmetric Padding
RSA OAEP (Encoding/Decoding) and RSA PSS (Encoding) padding schemes (PKCS#1 v2.2 / RFC 8017)
Overview
Performs standalone PKCS#1 v2.2 (RFC 8017) asymmetric message encoding and decoding using SHA-256 and MGF1-SHA256: EME-OAEP Encode (encryption padding), EME-OAEP Decode (decryption unpadding), and EMSA-PSS Encode (signature padding).
Both the visible parameters and the node's fixed input ports dynamically adapt to the selected Scheme:
- In
OAEP-Encodemode, it acceptsMessageand optionalOAEP Labeland produces a padded block of Target Length bytes ($128, 256, 384,$ or $512$). - In
OAEP-Decodemode, it acceptsEncoded (EM)and optionalOAEP Label, verifies the OAEP structure, and recovers the original message. - In
PSS-Encodemode, it accepts a 32-byteMessage Hash($\text{SHA-256}(M)$) and an optional explicitPSS Salt(or generates a random salt of PSS Salt Length bytes) to produce an EMSA-PSS encoded block ready for textbook RSA modular exponentiation.
When to Use
- Inspecting the internal maskedDB / maskedSeed structure of RSA-OAEP or RSA-PSS blocks for educational analysis or CAVP test-vector verification (using an explicit
PSS Salt). - Building custom raw RSA workflows separated into padding + modular exponentiation.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Schemescheme |
selectDefault: OAEP-Encode |
Always visible | Selects the RFC 8017 operation: OAEP-Encode, OAEP-Decode, or PSS-Encode. Dynamically switches which input ports and properties are visible.
|
Modulus / Target Length (Bytes)targetLength |
selectDefault: 256 |
Always visible | RSA modulus byte length ($k \in \{128, 256, 384, 512\}$ corresponding to 1024, 2048, 3072, or 4096-bit RSA). Only visible when Scheme is OAEP-Encode or PSS-Encode.
|
PSS Salt Length (Bytes)saltLength |
numberDefault: 32 |
When scheme is PSS-Encode |
Length in bytes of the random salt generated when the optional PSS Salt input port is unconnected (default 32). Only visible when Scheme = PSS-Encode. |
Unify ErrorserrorUnify |
booleanDefault: false |
Always visible | Replaces built-in errors with a custom error code/message when enabled. |
Unified Error CodeerrorUnifyCode |
textDefault: "" (empty) |
When errorUnify is true |
Custom error code when Unify Errors is enabled. |
Unified Error MessageerrorUnifyMessage |
textDefault: "" (empty) |
When errorUnify is true |
Custom error message when Unify Errors is enabled. |
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (5 total; conditionally visible ports depend on parameter settings as shown below).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Message |
message |
Bytes |
Required | When scheme is OAEP-Encode |
Raw message bytes to encode with EME-OAEP. Only visible when Scheme = OAEP-Encode (max length $k - 2 \times 32 - 2 = k - 66$ bytes). |
Encoded Message |
em |
Bytes |
Required | When scheme is OAEP-Decode |
EME-OAEP encoded block (EM) to decode and unpad. Only visible when Scheme = OAEP-Decode. |
Message Hash |
mHash |
Bytes |
Required | When scheme is PSS-Encode |
Pre-computed 32-byte SHA-256 hash of the message to encode with EMSA-PSS. Only visible when Scheme = PSS-Encode. |
OAEP Label |
label |
Bytes |
Optional | When scheme is OAEP-Encode or OAEP-Decode |
Optional OAEP label bytes (hashed with SHA-256; defaults to empty bytes if unconnected). Only visible when Scheme is OAEP-Encode or OAEP-Decode. |
PSS Salt |
salt |
Bytes |
Optional | When scheme is PSS-Encode |
Optional explicit PSS salt bytes for deterministic test vectors. If unconnected, a random salt of PSS Salt Length bytes is generated. Only visible when Scheme = PSS-Encode. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Result |
result |
Bytes |
Always visible |
Error Cases
When any of the following conditions occurs at runtime, this node transitions to an ERROR state and downstream nodes connected to its outputs do not execute. Enabling Unify Errors (errorUnify) replaces all error codes below with your configured unified error code and message.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
OAEP_MESSAGE_TOO_LONG |
Message is too long for OAEP | Raised in OAEP-Encode when Message exceeds $k - 66$ bytes (e.g., > 190 bytes for 2048-bit / 256-byte target length). |
INVALID_OAEP_PADDING |
Invalid OAEP padding | Raised when the encoded RSA-OAEP block fails structural or label-hash verification during decoding. |
INVALID_PSS_PARAMS |
Invalid PSS parameters (message hash must be 32 bytes, salt the same length as Salt Length, target length longer than hash and salt) | Raised when the message hash is not 32 bytes, the explicit salt length mismatches PSS Salt Length, or the modulus size is too small for the hash and salt. |
Examples
Encoding and Decoding an RSA-OAEP Block
Pad a short message into a 256-byte (2048-bit) OAEP block and decode it back.
- On the first Asymmetric Padding node, set Scheme to
RSA-OAEP Encodeand Target Length to256 Bytes (2048-bit RSA), and connect your message toMessage. - Connect its
Encoded / Unpaddedoutput to theEncoded (EM)input of a second Asymmetric Padding node configured withScheme = RSA-OAEP Decodeto recover the original message.