SkeinFish is an implementation of Skein and Threefish, with a focus on speed and completeness. Skein is a general purpose hash algorithm and Threefish is a general purpose block cipher. Both were designed by Bruce Schneier, among others.
This is an implementation of both algorithms in C#. Version 0.3.5 implements Skein 1.2.
Quick and Dirty usage guide
First, add a reference to SkeinFish.dll to your project. Next, use as such:
using SkeinFish;
static byte[] hash_skein(byte[] input)
{
// (state_size, output_size)
Skein skein = new Skein(512, 512);
return skein.ComputeHash(input, 0, input.Length);
}
Key Generation
It may just happen that you want to use Skein to generate keys from passwords. It would probably suffice to just use the hash as you would any other to generate a key. However, the Skein paper describes how to configure the hash for whatever it is you're hashing. Changing the configure has the basic effect of using different IV values for the hash. Changing the hash's payload type is supported in SkeinFish, as follows:
// Generates a 512-bit key from a password
static byte[] generate_key(string password)
{
// (state_size, output_size)
Skein skein = new Skein(512, 512);
skein.UBIPayloadType = UBIType.Key; // Set UBI payload type to the Key type
// (this automatically [Re]Initializes the hash,
// so don't do this between block transforms, only when
// you are finished with a particular message)
skein.TransformFinalBlock(ASCIIEncoding.ASCII.GetBytes(password), 0, password.Length);
return skein.Hash;
}Using Threefish
The Threefish block cipher is also implemented as part of SkeinFish (hence the name). To use it, simply instantiate a Threefish object and use it as you would any other cipher in the .NET library. It supports all encryption modes except CTS. All padding modes are supported.