Changeset 956
- Timestamp:
- 5/1/2009 5:19:43 AM (4 years ago)
- Location:
- branches/eraser6
- Files:
-
- 14 edited
-
DefaultPlugins/CustomMethodEditorForm.cs (modified) (8 diffs)
-
DefaultPlugins/EraseCustom.cs (modified) (6 diffs)
-
DefaultPlugins/EraseDoD.cs (modified) (3 diffs)
-
DefaultPlugins/EraseFirstLast16KB.cs (modified) (1 diff)
-
DefaultPlugins/EraseGOSTP50739.cs (modified) (1 diff)
-
DefaultPlugins/EraseGutmann.cs (modified) (2 diffs)
-
DefaultPlugins/EraseHMGIS5.cs (modified) (2 diffs)
-
DefaultPlugins/EraseRCMP_TSSIT_OPS_II.cs (modified) (2 diffs)
-
DefaultPlugins/EraseRandom.cs (modified) (1 diff)
-
DefaultPlugins/EraseSchneier.cs (modified) (1 diff)
-
DefaultPlugins/EraseUSAF5020.cs (modified) (2 diffs)
-
DefaultPlugins/EraseUSArmyAR380_19.cs (modified) (2 diffs)
-
DefaultPlugins/EraseVSITR.cs (modified) (1 diff)
-
Manager/Method.cs (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/DefaultPlugins/CustomMethodEditorForm.cs
r950 r956 61 61 62 62 //And all the passes. 63 ErasureMethod .Pass[] passes = new ErasureMethod.Pass[passesLv.Items.Count];63 ErasureMethodPass[] passes = new ErasureMethodPass[passesLv.Items.Count]; 64 64 for (int i = 0; i < passesLv.Items.Count; ++i) 65 passes[i] = (ErasureMethod .Pass)passesLv.Items[i].Tag;65 passes[i] = (ErasureMethodPass)passesLv.Items[i].Tag; 66 66 method.Passes = passes; 67 67 … … 79 79 80 80 //Every pass. 81 foreach (ErasureMethod .Pass pass in method.Passes)81 foreach (ErasureMethodPass pass in method.Passes) 82 82 AddPass(pass); 83 83 } … … 89 89 /// <param name="pass">The pass to add.</param> 90 90 /// <returns>The item added to the list view.</returns> 91 private ListViewItem AddPass(ErasureMethod .Pass pass)91 private ListViewItem AddPass(ErasureMethodPass pass) 92 92 { 93 93 ListViewItem item = new ListViewItem((passesLv.Items.Count + 1).ToString( 94 94 CultureInfo.CurrentCulture)); 95 95 item.Tag = pass; 96 if (pass.Function == ErasureMethod. Pass.WriteRandom)96 if (pass.Function == ErasureMethod.WriteRandom) 97 97 item.SubItems.Add(S._("Random Data")); 98 98 else … … 108 108 private void SavePass(ListViewItem item) 109 109 { 110 ErasureMethod .Pass pass = (ErasureMethod.Pass)item.Tag;110 ErasureMethodPass pass = (ErasureMethodPass)item.Tag; 111 111 if (passEditor.PassType == CustomMethodPassEditorPassType.Random) 112 112 { 113 pass.Function = ErasureMethod. Pass.WriteRandom;113 pass.Function = ErasureMethod.WriteRandom; 114 114 pass.OpaqueValue = null; 115 115 item.SubItems[1].Text = S._("Random Data"); … … 117 117 else 118 118 { 119 pass.Function = ErasureMethod. Pass.WriteConstant;119 pass.Function = ErasureMethod.WriteConstant; 120 120 pass.OpaqueValue = passEditor.PassData; 121 121 item.SubItems[1].Text = S._("Constant ({0} bytes)", passEditor.PassData.Length); … … 130 130 { 131 131 currentPass = item; 132 ErasureMethod .Pass pass = (ErasureMethod.Pass)item.Tag;132 ErasureMethodPass pass = (ErasureMethodPass)item.Tag; 133 133 passEditor.PassData = (byte[])pass.OpaqueValue; 134 passEditor.PassType = pass.Function == Eras eCustom.Pass.WriteRandom ?134 passEditor.PassType = pass.Function == ErasureMethod.WriteRandom ? 135 135 CustomMethodPassEditorPassType.Random : 136 136 CustomMethodPassEditorPassType.Text; … … 169 169 private void passesAddBtn_Click(object sender, EventArgs e) 170 170 { 171 ErasureMethod .Pass pass = new ErasureMethod.Pass(ErasureMethod.Pass.WriteRandom, null);171 ErasureMethodPass pass = new ErasureMethodPass(ErasureMethod.WriteRandom, null); 172 172 ListViewItem item = AddPass(pass); 173 173 … … 193 193 foreach (ListViewItem item in passesLv.SelectedItems) 194 194 { 195 ErasureMethod .Pass oldPass = (ErasureMethod.Pass)item.Tag;196 ErasureMethod .Pass pass = new ErasureMethod.Pass(195 ErasureMethodPass oldPass = (ErasureMethodPass)item.Tag; 196 ErasureMethodPass pass = new ErasureMethodPass( 197 197 oldPass.Function, oldPass.OpaqueValue); 198 198 AddPass(pass); -
branches/eraser6/DefaultPlugins/EraseCustom.cs
r919 r956 74 74 } 75 75 76 protected override Pass[] PassesSet76 protected override ErasureMethodPass[] PassesSet 77 77 { 78 78 get { return method.Passes; } … … 103 103 info.GetValue("Passes", typeof(List<PassData>)); 104 104 105 Passes = new ErasureMethod .Pass[passes.Count];105 Passes = new ErasureMethodPass[passes.Count]; 106 106 for (int i = 0; i != passes.Count; ++i) 107 107 Passes[i] = passes[i]; … … 111 111 public Guid Guid { get; set; } 112 112 public bool RandomizePasses { get; set; } 113 public ErasureMethod .Pass[] Passes { get; set; }113 public ErasureMethodPass[] Passes { get; set; } 114 114 115 115 #region ISerializable Members … … 122 122 123 123 List<PassData> passes = new List<PassData>(Passes.Length); 124 foreach (ErasureMethod .Pass pass in Passes)124 foreach (ErasureMethodPass pass in Passes) 125 125 passes.Add(new PassData(pass)); 126 126 info.AddValue("Passes", passes); … … 130 130 private class PassData 131 131 { 132 public PassData(ErasureMethod .Pass pass)132 public PassData(ErasureMethodPass pass) 133 133 { 134 if (pass.Function == ErasureMethod. Pass.WriteConstant)134 if (pass.Function == ErasureMethod.WriteConstant) 135 135 { 136 136 Random = false; 137 137 OpaqueValue = pass.OpaqueValue; 138 138 } 139 else if (pass.Function == ErasureMethod. Pass.WriteRandom)139 else if (pass.Function == ErasureMethod.WriteRandom) 140 140 { 141 141 Random = true; … … 146 146 } 147 147 148 public static implicit operator ErasureMethod .Pass(PassData pass)148 public static implicit operator ErasureMethodPass(PassData pass) 149 149 { 150 ErasureMethod.Pass result = new ErasureMethod.Pass(pass.Random ?151 ErasureMethod.Pass.WriteRandom:152 ErasureMethod.Pass.WriteConstant, pass.OpaqueValue);153 return result;150 return new ErasureMethodPass(pass.Random ? 151 new ErasureMethodPassFunction(ErasureMethod.WriteRandom) : 152 new ErasureMethodPassFunction(ErasureMethod.WriteConstant), 153 pass.OpaqueValue); 154 154 } 155 155 -
branches/eraser6/DefaultPlugins/EraseDoD.cs
r938 r956 45 45 } 46 46 47 protected override Pass[] PassesSet47 protected override ErasureMethodPass[] PassesSet 48 48 { 49 49 get … … 53 53 int rand = prng.Next(); 54 54 55 Pass[] result = newPass[]55 ErasureMethodPass[] result = new ErasureMethodPass[] 56 56 { 57 new Pass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }),58 new Pass(WriteConstant, new byte[] { 0 }),59 new Pass(WriteRandom, null),60 new Pass(WriteConstant, new byte[] { (byte)((rand >> 8) & 0xFF) }),61 new Pass(WriteConstant, new byte[] { (byte)((rand >> 16) & 0xFF) }),62 new Pass(WriteConstant, new byte[] { 0 }),63 new Pass(WriteRandom, null)57 new ErasureMethodPass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }), 58 new ErasureMethodPass(WriteConstant, new byte[] { 0 }), 59 new ErasureMethodPass(WriteRandom, null), 60 new ErasureMethodPass(WriteConstant, new byte[] { (byte)((rand >> 8) & 0xFF) }), 61 new ErasureMethodPass(WriteConstant, new byte[] { (byte)((rand >> 16) & 0xFF) }), 62 new ErasureMethodPass(WriteConstant, new byte[] { 0 }), 63 new ErasureMethodPass(WriteRandom, null) 64 64 }; 65 65 66 66 //Set passes 2 and 6 to be complements of 1 and 5 67 result[1] = new Pass(WriteConstant, new byte[] {67 result[1] = new ErasureMethodPass(WriteConstant, new byte[] { 68 68 (byte)(~((byte[])result[0].OpaqueValue)[0]) }); 69 result[5] = new Pass(WriteConstant, new byte[] {69 result[5] = new ErasureMethodPass(WriteConstant, new byte[] { 70 70 (byte)(~((byte[])result[4].OpaqueValue)[0]) }); 71 71 return result; … … 91 91 } 92 92 93 protected override Pass[] PassesSet93 protected override ErasureMethodPass[] PassesSet 94 94 { 95 95 get 96 96 { 97 return new Pass[]97 return new ErasureMethodPass[] 98 98 { 99 new Pass(WriteConstant, new byte[] { 0 }),100 new Pass(WriteConstant, new byte[] { 0xFF }),101 new Pass(WriteRandom, null)99 new ErasureMethodPass(WriteConstant, new byte[] { 0 }), 100 new ErasureMethodPass(WriteConstant, new byte[] { 0xFF }), 101 new ErasureMethodPass(WriteRandom, null) 102 102 }; 103 103 } -
branches/eraser6/DefaultPlugins/EraseFirstLast16KB.cs
r938 r956 90 90 91 91 public override void Erase(Stream strm, long erasureLength, Prng prng, 92 ProgressFunction callback)92 EraserMethodProgressFunction callback) 93 93 { 94 94 //Make sure that the erasureLength passed in here is the maximum value -
branches/eraser6/DefaultPlugins/EraseGOSTP50739.cs
r905 r956 48 48 } 49 49 50 protected override Pass[] PassesSet50 protected override ErasureMethodPass[] PassesSet 51 51 { 52 52 get 53 53 { 54 return new Pass[]54 return new ErasureMethodPass[] 55 55 { 56 new Pass(WriteConstant, new byte[] { (byte)0 }),57 new Pass(WriteRandom, null)56 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }), 57 new ErasureMethodPass(WriteRandom, null) 58 58 }; 59 59 } -
branches/eraser6/DefaultPlugins/EraseGutmann.cs
r905 r956 52 52 } 53 53 54 protected override Pass[] PassesSet54 protected override ErasureMethodPass[] PassesSet 55 55 { 56 56 get 57 57 { 58 return new Pass[]58 return new ErasureMethodPass[] 59 59 { 60 new Pass(WriteRandom, null), // 161 new Pass(WriteRandom, null),62 new Pass(WriteRandom, null),63 new Pass(WriteRandom, null),64 new Pass(WriteConstant, new byte[] {0x55}), // 565 new Pass(WriteConstant, new byte[] {0xAA}),66 new Pass(WriteConstant, new byte[] {0x92, 0x49, 0x24}),67 new Pass(WriteConstant, new byte[] {0x49, 0x24, 0x92}),68 new Pass(WriteConstant, new byte[] {0x24, 0x92, 0x49}),69 new Pass(WriteConstant, new byte[] {0x00}), // 1070 new Pass(WriteConstant, new byte[] {0x11}),71 new Pass(WriteConstant, new byte[] {0x22}),72 new Pass(WriteConstant, new byte[] {0x33}),73 new Pass(WriteConstant, new byte[] {0x44}),74 new Pass(WriteConstant, new byte[] {0x55}), // 1575 new Pass(WriteConstant, new byte[] {0x66}),76 new Pass(WriteConstant, new byte[] {0x77}),77 new Pass(WriteConstant, new byte[] {0x88}),78 new Pass(WriteConstant, new byte[] {0x99}),79 new Pass(WriteConstant, new byte[] {0xAA}), // 2080 new Pass(WriteConstant, new byte[] {0xBB}),81 new Pass(WriteConstant, new byte[] {0xCC}),82 new Pass(WriteConstant, new byte[] {0xDD}),83 new Pass(WriteConstant, new byte[] {0xEE}),84 new Pass(WriteConstant, new byte[] {0xFF}), // 2585 new Pass(WriteConstant, new byte[] {0x92, 0x49, 0x24}),86 new Pass(WriteConstant, new byte[] {0x49, 0x24, 0x92}),87 new Pass(WriteConstant, new byte[] {0x24, 0x92, 0x49}),88 new Pass(WriteConstant, new byte[] {0x6D, 0xB6, 0xDB}),89 new Pass(WriteConstant, new byte[] {0xB6, 0xDB, 0x6D}), // 3090 new Pass(WriteConstant, new byte[] {0xDB, 0x6D, 0xB6}),91 new Pass(WriteRandom, null),92 new Pass(WriteRandom, null),93 new Pass(WriteRandom, null),94 new Pass(WriteRandom, null) // 3560 new ErasureMethodPass(WriteRandom, null), // 1 61 new ErasureMethodPass(WriteRandom, null), 62 new ErasureMethodPass(WriteRandom, null), 63 new ErasureMethodPass(WriteRandom, null), 64 new ErasureMethodPass(WriteConstant, new byte[] {0x55}), // 5 65 new ErasureMethodPass(WriteConstant, new byte[] {0xAA}), 66 new ErasureMethodPass(WriteConstant, new byte[] {0x92, 0x49, 0x24}), 67 new ErasureMethodPass(WriteConstant, new byte[] {0x49, 0x24, 0x92}), 68 new ErasureMethodPass(WriteConstant, new byte[] {0x24, 0x92, 0x49}), 69 new ErasureMethodPass(WriteConstant, new byte[] {0x00}), // 10 70 new ErasureMethodPass(WriteConstant, new byte[] {0x11}), 71 new ErasureMethodPass(WriteConstant, new byte[] {0x22}), 72 new ErasureMethodPass(WriteConstant, new byte[] {0x33}), 73 new ErasureMethodPass(WriteConstant, new byte[] {0x44}), 74 new ErasureMethodPass(WriteConstant, new byte[] {0x55}), // 15 75 new ErasureMethodPass(WriteConstant, new byte[] {0x66}), 76 new ErasureMethodPass(WriteConstant, new byte[] {0x77}), 77 new ErasureMethodPass(WriteConstant, new byte[] {0x88}), 78 new ErasureMethodPass(WriteConstant, new byte[] {0x99}), 79 new ErasureMethodPass(WriteConstant, new byte[] {0xAA}), // 20 80 new ErasureMethodPass(WriteConstant, new byte[] {0xBB}), 81 new ErasureMethodPass(WriteConstant, new byte[] {0xCC}), 82 new ErasureMethodPass(WriteConstant, new byte[] {0xDD}), 83 new ErasureMethodPass(WriteConstant, new byte[] {0xEE}), 84 new ErasureMethodPass(WriteConstant, new byte[] {0xFF}), // 25 85 new ErasureMethodPass(WriteConstant, new byte[] {0x92, 0x49, 0x24}), 86 new ErasureMethodPass(WriteConstant, new byte[] {0x49, 0x24, 0x92}), 87 new ErasureMethodPass(WriteConstant, new byte[] {0x24, 0x92, 0x49}), 88 new ErasureMethodPass(WriteConstant, new byte[] {0x6D, 0xB6, 0xDB}), 89 new ErasureMethodPass(WriteConstant, new byte[] {0xB6, 0xDB, 0x6D}), // 30 90 new ErasureMethodPass(WriteConstant, new byte[] {0xDB, 0x6D, 0xB6}), 91 new ErasureMethodPass(WriteRandom, null), 92 new ErasureMethodPass(WriteRandom, null), 93 new ErasureMethodPass(WriteRandom, null), 94 new ErasureMethodPass(WriteRandom, null) // 35 95 95 }; 96 96 } … … 115 115 } 116 116 117 protected override Pass[] PassesSet117 protected override ErasureMethodPass[] PassesSet 118 118 { 119 119 get 120 120 { 121 return new Pass[]121 return new ErasureMethodPass[] 122 122 { 123 new Pass(WriteRandom, null), //Original pass 1124 new Pass(WriteConstant, new byte[] {0x55}), //Original pass 5125 new Pass(WriteConstant, new byte[] {0xAA}), //Original pass 6126 new Pass(WriteConstant, new byte[] {0x92, 0x49, 0x24}), //Original pass 7127 new Pass(WriteConstant, new byte[] {0x49, 0x24, 0x92}), //Original pass 8128 new Pass(WriteConstant, new byte[] {0x24, 0x92, 0x49}), //Original pass 9129 new Pass(WriteConstant, new byte[] {0x4B}),130 new Pass(WriteConstant, new byte[] {0xB4}),131 new Pass(WriteConstant, new byte[] {0x00}),132 new Pass(WriteConstant, new byte[] {0x11}),123 new ErasureMethodPass(WriteRandom, null), //Original pass 1 124 new ErasureMethodPass(WriteConstant, new byte[] {0x55}), //Original pass 5 125 new ErasureMethodPass(WriteConstant, new byte[] {0xAA}), //Original pass 6 126 new ErasureMethodPass(WriteConstant, new byte[] {0x92, 0x49, 0x24}), //Original pass 7 127 new ErasureMethodPass(WriteConstant, new byte[] {0x49, 0x24, 0x92}), //Original pass 8 128 new ErasureMethodPass(WriteConstant, new byte[] {0x24, 0x92, 0x49}), //Original pass 9 129 new ErasureMethodPass(WriteConstant, new byte[] {0x4B}), 130 new ErasureMethodPass(WriteConstant, new byte[] {0xB4}), 131 new ErasureMethodPass(WriteConstant, new byte[] {0x00}), 132 new ErasureMethodPass(WriteConstant, new byte[] {0x11}), 133 133 }; 134 134 } -
branches/eraser6/DefaultPlugins/EraseHMGIS5.cs
r905 r956 48 48 } 49 49 50 protected override Pass[] PassesSet50 protected override ErasureMethodPass[] PassesSet 51 51 { 52 52 get 53 53 { 54 return new Pass[]54 return new ErasureMethodPass[] 55 55 { 56 new Pass(WriteConstant, new byte[] { (byte)0 })56 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }) 57 57 }; 58 58 } … … 77 77 } 78 78 79 protected override Pass[] PassesSet79 protected override ErasureMethodPass[] PassesSet 80 80 { 81 81 get 82 82 { 83 return new Pass[]83 return new ErasureMethodPass[] 84 84 { 85 new Pass(WriteConstant, new byte[] { (byte)0 }),86 new Pass(WriteConstant, new byte[] { (byte)0x01 }),87 new Pass(WriteRandom, null),85 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }), 86 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 87 new ErasureMethodPass(WriteRandom, null), 88 88 }; 89 89 } -
branches/eraser6/DefaultPlugins/EraseRCMP_TSSIT_OPS_II.cs
r938 r956 48 48 } 49 49 50 protected override Pass[] PassesSet50 protected override ErasureMethodPass[] PassesSet 51 51 { 52 52 get … … 55 55 int rand = prng.Next(); 56 56 57 return new Pass[]57 return new ErasureMethodPass[] 58 58 { 59 new Pass(WriteConstant, new byte[] { (byte)0}),60 new Pass(WriteConstant, new byte[] { (byte)0x01 }),61 new Pass(WriteConstant, new byte[] { (byte)0 }),62 new Pass(WriteConstant, new byte[] { (byte)0x01 }),63 new Pass(WriteConstant, new byte[] { (byte)0 }),64 new Pass(WriteConstant, new byte[] { (byte)0x01 }),65 new Pass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }),59 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0}), 60 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 61 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }), 62 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 63 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }), 64 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 65 new ErasureMethodPass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }), 66 66 }; 67 67 } -
branches/eraser6/DefaultPlugins/EraseRandom.cs
r905 r956 49 49 } 50 50 51 protected override Pass[] PassesSet51 protected override ErasureMethodPass[] PassesSet 52 52 { 53 53 get 54 54 { 55 return new Pass[]55 return new ErasureMethodPass[] 56 56 { 57 new Pass(WriteRandom, null)57 new ErasureMethodPass(WriteRandom, null) 58 58 }; 59 59 } -
branches/eraser6/DefaultPlugins/EraseSchneier.cs
r905 r956 45 45 } 46 46 47 protected override Pass[] PassesSet47 protected override ErasureMethodPass[] PassesSet 48 48 { 49 49 get 50 50 { 51 return new Pass[]51 return new ErasureMethodPass[] 52 52 { 53 new Pass(WriteConstant, new byte[] { 1 }),54 new Pass(WriteConstant, new byte[] { 0 }),55 new Pass(WriteRandom, null),56 new Pass(WriteRandom, null),57 new Pass(WriteRandom, null),58 new Pass(WriteRandom, null),59 new Pass(WriteRandom, null)53 new ErasureMethodPass(WriteConstant, new byte[] { 1 }), 54 new ErasureMethodPass(WriteConstant, new byte[] { 0 }), 55 new ErasureMethodPass(WriteRandom, null), 56 new ErasureMethodPass(WriteRandom, null), 57 new ErasureMethodPass(WriteRandom, null), 58 new ErasureMethodPass(WriteRandom, null), 59 new ErasureMethodPass(WriteRandom, null) 60 60 }; 61 61 } -
branches/eraser6/DefaultPlugins/EraseUSAF5020.cs
r938 r956 48 48 } 49 49 50 protected override Pass[] PassesSet50 protected override ErasureMethodPass[] PassesSet 51 51 { 52 52 get … … 55 55 int rand = prng.Next(); 56 56 57 return new Pass[]57 return new ErasureMethodPass[] 58 58 { 59 new Pass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }),60 new Pass(WriteConstant, new byte[] { (byte)((rand >> 8) & 0xFF) }),61 new Pass(WriteConstant, new byte[] { (byte)((rand >> 16) & 0xFF) })59 new ErasureMethodPass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }), 60 new ErasureMethodPass(WriteConstant, new byte[] { (byte)((rand >> 8) & 0xFF) }), 61 new ErasureMethodPass(WriteConstant, new byte[] { (byte)((rand >> 16) & 0xFF) }) 62 62 }; 63 63 } -
branches/eraser6/DefaultPlugins/EraseUSArmyAR380_19.cs
r938 r956 48 48 } 49 49 50 protected override Pass[] PassesSet50 protected override ErasureMethodPass[] PassesSet 51 51 { 52 52 get … … 55 55 int rand = prng.Next(); 56 56 57 return new Pass[]57 return new ErasureMethodPass[] 58 58 { 59 new Pass(WriteRandom, null),60 new Pass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }),61 new Pass(WriteConstant, new byte[] { (byte)~(rand & 0xFF) })59 new ErasureMethodPass(WriteRandom, null), 60 new ErasureMethodPass(WriteConstant, new byte[] { (byte)(rand & 0xFF) }), 61 new ErasureMethodPass(WriteConstant, new byte[] { (byte)~(rand & 0xFF) }) 62 62 }; 63 63 } -
branches/eraser6/DefaultPlugins/EraseVSITR.cs
r905 r956 48 48 } 49 49 50 protected override Pass[] PassesSet50 protected override ErasureMethodPass[] PassesSet 51 51 { 52 52 get 53 53 { 54 return new Pass[]54 return new ErasureMethodPass[] 55 55 { 56 new Pass(WriteConstant, new byte[] { (byte)0}),57 new Pass(WriteConstant, new byte[] { (byte)0x01 }),58 new Pass(WriteConstant, new byte[] { (byte)0 }),59 new Pass(WriteConstant, new byte[] { (byte)0x01 }),60 new Pass(WriteConstant, new byte[] { (byte)0 }),61 new Pass(WriteConstant, new byte[] { (byte)0x01 }),62 new Pass(WriteRandom, null),56 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0}), 57 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 58 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }), 59 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 60 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }), 61 new ErasureMethodPass(WriteConstant, new byte[] { (byte)0x01 }), 62 new ErasureMethodPass(WriteRandom, null), 63 63 }; 64 64 } -
branches/eraser6/Manager/Method.cs
r952 r956 86 86 87 87 /// <summary> 88 /// A simple callback for clients to retrieve progress information from89 /// the erase method.90 /// </summary>91 /// <param name="lastWritten">The amount of data written to the stream since92 /// the last call to the delegate.</param>93 /// <param name="currentPass">The current pass number. The total number94 /// of passes can be found from the Passes property.</param>95 public delegate void ProgressFunction(long lastWritten, int currentPass);96 97 /// <summary>98 88 /// The main bit of the class! This function is called whenever data has 99 89 /// to be erased. Erase the stream passed in, using the given PRNG for … … 110 100 /// <param name="callback">The progress callback function.</param> 111 101 public abstract void Erase(Stream stream, long erasureLength, Prng prng, 112 ProgressFunction callback);102 EraserMethodProgressFunction callback); 113 103 114 104 /// <summary> … … 130 120 /// <param name="passes">The input set of passes.</param> 131 121 /// <returns>The shuffled set of passes.</returns> 132 protected static Pass[] ShufflePasses(Pass[] passes)122 protected static ErasureMethodPass[] ShufflePasses(ErasureMethodPass[] passes) 133 123 { 134 124 //Make a copy. 135 Pass[] result = newPass[passes.Length];125 ErasureMethodPass[] result = new ErasureMethodPass[passes.Length]; 136 126 passes.CopyTo(result, 0); 137 127 … … 141 131 { 142 132 int val = rand.Next(result.Length - 1); 143 Pass tmpPass = result[val];133 ErasureMethodPass tmpPass = result[val]; 144 134 result[val] = result[i]; 145 135 result[i] = tmpPass; … … 155 145 /// <param name="strm">The buffer to populate with data to write to disk.</param> 156 146 /// <param name="prng">The PRNG used.</param> 157 p rotectedstatic void WriteRandom(byte[] buffer, object value)147 public static void WriteRandom(byte[] buffer, object value) 158 148 { 159 149 ((Prng)value).NextBytes(buffer); … … 166 156 /// <param name="strm">The buffer to populate with data to write to disk.</param> 167 157 /// <param name="value">The byte[] to write.</param> 168 p rotectedstatic void WriteConstant(byte[] buffer, object value)158 public static void WriteConstant(byte[] buffer, object value) 169 159 { 170 160 byte[] constant = (byte[])value; … … 172 162 buffer[i] = constant[i % constant.Length]; 173 163 } 174 175 /// <summary>176 /// A pass object. This object holds both the pass function, as well as the177 /// data used for the pass (random, byte, or triplet)178 /// </summary>179 public class Pass180 {181 public override string ToString()182 {183 return OpaqueValue == null ? S._("Random") : OpaqueValue.ToString();184 }185 186 /// <summary>187 /// Constructor.188 /// </summary>189 /// <param name="function">The delegate to the function.</param>190 /// <param name="opaqueValue">The opaque value passed to the function.</param>191 public Pass(PassFunction function, object opaqueValue)192 {193 Function = function;194 OpaqueValue = opaqueValue;195 }196 197 /// <summary>198 /// Executes the pass.199 /// </summary>200 /// <param name="buffer">The buffer to populate with the data to write.</param>201 /// <param name="prng">The PRNG used for random passes.</param>202 public void Execute(byte[] buffer, Prng prng)203 {204 Function(buffer, OpaqueValue == null ? prng : OpaqueValue);205 }206 207 /// <summary>208 /// The prototype of a pass.209 /// </summary>210 /// <param name="strm">The buffer to populate with data to write to disk.</param>211 /// <param name="opaque">An opaque value, depending on the type of callback.</param>212 public delegate void PassFunction(byte[] buffer, object opaque);213 214 /// <summary>215 /// The default pass function which writes random information to the stream216 /// </summary>217 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]218 public static readonly PassFunction WriteRandom = ErasureMethod.WriteRandom;219 220 /// <summary>221 /// The default pass function which writes a constant repeatedly to the222 /// stream. The Pass' OpaqueValue must be set.223 /// </summary>224 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]225 public static readonly PassFunction WriteConstant = ErasureMethod.WriteConstant;226 227 /// <summary>228 /// The function to execute for this pass.229 /// </summary>230 public PassFunction Function { get; set; }231 232 /// <summary>233 /// The value to be passed to the executing function.234 /// </summary>235 public object OpaqueValue { get; set; }236 }237 164 } 165 166 /// <summary> 167 /// A simple callback for clients to retrieve progress information from 168 /// the erase method. 169 /// </summary> 170 /// <param name="lastWritten">The amount of data written to the stream since 171 /// the last call to the delegate.</param> 172 /// <param name="currentPass">The current pass number. The total number 173 /// of passes can be found from the Passes property.</param> 174 public delegate void EraserMethodProgressFunction(long lastWritten, int currentPass); 175 176 /// <summary> 177 /// A pass object. This object holds both the pass function, as well as the 178 /// data used for the pass (random, byte, or triplet) 179 /// </summary> 180 public class ErasureMethodPass 181 { 182 public override string ToString() 183 { 184 return OpaqueValue == null ? S._("Random") : OpaqueValue.ToString(); 185 } 186 187 /// <summary> 188 /// Constructor. 189 /// </summary> 190 /// <param name="function">The delegate to the function.</param> 191 /// <param name="opaqueValue">The opaque value passed to the function.</param> 192 public ErasureMethodPass(ErasureMethodPassFunction function, object opaqueValue) 193 { 194 Function = function; 195 OpaqueValue = opaqueValue; 196 } 197 198 /// <summary> 199 /// Executes the pass. 200 /// </summary> 201 /// <param name="buffer">The buffer to populate with the data to write.</param> 202 /// <param name="prng">The PRNG used for random passes.</param> 203 public void Execute(byte[] buffer, Prng prng) 204 { 205 Function(buffer, OpaqueValue == null ? prng : OpaqueValue); 206 } 207 208 /// <summary> 209 /// The function to execute for this pass. 210 /// </summary> 211 public ErasureMethodPassFunction Function { get; set; } 212 213 /// <summary> 214 /// The value to be passed to the executing function. 215 /// </summary> 216 public object OpaqueValue { get; set; } 217 } 218 219 /// <summary> 220 /// The prototype of a pass. 221 /// </summary> 222 /// <param name="strm">The buffer to populate with data to write to disk.</param> 223 /// <param name="opaque">An opaque value, depending on the type of callback.</param> 224 public delegate void ErasureMethodPassFunction(byte[] buffer, object opaque); 238 225 239 226 /// <summary> … … 256 243 /// <param name="prng">The PRNG source for random data.</param> 257 244 /// <param name="callback">The progress callback function.</param> 258 public virtual void EraseUnusedSpace(Stream stream, Prng prng, ProgressFunction callback)245 public virtual void EraseUnusedSpace(Stream stream, Prng prng, EraserMethodProgressFunction callback) 259 246 { 260 247 Erase(stream, long.MaxValue, prng, callback); … … 290 277 /// The set of Pass objects describing the passes in this erasure method. 291 278 /// </summary> 292 protected abstract Pass[] PassesSet279 protected abstract ErasureMethodPass[] PassesSet 293 280 { 294 281 get; … … 302 289 303 290 public override void Erase(Stream stream, long erasureLength, Prng prng, 304 ProgressFunction callback)291 EraserMethodProgressFunction callback) 305 292 { 306 293 //Randomize the order of the passes 307 Pass[] randomizedPasses = PassesSet;294 ErasureMethodPass[] randomizedPasses = PassesSet; 308 295 if (RandomizePasses) 309 296 randomizedPasses = ShufflePasses(randomizedPasses); … … 392 379 393 380 public override void Erase(Stream strm, long erasureLength, Prng prng, 394 ProgressFunction callback)381 EraserMethodProgressFunction callback) 395 382 { 396 383 throw new InvalidOperationException(S._("The DefaultMethod class should never " +
Note: See TracChangeset
for help on using the changeset viewer.
