NodeCrypto Help

Asymmetric Padding

Category: Utility ยท Node Type ID: padding-asymmetric

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:

When to Use

Parameter Configuration

Parameter (ID)Type & DefaultVisibility ConditionDescription & Options
Scheme
scheme
select
Default: 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.
  • OAEP-Encode: RSA-OAEP Encode (Encryption Padding)
  • OAEP-Decode: RSA-OAEP Decode (Decryption Unpadding)
  • PSS-Encode: RSA-PSS Encode (Signature Padding)
Modulus / Target Length (Bytes)
targetLength
select
Default: 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.
  • 128: 128 Bytes (1024-bit RSA)
  • 256: 256 Bytes (2048-bit RSA)
  • 384: 384 Bytes (3072-bit RSA)
  • 512: 512 Bytes (4096-bit RSA)
PSS Salt Length (Bytes)
saltLength
number
Default: 32
Supports Variable Reference ($var: int)
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 Errors
errorUnify
boolean
Default: false
Supports Variable Reference ($var: bool)
Always visible Replaces built-in errors with a custom error code/message when enabled.
Unified Error Code
errorUnifyCode
text
Default: "" (empty)
Supports Variable Reference ($var: string)
When errorUnify is true Custom error code when Unify Errors is enabled.
Unified Error Message
errorUnifyMessage
text
Default: "" (empty)
Supports Variable Reference ($var: string)
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 NamePort IDData TypeRequiredVisibility ConditionDescription
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 (EM) 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 (32B) 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 NamePort IDData TypeVisibility ConditionDescription
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 CodeDefault Engine MessageTrigger 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.

  1. On the first Asymmetric Padding node, set Scheme to RSA-OAEP Encode and Target Length to 256 Bytes (2048-bit RSA), and connect your message to Message.
  2. Connect its Encoded / Unpadded output to the Encoded (EM) input of a second Asymmetric Padding node configured with Scheme = RSA-OAEP Decode to recover the original message.