Table of Contents

Rabbit Class

Definition

Namespace
Bodu.Security.Cryptography
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
Rabbit.cs

Provides a managed implementation of the Rabbit stream cipher specified by RFC 4503. This class cannot be inherited.

public sealed class Rabbit : SymmetricStreamAlgorithm, IDisposable
Inheritance
Rabbit
Implements
Inherited Members
Extension Methods

Examples

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

using var rabbit = new Rabbit();
rabbit.GenerateKey(); // 128-bit
rabbit.GenerateNonce(); // 64-bit IV
byte[] ciphertext = rabbit.Encrypt(plaintext);
byte[] roundTrip  = rabbit.Decrypt(ciphertext);

Remarks

Rabbit is a high-speed additive stream cipher and an eSTREAM software-portfolio finalist. It uses a 128-bit key and a 64-bit IV to drive an evolving internal state that emits a keystream XORed with the plaintext. This class exposes the raw, confidentiality-only cipher with no authentication; for new designs prefer an AEAD construction.

Like the other stream ciphers in this library it is self-inverse: CreateEncryptor() and CreateDecryptor() are interchangeable. The IV is supplied through the Nonce property.

Parameters at a glance.

  • Key size: 128 bits (16 bytes).
  • Nonce (IV) size: 64 bits (8 bytes).

Nonce reuse is catastrophic. A given (key, IV) pair must encrypt at most one message; reusing it reveals the XOR of the plaintexts. Rabbit has no seekable counter, so a message is encrypted as one forward keystream sequence.

Constructors

Rabbit()

Initializes a new instance of the Rabbit class with default parameters.

public Rabbit()

Remarks

The default configuration uses a 128-bit key and a 64-bit IV.

Methods

Create()

Creates a new Rabbit instance with default parameters.

public static Rabbit Create()

Returns

Rabbit

A new Rabbit instance.

CreateStreamCipher(byte[], byte[])

Builds a configured IStreamCipher engine from the validated key and nonce.

protected override IStreamCipher CreateStreamCipher(byte[] key, byte[] nonce)

Parameters

key byte[]

The key, already validated to the algorithm's key size.

nonce byte[]

The nonce, already validated to the algorithm's nonce size.

Returns

IStreamCipher

A new IStreamCipher engine positioned at the start of its keystream.

Remarks

Implementations receive a key and nonce whose lengths have already been checked by the base class, so they need only construct their engine. Ownership of the returned engine transfers to the caller.

Applies to

ProductVersions
.NET8, 10

See Also