/// <overloads> /// Reads an encrypted key from an input stream. This method is not intended to allow keys to be transferred /// from another machine. /// </overloads> /// <summary> /// Reads an encrypted key from an input stream. This method is not intended to allow keys to be transferred /// from another machine. /// </summary> /// <param name="inputStream"><see cref="Stream"/> from which DPAPI-protected key is to be read.</param> /// <param name="dpapiProtectionScope"><see cref="DataProtectionScope"/> used to protect the key on disk. </param> /// <returns>Key read from stream, encapsulated in a <see cref="ProtectedKey"></see>.</returns> public static ProtectedKey Read(Stream inputStream, DataProtectionScope dpapiProtectionScope) { IKeyReader reader = new KeyReaderWriter(); ProtectedKey key = reader.Read(inputStream, dpapiProtectionScope); return(key); }
/// <summary> /// Writes an encrypted key to an output stream. This method is not intended to allow the keys to be /// moved from machine to machine. /// </summary> /// <param name="outputStream"><see cref="Stream"/> to which DPAPI-protected key is to be written.</param> /// <param name="key">Encrypted key to be written to stream.</param> public static void Write(Stream outputStream, ProtectedKey key) { IKeyWriter writer = new KeyReaderWriter(); writer.Write(outputStream, key); }
/// <summary> /// Archives a cryptographic key to a <see cref="Stream"/>. This method is intended for use in /// transferring a key between machines. /// </summary> /// <param name="outputStream"><see cref="Stream"/> to which key is to be archived.</param> /// <param name="keyToArchive">Key to be archived.</param> /// <param name="passphrase">User-provided passphrase used to encrypt the key in the arhive.</param> public static void ArchiveKey(Stream outputStream, ProtectedKey keyToArchive, string passphrase) { IKeyWriter writer = new KeyReaderWriter(); writer.Archive(outputStream, keyToArchive, passphrase); }
/// <overloads> /// Reads an encrypted key from an input stream. This method is not intended to allow keys to be transferred /// from another machine. /// </overloads> /// <summary> /// Reads an encrypted key from an input stream. This method is not intended to allow keys to be transferred /// from another machine. /// </summary> /// <param name="inputStream"><see cref="Stream"/> from which DPAPI-protected key is to be read.</param> /// <param name="dpapiProtectionScope"><see cref="DataProtectionScope"/> used to protect the key on disk. </param> /// <returns>Key read from stream, encapsulated in a <see cref="ProtectedKey"></see>.</returns> public static ProtectedKey Read(Stream inputStream, DataProtectionScope dpapiProtectionScope) { IKeyReader reader = new KeyReaderWriter(); ProtectedKey key = reader.Read(inputStream, dpapiProtectionScope); return key; }
/// <summary> /// Archives a cryptographic key to a <see cref="Stream"/>. This method is intended for use in /// transferring a key between machines. /// </summary> /// <param name="outputStream"><see cref="Stream"/> to which key is to be archived.</param> /// <param name="keyToArchive">Key to be archived.</param> /// <param name="passphrase">User-provided passphrase used to encrypt the key in the arhive.</param> public static void ArchiveKey(Stream outputStream, ProtectedKey keyToArchive, string passphrase) { IKeyWriter writer = new KeyReaderWriter(); writer.Archive(outputStream, keyToArchive, passphrase); }
/// <summary> /// Restores a cryptogrpahic key from a <see cref="Stream"/>. This method is intended for use in /// transferring a key between machines. /// </summary> /// <param name="inputStream"><see cref="Stream"/> from which key is to be restored.</param> /// <param name="passphrase">User-provided passphrase used to encrypt the key in the arhive.</param> /// <param name="protectionScope"><see cref="DataProtectionScope"/> used to protect the key on disk. </param> /// <returns>Key restored from stream, encapsulated in a <see cref="ProtectedKey"></see>.</returns> public static ProtectedKey RestoreKey(Stream inputStream, string passphrase, DataProtectionScope protectionScope) { IKeyReader reader = new KeyReaderWriter(); return(reader.Restore(inputStream, passphrase, protectionScope)); }
/// <summary> /// Writes an encrypted key to an output stream. This method is not intended to allow the keys to be /// moved from machine to machine. /// </summary> /// <param name="outputStream"><see cref="Stream"/> to which DPAPI-protected key is to be written.</param> /// <param name="key">Encrypted key to be written to stream.</param> public static void Write(Stream outputStream, ProtectedKey key) { IKeyWriter writer = new KeyReaderWriter(); writer.Write(outputStream, key); }
/// <summary> /// Restores a cryptogrpahic key from a <see cref="Stream"/>. This method is intended for use in /// transferring a key between machines. /// </summary> /// <param name="inputStream"><see cref="Stream"/> from which key is to be restored.</param> /// <param name="passphrase">User-provided passphrase used to encrypt the key in the arhive.</param> /// <param name="protectionScope"><see cref="DataProtectionScope"/> used to protect the key on disk. </param> /// <returns>Key restored from stream, encapsulated in a <see cref="ProtectedKey"></see>.</returns> public static ProtectedKey RestoreKey(Stream inputStream, string passphrase, DataProtectionScope protectionScope) { IKeyReader reader = new KeyReaderWriter(); return reader.Restore(inputStream, passphrase, protectionScope); }