public void Archive(Stream outputStream, ProtectedKey keyToBeArchived, string passphrase) { byte[] bytes = BitConverter.GetBytes(0x10e1); byte[] salt = this.GenerateSalt(); byte[] buffer = this.GetEncryptedKey(keyToBeArchived, passphrase, salt); outputStream.Write(bytes, 0, bytes.Length); outputStream.Write(salt, 0, salt.Length); outputStream.Write(buffer, 0, buffer.Length); }
public SymmetricAlgorithmProvider(Type algorithmType, ProtectedKey key) { if (algorithmType == null) { throw new ArgumentNullException("algorithmType"); } if (!typeof(SymmetricAlgorithm).IsAssignableFrom(algorithmType)) { throw new ArgumentException("The type must be of type SymmetricAlgorithm.", "algorithmType"); } this.algorithmType = algorithmType; this.key = key; }
byte[] GetEncryptedKey(ProtectedKey keyToBeArchived, string passphrase, byte[] salt) { byte[] buffer2; byte[] decryptedKey = keyToBeArchived.DecryptedKey; try { buffer2 = this.EncryptKeyForArchival(decryptedKey, passphrase, salt); } finally { CryptographyUtility.ZeroOutBytes(decryptedKey); } return buffer2; }
byte[] GetEncryptedKey(ProtectedKey keyToBeArchived, string passphrase, byte[] salt) { byte[] buffer2; byte[] decryptedKey = keyToBeArchived.DecryptedKey; try { buffer2 = this.EncryptKeyForArchival(decryptedKey, passphrase, salt); } finally { CryptographyUtility.ZeroOutBytes(decryptedKey); } return(buffer2); }
public SymmetricCryptographer(Type algorithmType, ProtectedKey key) { if (algorithmType == null) { throw new ArgumentNullException("algorithmType"); } if (!typeof(SymmetricAlgorithm).IsAssignableFrom(algorithmType)) { throw new ArgumentException("The type must be of type SymmetricAlgorithm.", "algorithmType"); } if (key == null) { throw new ArgumentNullException("key"); } this.key = key; this.algorithm = GetSymmetricAlgorithm(algorithmType); }
ProtectedKey GenerateKey(SymmetricAlgorithm algorithm, DataProtectionScope dataProtectionScope) { ProtectedKey key; byte[] plaintextKey = this.GenerateUnprotectedKey(algorithm); try { key = ProtectedKey.CreateFromPlaintextKey(plaintextKey, dataProtectionScope); } finally { if (plaintextKey != null) { CryptographyUtility.ZeroOutBytes(plaintextKey); } } return(key); }
public static void ArchiveKey(Stream outputStream, ProtectedKey keyToArchive, string passphrase) { IKeyWriter writer = new KeyReaderWriter(); writer.Archive(outputStream, keyToArchive, passphrase); }
public void Write(Stream outputStream, ProtectedKey key) { this.WriteVersionNumber(outputStream, 0x10e1); this.WriteEncryptedKey(outputStream, key); }
public static void Write(Stream outputStream, ProtectedKey key) { IKeyWriter writer = new KeyReaderWriter(); writer.Write(outputStream, key); }
void WriteEncryptedKey(Stream outputStream, ProtectedKey key) { outputStream.Write(key.EncryptedKey, 0, key.EncryptedKey.Length); }
public HashCryptographer(Type algorithmType, ProtectedKey protectedKey) : this(algorithmType) { this.key = protectedKey; }
public ProtectedKey Read(Stream protectedKeyStream, DataProtectionScope protectionScope) { this.ValidateKeyVersion(protectedKeyStream); return(ProtectedKey.CreateFromEncryptedKey(this.ReadEncryptedKey(protectedKeyStream), protectionScope)); }
public static void Write(Stream outputStream, byte[] encryptedKey, DataProtectionScope dpapiProtectionScope) { ProtectedKey key = ProtectedKey.CreateFromEncryptedKey(encryptedKey, dpapiProtectionScope); Write(outputStream, key); }