byte[] EncryptKeyForArchival(byte[] keyToExport, string passphrase, byte[] salt) { RijndaelManaged archivalEncryptionAlgorithm = new RijndaelManaged(); byte[] rgbKey = this.GenerateArchivalKey(archivalEncryptionAlgorithm, passphrase, salt); byte[] rgbIV = new byte[archivalEncryptionAlgorithm.BlockSize / 8]; return(CryptographyUtility.Transform(archivalEncryptionAlgorithm.CreateEncryptor(rgbKey, rgbIV), keyToExport)); }
byte[] DecryptKeyForRestore(string passphrase, byte[] encryptedKey, byte[] salt) { RijndaelManaged archivalEncryptionAlgorithm = new RijndaelManaged(); byte[] rgbKey = this.GenerateArchivalKey(archivalEncryptionAlgorithm, passphrase, salt); byte[] rgbIV = new byte[archivalEncryptionAlgorithm.BlockSize / 8]; byte[] buffer3 = CryptographyUtility.Transform(archivalEncryptionAlgorithm.CreateDecryptor(rgbKey, rgbIV), encryptedKey); CryptographyUtility.ZeroOutBytes(rgbKey); return(buffer3); }
static byte[] Transform(ICryptoTransform transform, byte[] buffer) { return(CryptographyUtility.Transform(transform, buffer)); }