예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
 static byte[] Transform(ICryptoTransform transform, byte[] buffer)
 {
     return(CryptographyUtility.Transform(transform, buffer));
 }