Threefish1024 Class
Definition
- Namespace
- Bodu.Security.Cryptography
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
- Source
- Threefish.1024.cs
Provides a managed implementation of the Threefish-1024 tweakable 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 Threefish1024 : Threefish, IDisposable
- Inheritance
-
Threefish1024
- Implements
- Inherited Members
- Extension Methods
Examples
using System.Security.Cryptography;
using Bodu.Security.Cryptography;
using Bodu.Security.Cryptography.Extensions;
using var tf = Threefish1024.Create();
tf.Key = RandomNumberGenerator.GetBytes(128); // 1024-bit key
tf.IV = RandomNumberGenerator.GetBytes(128); // matches the 1024-bit block
tf.Tweak = RandomNumberGenerator.GetBytes(16); // 128-bit tweak
byte[] ciphertext = tf.Encrypt(plaintext);
byte[] roundTrip = tf.Decrypt(ciphertext);
Remarks
Threefish is the tweakable block cipher underlying the Skein hash function. This variant supports a variety of cipher block modes (CBC, CFB, OFB, CTR) via the BlockMode property, and is suitable for scenarios such as disk encryption or format-preserving encryption where a tweak is useful.
For other block sizes, see Threefish256 and Threefish512.
Parameters at a glance.
- Block size: 1024 bits (128 bytes).
- Key size: 1024 bits (128 bytes).
- Tweak size: 128 bits (16 bytes).
- Default mode: CBC; default padding: PKCS7.
When to choose Threefish-1024. The widest Threefish variant - pick it when the surrounding construction (Skein-1024, custom long-tweak schemes, or extreme-margin disk-encryption layouts) requires the 1024-bit block. Throughput is lower than the 512-bit variant; the 256/512-bit variants are more practical defaults unless the wider block is a hard requirement.
Constructors
Threefish1024()
Initializes a new instance of the Threefish1024 class using a 1024-bit block size, 1024-bit key, and 128-bit tweak.
public Threefish1024()
Methods
Create()
Creates a new Threefish1024 instance with default parameters.
public static Threefish1024 Create()
Returns
- Threefish1024
A new Threefish1024 instance.
Remarks
CreateCipher(byte[], byte[])
Instantiates the concrete Threefish block cipher with the specified key and tweak.
protected override ThreefishBlockCipher CreateCipher(byte[] key, byte[] tweak)
Parameters
Returns
- ThreefishBlockCipher
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 |