Exemplo n.º 1
0
        /// <summary>
        /// Static method to create a protected key from a plaintext key.  It will wipe the reference that was passed in once the protected key instance is initialized
        /// </summary>
        /// <param name="plaintextKey">The key</param>
        /// <returns>A protected key instance from the provided key</returns>
        public static InMemoryKey CreateProtectedKeyAndDestroyPlaintextKey(byte[] plaintextKey)
        {
            var key = new InMemoryKey(plaintextKey);

            // the protected key creates a copy of the key and pads it as needed for in memory protection.
            // Thus the reference that was passed in isn't needed.  Overwrite it with random garbage.
            KeyUtilities.Destroy(plaintextKey);
            return(key);
        }
 /// <summary>
 /// Static method to create a protected key from a plaintext key.  It will wipe the reference that was passed in once the protected key instance is initialized
 /// </summary>
 /// <param name="plaintextKey">The key</param>
 /// <returns>A protected key instance from the provided key</returns>
 public static InMemoryKey CreateProtectedKeyAndDestroyPlaintextKey(byte[] plaintextKey)
 {
     var key = new InMemoryKey(plaintextKey);
     // the protected key creates a copy of the key and pads it as needed for in memory protection.
     // Thus the reference that was passed in isn't needed.  Overwrite it with random garbage.
     KeyUtilities.Destroy(plaintextKey);
     return key;
 }