コード例 #1
0
        /// <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="ArgumentNullException">One or more arguments was <b>null</b>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Either <c>kek</c> was an invalid AES key, or the ciphertext contained fewer than 16 bytes.</exception>
        /// <exception cref="ArgumentException"><c>ciphertext</c> was not made up of 64-bit blocks.</exception>
        /// <exception cref="CryptographicException">The decryption process failed an integrity check.</exception>
        public static byte[] UnwrapKey(byte[] kek, byte[] ciphertext)
        {
            KeyWrapAlgorithm kwa = new KeyWrapAlgorithm(kek);

            return(kwa.UnwrapKey(ciphertext));
        }
コード例 #2
0
        /// <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="ArgumentNullException">One or more arguments was <b>null</b>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Either <c>kek</c> was an invalid AES key, or the plaintext contained fewer than 16 bytes.</exception>
        /// <exception cref="ArgumentException"><c>plaintext</c> was not made up of 64-bit blocks.</exception>
        public static byte[] WrapKey(byte[] kek, byte[] plaintext)
        {
            KeyWrapAlgorithm kwa = new KeyWrapAlgorithm(kek);

            return(kwa.WrapKey(plaintext));
        }