Bit Shift & Rotate
Shifts or rotates a byte array by a number of bits (SHL, SHR, ROL, ROR)
Overview
Treats the entire input byte array as a single contiguous big-endian bit vector of $8 \times N$ bits and shifts or circularly rotates all bits by the specified bit count: Logical Shift Left (SHL, <<), Logical Shift Right (SHR, >>), Rotate Left (ROL), or Rotate Right (ROR).
Carry bits shifted out of one byte cross seamlessly into the adjacent byte! The bit count can be configured via the Bits property or overridden dynamically at runtime by connecting an integer to the optional Bits input port. Output byte length always equals the input byte length.
When to Use
- Implementing GF($2^{128}$) subkey doubling in AES-CMAC / XTS (1-bit left shift across 16 bytes with conditional polynomial XOR).
- Performing multi-byte circular bit rotations (
ROL/ROR) or bit-level alignment across protocol buffers.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Operationoperation |
selectDefault: SHL |
Always visible | Selects the bit-level operation across the entire byte array: SHL (zeros shifted in from the right), SHR (zeros shifted in from the left), ROL (MSB wraps around to LSB), or ROR (LSB wraps around to MSB).
|
Bitsbits |
numberDefault: 1 |
Always visible | Number of bits to shift or rotate (integer ≥ 0; default 1). Ignored if the optional Bits input port is connected. |
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 (1 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Value |
data |
Bytes |
Required | Always visible | Input byte array (Uint8Array) treated as a contiguous big-endian bit stream. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Result |
result |
Bytes |
Always visible | Shifted or rotated byte array (Uint8Array) of the same byte length as Data. |
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.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
BYTES_INVALID_ARGUMENT |
Invalid argument value | Raised when an argument (such as bit shift count, byte length, or negative integer) is invalid or negative. |
Examples
Shifting a 16-Byte Block Left by 1 Bit (CMAC Subkey Step)
Shift a 128-bit block left by 1 bit across byte boundaries.
- Set Operation to
SHL (Bit Shift Left <<)and Bits to1. - Connect a 16-byte buffer to
Data;Resultemits the 16-byte buffer shifted left by 1 bit.