Skipjack Class
Definition
- Namespace
- Bodu.Security.Cryptography
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
- Source
- Skipjack.cs
Provides a managed implementation of the Skipjack symmetric block cipher, exposing the SkipjackBlockCipher engine through the standard SymmetricAlgorithm framework. This class cannot be inherited.
public sealed class Skipjack : ExtendedSymmetricAlgorithm, IDisposable
- Inheritance
-
Skipjack
- Implements
- Inherited Members
- Extension Methods
Examples
using System.Security.Cryptography;
using Bodu.Security.Cryptography;
using Bodu.Security.Cryptography.Extensions;
// Legacy interop only - do not use Skipjack to protect new data.
using var skipjack = new Skipjack();
skipjack.Key = legacyKeyMaterial; // exactly 10 bytes
skipjack.IV = RandomNumberGenerator.GetBytes(8); // matches the 64-bit block
byte[] ciphertext = skipjack.Encrypt(legacyPlaintext);
Remarks
Skipjack is a block cipher designed by the United States National Security Agency (NSA), specified in FIPS PUB 185 (1994) and declassified in 1998. It operates on 64-bit (8-byte) blocks, uses a fixed 80-bit (10-byte) key, and applies an unbalanced Feistel network across 32 rounds whose round function alternates between two rules known as Rule A and Rule B. Skipjack is supported here for legacy and research scenarios only.
This class integrates with the .NET SymmetricAlgorithm framework and supports standard block cipher modes via the BlockMode property. The default mode is CBC with PKCS7 padding.
Parameters at a glance.
- Block size: 64 bits (8 bytes).
- Key size: 80 bits (10 bytes), fixed.
- 32 rounds, unbalanced Feistel network.
- Default mode: CBC; default padding: PKCS7.
When to choose Skipjack. Only when reading or producing data encrypted under a Skipjack-based legacy system, or when reproducing published test vectors for research. For any new design use Aes or another 128-bit block cipher.
important
Because of its 80-bit key and 64-bit block, Skipjack offers no modern security margin and must not be used to protect sensitive data in new applications. The 64-bit block size also exposes it to birthday-bound attacks (SWEET32) when large volumes of data are encrypted under the same key. Prefer a modern cipher such as AES.
The underlying block-cipher implementation is constant-time in its control flow, but the S-box lookup table remains data-dependent. As such, it is not hardened against timing or cache-based side-channel attacks.
Constructors
Skipjack()
Initializes a new instance of the Skipjack class with the fixed 80-bit key size and 64-bit block size, CBC cipher mode, and PKCS7 padding.
public Skipjack()
Remarks
Call GenerateKey() and GenerateIV() to produce random key material, or assign Key and IV directly before calling CreateEncryptor(byte[], byte[]?) or CreateDecryptor(byte[], byte[]?).
Methods
CreateDecryptor(byte[], byte[]?)
Creates a symmetric Skipjack decryptor using the specified key and initialization vector.
public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV)
Parameters
rgbKeybyte[]The secret key for the symmetric algorithm. Must be exactly 10 bytes (80 bits) in length. Must not be null.
rgbIVbyte[]The initialization vector. Must be exactly 8 bytes (64 bits) in length and must not be null for any cipher mode other than ECB.
Returns
- ICryptoTransform
A symmetric Skipjack decryptor object implementing ICryptoTransform.
Exceptions
- ObjectDisposedException
The current instance has been disposed.
- ArgumentNullException
rgbKeyorrgbIVis null.- CryptographicException
rgbKeyis not exactly 10 bytes in length, orrgbIVis not exactly 8 bytes in length.
CreateEncryptor(byte[], byte[]?)
Creates a symmetric Skipjack encryptor using the specified key and initialization vector.
public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV)
Parameters
rgbKeybyte[]The secret key for the symmetric algorithm. Must be exactly 10 bytes (80 bits) in length. Must not be null.
rgbIVbyte[]The initialization vector. Must be exactly 8 bytes (64 bits) in length and must not be null for any cipher mode other than ECB.
Returns
- ICryptoTransform
A symmetric Skipjack encryptor object implementing ICryptoTransform.
Exceptions
- ObjectDisposedException
The current instance has been disposed.
- ArgumentNullException
rgbKeyorrgbIVis null.- CryptographicException
rgbKeyis not exactly 10 bytes in length, orrgbIVis not exactly 8 bytes in length.
Dispose(bool)
Releases the unmanaged resources used by the Skipjack instance and, optionally, the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Remarks
Clears any cached key material and initialization vector before delegating to the base implementation. This method is idempotent and safe to call multiple times.
GenerateIV()
Generates a cryptographically random initialization vector (IV) suitable for use with the Skipjack algorithm.
public override void GenerateIV()
Remarks
The generated IV length is determined by the algorithm block size.
The generated IV is assigned to IV.
A new IV should be generated for each independent encryption operation when reusing a Skipjack instance with the same key.
Exceptions
- ObjectDisposedException
The current instance has been disposed.
GenerateKey()
Generates a cryptographically random key for use with the Skipjack algorithm using the currently configured KeySize.
public override void GenerateKey()
Remarks
Exceptions
- ObjectDisposedException
The current instance has been disposed.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |