Example #1
0
      public override void Erase(Stream strm, long erasureLength, Prng prng,
 ErasureMethodProgressFunction callback)
      {
          if (method == null || method.Guid == Guid)
          throw new InvalidOperationException(S._("The First/last 16KB erasure method " +
           "requires another erasure method to erase the file.\n\nThis must " +
           "be set in the Plugin Settings dialog."));
             if (erasureLength != long.MaxValue)
          throw new ArgumentException(S._("The amount of data erased should not be " +
           "limited, since this is a self-limiting erasure method."));
             if (strm.Length < dataSize)
             {
          method.Erase(strm, erasureLength, prng, callback);
          return;
             }
             strm.Seek(0, SeekOrigin.Begin);
             method.Erase(strm, dataSize, prng, callback);
             strm.Seek(-dataSize, SeekOrigin.End);
             method.Erase(strm, long.MaxValue, prng, callback);
      }
Example #2
0
 public static void Register(Prng prng)
 {
     lock (ManagerLibrary.Instance.PRNGManager.prngs)
     ManagerLibrary.Instance.PRNGManager.prngs.Add(prng.Guid, prng);
 }
Example #3
0
      public abstract void Erase(Stream stream, long erasureLength, Prng prng,
 ErasureMethodProgressFunction callback);
Example #4
0
 public virtual void EraseUnusedSpace(Stream stream, Prng prng, ErasureMethodProgressFunction callback)
 {
     Erase(stream, long.MaxValue, prng, callback);
 }
Example #5
0
      public override void Erase(Stream stream, long erasureLength, Prng prng,
 ErasureMethodProgressFunction callback)
      {
          ErasureMethodPass[] randomizedPasses = PassesSet;
             if (RandomizePasses)
          randomizedPasses = ShufflePasses(randomizedPasses);
             long strmStart = stream.Position;
             long strmLength = Math.Min(stream.Length - strmStart, erasureLength);
             long totalData = CalculateEraseDataSize(null, strmLength);
             byte[] buffer = new byte[Math.Min(DiskOperationUnit, strmLength)];
             for (int pass = 0; pass < Passes; ++pass)
             {
          if (callback != null)
           callback(0, totalData, pass + 1);
          stream.Seek(strmStart, SeekOrigin.Begin);
          long toWrite = strmLength;
          int dataStopped = buffer.Length;
          while (toWrite > 0)
          {
           int amount = (int)Math.Min(toWrite, buffer.Length - dataStopped);
           if (amount == 0)
           {
            randomizedPasses[pass].Execute(buffer, prng);
            dataStopped = 0;
            continue;
           }
           stream.Write(buffer, dataStopped, amount);
           stream.Flush();
           toWrite -= amount;
           if (callback != null)
            callback(amount, totalData, pass + 1);
          }
             }
      }
Example #6
0
 public void Execute(byte[] buffer, Prng prng)
 {
     Function(buffer, OpaqueValue == null ? prng : OpaqueValue);
 }
Example #7
0
         public override void Erase(Stream strm, long erasureLength, Prng prng,
 ErasureMethodProgressFunction callback)
         {
             throw new InvalidOperationException(S._("The DefaultMethod class should never " +
              "be used and should instead be replaced before execution!"));
         }