Table of Contents

Serpent1024Cipher Class

Definition

Namespace
Bodu.Security.Cryptography
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
SerpentBlockCipher.1024.cs

Implements the wide-block tweakable Serpent-1024 block cipher variant, which operates on 1024-bit (128-byte) blocks using a 1024-bit key and a 128-bit tweak. This class cannot be inherited.

public sealed class Serpent1024Cipher : SerpentBlockCipher, IBlockCipher, IDisposable
Inheritance
Serpent1024Cipher
Implements
Inherited Members
Extension Methods

Examples

// Direct single-block use. For most workloads prefer the Serpent1024 SymmetricAlgorithm wrapper.
byte[] key   = new byte[128];   // 1024-bit key
byte[] tweak = new byte[16];    // 128-bit tweak
RandomNumberGenerator.Fill(key);
RandomNumberGenerator.Fill(tweak);

using var cipher = new Serpent1024Cipher(key, tweak);

byte[] plaintext  = new byte[128];
byte[] ciphertext = new byte[128];
cipher.Encrypt(plaintext, ciphertext);

byte[] roundtrip = new byte[128];
cipher.Decrypt(ciphertext, roundtrip);
// roundtrip equals plaintext

Remarks

The cipher runs 80 rounds over a thirty-two-word (1024-bit) state, alternating the canonical Serpent S-boxes with the bitsliced linear transform applied to each four-word lane. A cross-lane rotation between rounds provides diffusion across lanes, and a Threefish-style tweak subkey is XOR-injected every four rounds.

Most callers should prefer the higher-level Serpent1024 class, which exposes the standard SymmetricAlgorithm contract. Use Serpent1024Cipher directly only when composing the raw block primitive with an IBlockCipherModeTransform or IPaddingStrategy.

important

This type is a **non-standard Serpent-derived construction** and is not interoperable with any reference Serpent implementation. Its cryptographic properties have not been externally analyzed. For standard, externally vetted Serpent, use Serpent128Cipher.

Constructors

Serpent1024Cipher(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Initializes a new instance of the Serpent1024Cipher class using the specified key and tweak.

public Serpent1024Cipher(ReadOnlySpan<byte> key, ReadOnlySpan<byte> tweak)

Parameters

key ReadOnlySpan<byte>

The 1024-bit (128-byte) key used for encryption and decryption.

tweak ReadOnlySpan<byte>

The 128-bit (16-byte) tweak value used to modify the block cipher behavior.

Fields

KeySize

Length of the Serpent-1024 key is 1024 bits (128 bytes).

public const int KeySize = 1024

Field Value

int

Properties

BlockSize

Gets the block size, in bits, of the cipher (for example, 128 bits / 16 bytes for AES).

public override int BlockSize { get; }

Property Value

int

The block size, in bits.

Remarks

The block size is expressed in bits to align with the BCL convention used by BlockSize. Byte-array operations (encrypt, decrypt, slice) convert to bytes at the call site as BlockSize / 8.

Applies to

ProductVersions
.NET8, 10

See Also