Table of Contents

Threefish256 Class

Definition

Namespace
Bodu.Security.Cryptography
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
Threefish.256.cs

Provides a managed implementation of the Threefish-256 tweakable symmetric block cipher, which operates on 256-bit (32-byte) blocks using a 256-bit key and a 128-bit tweak. This class cannot be inherited.

public sealed class Threefish256 : Threefish, IDisposable
Inheritance
Threefish256
Implements
Inherited Members
Extension Methods

Examples

using System.Security.Cryptography;
using Bodu.Security.Cryptography;
using Bodu.Security.Cryptography.Extensions;

using var tf = Threefish256.Create();
tf.Key = RandomNumberGenerator.GetBytes(32); // 256-bit key
tf.IV = RandomNumberGenerator.GetBytes(32); // matches the 256-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 Threefish512 and Threefish1024.

Parameters at a glance.

  • Block size: 256 bits (32 bytes).
  • Key size: 256 bits (32 bytes).
  • Tweak size: 128 bits (16 bytes).
  • Default mode: CBC; default padding: PKCS7.

When to choose Threefish-256. Pick the 256-bit variant when you want a tweakable block cipher at a comparable security margin to AES-256 with a smaller block than the wider Threefish variants - useful for per-record encryption or short-tweak-driven schemes. Reach for Threefish512 when a wider block reduces birthday-bound exposure on long messages, or for Threefish1024 when the surrounding construction (e.g. a custom Skein-based AEAD) demands the widest block. For general-purpose encryption without a tweak requirement, prefer Aes.

Constructors

Threefish256()

Initializes a new instance of the Threefish256 class using a 256-bit block size, 256-bit key, and 128-bit tweak.

public Threefish256()

Methods

Create()

Creates a new Threefish256 instance with default parameters.

public static Threefish256 Create()

Returns

Threefish256

A new Threefish256 instance.

Remarks

The key, initialization vector, and tweak are generated on demand the first time they are accessed unless assigned explicitly via Key, IV, or Tweak.

CreateCipher(byte[], byte[])

Instantiates the concrete Threefish block cipher with the specified key and tweak.

protected override ThreefishBlockCipher CreateCipher(byte[] key, byte[] tweak)

Parameters

key byte[]

The encryption key.

tweak byte[]

The tweak value.

Returns

ThreefishBlockCipher

A configured IBlockCipher instance for encryption or decryption.

Exceptions

ArgumentNullException

Thrown when key is null.

CryptographicException

Thrown when the underlying cryptographic algorithm fails.

Applies to

ProductVersions
.NET8, 10

See Also