Exemple #1
0
 private unsafe UnmanagedArray <byte> Decrypt2(byte[] bytes, ICryptoTransform transform)
 {
     byte[] managedBytes = transform.TransformFinalBlock(bytes, 0, bytes.Length);
     //pin it ASAP. this is a small race condition that is unavoidable due
     //to the way the crypto API's return byte[].
     fixed(byte *dummy = managedBytes)
     {
         try
         {
             UnmanagedByteArray rv = new UnmanagedByteArray(managedBytes.Length);
             for (int i = 0; i < rv.Length; i++)
             {
                 rv[i] = managedBytes[i];
             }
             return(rv);
         }
         finally
         {
             SecurityUtil.Clear(managedBytes);
         }
     }
 }
Exemple #2
0
 private unsafe UnmanagedArray<byte> Decrypt2(byte[] bytes, ICryptoTransform transform)
 {
     byte[] managedBytes = transform.TransformFinalBlock(bytes, 0, bytes.Length);
     //pin it ASAP. this is a small race condition that is unavoidable due
     //to the way the crypto API's return byte[].
     fixed (byte* dummy = managedBytes)
     {
         try
         {
             UnmanagedByteArray rv = new UnmanagedByteArray(managedBytes.Length);
             for (int i = 0; i < rv.Length; i++)
             {
                 rv[i] = managedBytes[i];
             }
             return rv;
         }
         finally
         {
             SecurityUtil.Clear(managedBytes);
         }
     }
 }