Serpent512Cipher Class
Definition
- Namespace
- Bodu.Security.Cryptography
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
Implements the wide-block tweakable Serpent-512 block cipher variant, which operates on 512-bit (64-byte)
blocks using a 512-bit key and a 128-bit tweak. This class cannot be inherited.
public sealed class Serpent512Cipher : SerpentBlockCipher, IBlockCipher, IDisposable
- Inheritance
-
Serpent512Cipher
- Implements
- Inherited Members
- Extension Methods
Examples
// Direct single-block use. For most workloads prefer the Serpent512 SymmetricAlgorithm wrapper.
byte[] key = new byte[64]; // 512-bit key
byte[] tweak = new byte[16]; // 128-bit tweak
RandomNumberGenerator.Fill(key);
RandomNumberGenerator.Fill(tweak);
using var cipher = new Serpent512Cipher(key, tweak);
byte[] plaintext = new byte[64];
byte[] ciphertext = new byte[64];
cipher.Encrypt(plaintext, ciphertext);
byte[] roundtrip = new byte[64];
cipher.Decrypt(ciphertext, roundtrip);
// roundtrip equals plaintext
Remarks
The cipher runs 64 rounds over a sixteen-word (512-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 Serpent512 class, which exposes the standard SymmetricAlgorithm contract. Use Serpent512Cipher 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
Serpent512Cipher(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Initializes a new instance of the Serpent512Cipher class using the specified key and tweak.
public Serpent512Cipher(ReadOnlySpan<byte> key, ReadOnlySpan<byte> tweak)
Parameters
keyReadOnlySpan<byte>The 512-bit (64-byte) key used for encryption and decryption.
tweakReadOnlySpan<byte>The 128-bit (16-byte) tweak value used to modify the block cipher behavior.
Fields
KeySize
Length of the Serpent-512 key is 512 bits (64 bytes).
public const int KeySize = 512
Field Value
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
| Product | Versions |
|---|---|
| .NET | 8, 10 |