Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / XML

RFC3394 Key-wrapping Algorithm in C#

Rate me:
Please Sign up or sign in to vote.
4.80/5 (9 votes)
31 Oct 2008Public Domain3 min read 42.9K   1.7K   25  
An implementation of the RFC3394 AES key-wrapping algorithm.
<?xml version="1.0"?>
<doc>
    <assembly>
        <name>RFC3394</name>
    </assembly>
    <members>
        <member name="T:RFC3394.Block">
            <summary>
            A <b>Block</b> contains exactly 64 bits of data.  This class
            provides several handy block-level operations.
            </summary>
        </member>
        <member name="T:RFC3394.KeyWrapAlgorithm">
            <summary>
            An implementation of the RFC3394 key-wrapping algorithm.
            </summary>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.#ctor(System.Byte[])">
            <summary>
            Constructs a <b>KeyWrapAlgorithm</b> object with the specified key-encryption key.
            </summary>
            <param name="kek">The key-encryption key to use for subsequent wrapping and unwrapping operations.  This must be a valid AES key.</param>
            <exception cref="T:System.ArgumentNullException"><c>kek</c> was a null reference.</exception>
            <exception cref="T:System.ArgumentOutOfRangeException"><c>kek</c> must be a valid AES key, either 128, 192 or 256 bits long.</exception>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.WrapKey(System.Byte[])">
            <summary>
            Wrap key data.
            </summary>
            <param name="plaintext">The key data, two or more 8-byte blocks.</param>
            <returns>The encrypted, wrapped data.</returns>
            <exception cref="T:System.ArgumentNullException"><c>plaintext</c> was <b>null</b>.</exception>
            <exception cref="T:System.ArgumentOutOfRangeException">The plaintext contained fewer than 16 bytes.</exception>
            <exception cref="T:System.ArgumentException"><c>plaintext</c> was not made up of 64-bit blocks.</exception>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.UnwrapKey(System.Byte[])">
            <summary>
            Unwrap encrypted key data.
            </summary>
            <param name="ciphertext">The encrypted key data, two or more 8-byte blocks.</param>
            <returns>The original key data.</returns>
            <exception cref="T:System.ArgumentNullException"><c>ciphertext</c> was <b>null</b>.</exception>
            <exception cref="T:System.ArgumentOutOfRangeException">The ciphertext contained fewer than 16 bytes.</exception>
            <exception cref="T:System.ArgumentException"><c>ciphertext</c> was not made up of 64-bit blocks.</exception>
            <exception cref="T:System.Security.Cryptography.CryptographicException">The decryption process failed an integrity check.</exception>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.WrapKey(System.Byte[],System.Byte[])">
            <summary>
            Wrap key data with a key-encryption key.
            </summary>
            <param name="kek">The key encryption key.  This must be a valid AES key.</param>
            <param name="plaintext">The key data, two or more 8-byte blocks.</param>
            <returns>The encrypted, wrapped data.</returns>
            <exception cref="T:System.ArgumentNullException">One or more arguments was <b>null</b>.</exception>
            <exception cref="T:System.ArgumentOutOfRangeException">Either <c>kek</c> was an invalid AES key, or the plaintext contained fewer than 16 bytes.</exception>
            <exception cref="T:System.ArgumentException"><c>plaintext</c> was not made up of 64-bit blocks.</exception>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.UnwrapKey(System.Byte[],System.Byte[])">
            <summary>
            Unwrap key data with a key-decryption key.
            </summary>
            <param name="kek">The key-decryption key.  This must be a valid AES key.</param>
            <param name="ciphertext">The encrypted key data, two or more 8-byte blocks.</param>
            <returns>The original key data.</returns>
            <exception cref="T:System.ArgumentNullException">One or more arguments was <b>null</b>.</exception>
            <exception cref="T:System.ArgumentOutOfRangeException">Either <c>kek</c> was an invalid AES key, or the ciphertext contained fewer than 16 bytes.</exception>
            <exception cref="T:System.ArgumentException"><c>ciphertext</c> was not made up of 64-bit blocks.</exception>
            <exception cref="T:System.Security.Cryptography.CryptographicException">The decryption process failed an integrity check.</exception>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.ValidateKEK(System.Byte[])">
            <summary>
            Validates a key encryption key.
            </summary>
            <param name="kek">The key encryption key (KEK) to validate.</param>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.ValidateInput(System.Byte[],System.String)">
            <summary>
            Validates the input to the (un)wrapping methods.
            </summary>
            <param name="input">Input to validate.</param>
            <param name="paramName">Name to use for exception messages.</param>
            <remarks>n must be at least 2, see §2.</remarks>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.Encrypt(System.Byte[])">
            <summary>
            Encrypts a block of plaintext with AES.
            </summary>
            <param name="plaintext">Plaintext to encrypt.</param>
            <returns><see cref="T:RFC3394.Block"/> containing the ciphertext bytes.</returns>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.Decrypt(System.Byte[])">
            <summary>
            Decrypts a block of ciphertext with AES.
            </summary>
            <param name="ciphertext">Ciphertext to decrypt.</param>
            <returns><see cref="T:RFC3394.Block"/> containing the plaintext bytes.</returns>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.MSB(RFC3394.Block[])">
            <summary>
            Retrieves the 64 most significant bits of a 128-bit <see cref="T:RFC3394.Block"/>[].
            </summary>
            <param name="B">An array of two blocks (128 bits).</param>
            <returns>The 64 most significant bits of <paramref name="B"/>.</returns>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.LSB(RFC3394.Block[])">
            <summary>
            Retrieves the 64 least significant bits of a 128-bit <see cref="T:RFC3394.Block"/>[].
            </summary>
            <param name="B">An array of two blocks (128 bits).</param>
            <returns>The 64 most significant bits of <paramref name="B"/>.</returns>
        </member>
        <member name="M:RFC3394.KeyWrapAlgorithm.ArraysAreEqual(System.Byte[],System.Byte[])">
            <summary>
            Tests whether two arrays have the same contents.
            </summary>
            <param name="array1">The first array.</param>
            <param name="array2">The second array.</param>
            <returns><b>true</b> if the two arrays have the same contents, otherwise <b>false</b>.</returns>
        </member>
        <member name="T:RFC3394.Strings">
            <summary>
              A strongly-typed resource class, for looking up localized strings, etc.
            </summary>
        </member>
        <member name="P:RFC3394.Strings.ResourceManager">
            <summary>
              Returns the cached ResourceManager instance used by this class.
            </summary>
        </member>
        <member name="P:RFC3394.Strings.Culture">
            <summary>
              Overrides the current thread's CurrentUICulture property for all
              resource lookups using this strongly typed resource class.
            </summary>
        </member>
        <member name="P:RFC3394.Strings.BufferLengthError">
            <summary>
              Looks up a localized string similar to Insufficient buffer size..
            </summary>
        </member>
        <member name="P:RFC3394.Strings.DivisibleBy8Error">
            <summary>
              Looks up a localized string similar to Length of bytes must be a multiple of 8..
            </summary>
        </member>
        <member name="P:RFC3394.Strings.IntegrityError">
            <summary>
              Looks up a localized string similar to Integrity check failed..
            </summary>
        </member>
    </members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Architect DigiData Corp.
United States United States
Not much to tell, really!

Comments and Discussions