Serpent1024 Class
Definition
- Namespace
- Bodu.Security.Cryptography
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
- Source
- Serpent.1024.cs
Provides a managed implementation of the non-standard wide-block tweakable Serpent-1024 symmetric block
cipher, 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 Serpent1024 : Serpent, IDisposable
- Inheritance
-
Serpent1024
- Implements
- Inherited Members
- Extension Methods
Examples
using System.Security.Cryptography;
using Bodu.Security.Cryptography;
using Bodu.Security.Cryptography.Extensions;
using var serpent = Serpent1024.Create();
serpent.Key = RandomNumberGenerator.GetBytes(128); // 1024-bit key
serpent.IV = RandomNumberGenerator.GetBytes(128); // matches the 1024-bit block
serpent.Tweak = RandomNumberGenerator.GetBytes(16); // 128-bit tweak
byte[] ciphertext = serpent.Encrypt(plaintext);
byte[] roundTrip = serpent.Decrypt(ciphertext);
Remarks
This variant runs the Serpent round function over a thirty-two-word state for 80 rounds, injecting a tweak subkey every four rounds in the style of Threefish. It supports the extended block cipher modes exposed by CipherModeKind via the BlockMode property.
For other block sizes, see Serpent256 and Serpent512.
Parameters at a glance.
- Block size: 1024 bits (128 bytes).
- Key size: 1024 bits (128 bytes).
- Tweak size: 128 bits (16 bytes).
- 80 rounds; tweak subkey injected every 4 rounds.
- Default mode: CBC; default padding: PKCS7.
When to choose Serpent-1024. The widest wide-block Serpent variant - purely experimental, for scenarios where a 1024-bit tweakable block with Serpent's round function is required. Threefish1024 is the better-studied alternative. Throughput drops markedly relative to the 256/512-bit Serpent variants. Use Serpent128 for any production scenario that requires interoperable Serpent.
important
Serpent-1024 (this type) is a non-standard Serpent-derived construction and is not interoperable with any reference Serpent implementation. For standard, externally vetted Serpent, use Serpent128.
Constructors
Serpent1024()
Initializes a new instance of the Serpent1024 class using a 1024-bit block size, 1024-bit key, and 128-bit tweak.
public Serpent1024()
Methods
Create()
Creates a new Serpent1024 instance with default parameters.
public static Serpent1024 Create()
Returns
- Serpent1024
A new Serpent1024 instance.
Remarks
CreateCipher(byte[], byte[])
Instantiates the concrete Serpent block cipher with the specified key and tweak.
protected override IBlockCipher CreateCipher(byte[] key, byte[] tweak)
Parameters
Returns
- IBlockCipher
A configured IBlockCipher instance for encryption or decryption.
Exceptions
- ArgumentNullException
Thrown when
keyis null.- CryptographicException
Thrown when the underlying cryptographic algorithm fails.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |