Changeset 956


Ignore:
Timestamp:
05/01/09 05:19:43 (6 years ago)
Author:
lowjoel
Message:

-No publicly accessible nested types
-Replaced the ErasureMethod?.Pass class with the ErasureMethodPass? class and removed the WriteConstant? and WriteRandom? delegates which pointed to real functions in ErasureMethod?

Location:
branches/eraser6
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/DefaultPlugins/CustomMethodEditorForm.cs

    r950 r956  
    6161 
    6262                //And all the passes. 
    63                 ErasureMethod.Pass[] passes = new ErasureMethod.Pass[passesLv.Items.Count]; 
     63                ErasureMethodPass[] passes = new ErasureMethodPass[passesLv.Items.Count]; 
    6464                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; 
    6666                method.Passes = passes; 
    6767 
     
    7979 
    8080                //Every pass. 
    81                 foreach (ErasureMethod.Pass pass in method.Passes) 
     81                foreach (ErasureMethodPass pass in method.Passes) 
    8282                    AddPass(pass); 
    8383            } 
     
    8989        /// <param name="pass">The pass to add.</param> 
    9090        /// <returns>The item added to the list view.</returns> 
    91         private ListViewItem AddPass(ErasureMethod.Pass pass) 
     91        private ListViewItem AddPass(ErasureMethodPass pass) 
    9292        { 
    9393            ListViewItem item = new ListViewItem((passesLv.Items.Count + 1).ToString( 
    9494                CultureInfo.CurrentCulture)); 
    9595            item.Tag = pass; 
    96             if (pass.Function == ErasureMethod.Pass.WriteRandom) 
     96            if (pass.Function == ErasureMethod.WriteRandom) 
    9797                item.SubItems.Add(S._("Random Data")); 
    9898            else 
     
    108108        private void SavePass(ListViewItem item) 
    109109        { 
    110             ErasureMethod.Pass pass = (ErasureMethod.Pass)item.Tag; 
     110            ErasureMethodPass pass = (ErasureMethodPass)item.Tag; 
    111111            if (passEditor.PassType == CustomMethodPassEditorPassType.Random) 
    112112            { 
    113                 pass.Function = ErasureMethod.Pass.WriteRandom; 
     113                pass.Function = ErasureMethod.WriteRandom; 
    114114                pass.OpaqueValue = null; 
    115115                item.SubItems[1].Text = S._("Random Data"); 
     
    117117            else 
    118118            { 
    119                 pass.Function = ErasureMethod.Pass.WriteConstant; 
     119                pass.Function = ErasureMethod.WriteConstant; 
    120120                pass.OpaqueValue = passEditor.PassData; 
    121121                item.SubItems[1].Text = S._("Constant ({0} bytes)", passEditor.PassData.Length); 
     
    130130        { 
    131131            currentPass = item; 
    132             ErasureMethod.Pass pass = (ErasureMethod.Pass)item.Tag; 
     132            ErasureMethodPass pass = (ErasureMethodPass)item.Tag; 
    133133            passEditor.PassData = (byte[])pass.OpaqueValue; 
    134             passEditor.PassType = pass.Function == EraseCustom.Pass.WriteRandom ? 
     134            passEditor.PassType = pass.Function == ErasureMethod.WriteRandom ? 
    135135                CustomMethodPassEditorPassType.Random : 
    136136                CustomMethodPassEditorPassType.Text; 
     
    169169        private void passesAddBtn_Click(object sender, EventArgs e) 
    170170        { 
    171             ErasureMethod.Pass pass = new ErasureMethod.Pass(ErasureMethod.Pass.WriteRandom, null); 
     171            ErasureMethodPass pass = new ErasureMethodPass(ErasureMethod.WriteRandom, null); 
    172172            ListViewItem item = AddPass(pass); 
    173173 
     
    193193            foreach (ListViewItem item in passesLv.SelectedItems) 
    194194            { 
    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( 
    197197                    oldPass.Function, oldPass.OpaqueValue); 
    198198                AddPass(pass); 
  • branches/eraser6/DefaultPlugins/EraseCustom.cs

    r919 r956  
    7474        } 
    7575 
    76         protected override Pass[] PassesSet 
     76        protected override ErasureMethodPass[] PassesSet 
    7777        { 
    7878            get { return method.Passes; } 
     
    103103                info.GetValue("Passes", typeof(List<PassData>)); 
    104104 
    105             Passes = new ErasureMethod.Pass[passes.Count]; 
     105            Passes = new ErasureMethodPass[passes.Count]; 
    106106            for (int i = 0; i != passes.Count; ++i) 
    107107                Passes[i] = passes[i]; 
     
    111111        public Guid Guid { get; set; } 
    112112        public bool RandomizePasses { get; set; } 
    113         public ErasureMethod.Pass[] Passes { get; set; } 
     113        public ErasureMethodPass[] Passes { get; set; } 
    114114 
    115115        #region ISerializable Members 
     
    122122 
    123123            List<PassData> passes = new List<PassData>(Passes.Length); 
    124             foreach (ErasureMethod.Pass pass in Passes) 
     124            foreach (ErasureMethodPass pass in Passes) 
    125125                passes.Add(new PassData(pass)); 
    126126            info.AddValue("Passes", passes); 
     
    130130        private class PassData 
    131131        { 
    132             public PassData(ErasureMethod.Pass pass) 
     132            public PassData(ErasureMethodPass pass) 
    133133            { 
    134                 if (pass.Function == ErasureMethod.Pass.WriteConstant) 
     134                if (pass.Function == ErasureMethod.WriteConstant) 
    135135                { 
    136136                    Random = false; 
    137137                    OpaqueValue = pass.OpaqueValue; 
    138138                } 
    139                 else if (pass.Function == ErasureMethod.Pass.WriteRandom) 
     139                else if (pass.Function == ErasureMethod.WriteRandom) 
    140140                { 
    141141                    Random = true; 
     
    146146            } 
    147147 
    148             public static implicit operator ErasureMethod.Pass(PassData pass) 
     148            public static implicit operator ErasureMethodPass(PassData pass) 
    149149            { 
    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); 
    154154            } 
    155155 
  • branches/eraser6/DefaultPlugins/EraseDoD.cs

    r938 r956  
    4545        } 
    4646 
    47         protected override Pass[] PassesSet 
     47        protected override ErasureMethodPass[] PassesSet 
    4848        { 
    4949            get 
     
    5353                int rand = prng.Next(); 
    5454 
    55                 Pass[] result = new Pass[] 
     55                ErasureMethodPass[] result = new ErasureMethodPass[] 
    5656                { 
    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) 
    6464                }; 
    6565 
    6666                //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[] { 
    6868                    (byte)(~((byte[])result[0].OpaqueValue)[0]) }); 
    69                 result[5] = new Pass(WriteConstant, new byte[] { 
     69                result[5] = new ErasureMethodPass(WriteConstant, new byte[] { 
    7070                    (byte)(~((byte[])result[4].OpaqueValue)[0]) }); 
    7171                return result; 
     
    9191        } 
    9292 
    93         protected override Pass[] PassesSet 
     93        protected override ErasureMethodPass[] PassesSet 
    9494        { 
    9595            get 
    9696            { 
    97                 return new Pass[] 
     97                return new ErasureMethodPass[] 
    9898                { 
    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) 
    102102                }; 
    103103            } 
  • branches/eraser6/DefaultPlugins/EraseFirstLast16KB.cs

    r938 r956  
    9090 
    9191        public override void Erase(Stream strm, long erasureLength, Prng prng, 
    92             ProgressFunction callback) 
     92            EraserMethodProgressFunction callback) 
    9393        { 
    9494            //Make sure that the erasureLength passed in here is the maximum value 
  • branches/eraser6/DefaultPlugins/EraseGOSTP50739.cs

    r905 r956  
    4848        } 
    4949 
    50         protected override Pass[] PassesSet 
     50        protected override ErasureMethodPass[] PassesSet 
    5151        { 
    5252            get 
    5353            { 
    54                 return new Pass[] 
     54                return new ErasureMethodPass[] 
    5555                { 
    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) 
    5858                }; 
    5959            } 
  • branches/eraser6/DefaultPlugins/EraseGutmann.cs

    r905 r956  
    5252        } 
    5353 
    54         protected override Pass[] PassesSet 
     54        protected override ErasureMethodPass[] PassesSet 
    5555        { 
    5656            get 
    5757            { 
    58                 return new Pass[] 
     58                return new ErasureMethodPass[] 
    5959                { 
    60                     new Pass(WriteRandom, null),                                   // 1 
    61                     new Pass(WriteRandom, null), 
    62                     new Pass(WriteRandom, null), 
    63                     new Pass(WriteRandom, null), 
    64                     new Pass(WriteConstant, new byte[] {0x55}),                    // 5 
    65                     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}),                    // 10 
    70                     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}),                    // 15 
    75                     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}),                    // 20 
    80                     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}),                    // 25 
    85                     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}),        // 30 
    90                     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)                                    // 35 
     60                    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 
    9595                }; 
    9696            } 
     
    115115        } 
    116116 
    117         protected override Pass[] PassesSet 
     117        protected override ErasureMethodPass[] PassesSet 
    118118        { 
    119119            get 
    120120            { 
    121                 return new Pass[] 
     121                return new ErasureMethodPass[] 
    122122                { 
    123                     new Pass(WriteRandom, null),                                //Original pass 1 
    124                     new Pass(WriteConstant, new byte[] {0x55}),                 //Original pass 5 
    125                     new Pass(WriteConstant, new byte[] {0xAA}),                 //Original pass 6 
    126                     new Pass(WriteConstant, new byte[] {0x92, 0x49, 0x24}),     //Original pass 7 
    127                     new Pass(WriteConstant, new byte[] {0x49, 0x24, 0x92}),     //Original pass 8 
    128                     new Pass(WriteConstant, new byte[] {0x24, 0x92, 0x49}),     //Original pass 9 
    129                     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}), 
    133133                }; 
    134134            } 
  • branches/eraser6/DefaultPlugins/EraseHMGIS5.cs

    r905 r956  
    4848        } 
    4949 
    50         protected override Pass[] PassesSet 
     50        protected override ErasureMethodPass[] PassesSet 
    5151        { 
    5252            get 
    5353            { 
    54                 return new Pass[] 
     54                return new ErasureMethodPass[] 
    5555                { 
    56                     new Pass(WriteConstant, new byte[] { (byte)0 }) 
     56                    new ErasureMethodPass(WriteConstant, new byte[] { (byte)0 }) 
    5757                }; 
    5858            } 
     
    7777        } 
    7878 
    79         protected override Pass[] PassesSet 
     79        protected override ErasureMethodPass[] PassesSet 
    8080        { 
    8181            get 
    8282            { 
    83                 return new Pass[] 
     83                return new ErasureMethodPass[] 
    8484                { 
    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), 
    8888                }; 
    8989            } 
  • branches/eraser6/DefaultPlugins/EraseRCMP_TSSIT_OPS_II.cs

    r938 r956  
    4848        } 
    4949 
    50         protected override Pass[] PassesSet 
     50        protected override ErasureMethodPass[] PassesSet 
    5151        { 
    5252            get 
     
    5555                int rand = prng.Next(); 
    5656 
    57                 return new Pass[] 
     57                return new ErasureMethodPass[] 
    5858                { 
    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) }), 
    6666                }; 
    6767            } 
  • branches/eraser6/DefaultPlugins/EraseRandom.cs

    r905 r956  
    4949        } 
    5050 
    51         protected override Pass[] PassesSet 
     51        protected override ErasureMethodPass[] PassesSet 
    5252        { 
    5353            get 
    5454            { 
    55                 return new Pass[] 
     55                return new ErasureMethodPass[] 
    5656                { 
    57                     new Pass(WriteRandom, null) 
     57                    new ErasureMethodPass(WriteRandom, null) 
    5858                }; 
    5959            } 
  • branches/eraser6/DefaultPlugins/EraseSchneier.cs

    r905 r956  
    4545        } 
    4646 
    47         protected override Pass[] PassesSet 
     47        protected override ErasureMethodPass[] PassesSet 
    4848        { 
    4949            get 
    5050            { 
    51                 return new Pass[] 
     51                return new ErasureMethodPass[] 
    5252                { 
    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) 
    6060                }; 
    6161            } 
  • branches/eraser6/DefaultPlugins/EraseUSAF5020.cs

    r938 r956  
    4848        } 
    4949 
    50         protected override Pass[] PassesSet 
     50        protected override ErasureMethodPass[] PassesSet 
    5151        { 
    5252            get 
     
    5555                int rand = prng.Next(); 
    5656 
    57                 return new Pass[] 
     57                return new ErasureMethodPass[] 
    5858                { 
    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) }) 
    6262                }; 
    6363            } 
  • branches/eraser6/DefaultPlugins/EraseUSArmyAR380_19.cs

    r938 r956  
    4848        } 
    4949 
    50         protected override Pass[] PassesSet 
     50        protected override ErasureMethodPass[] PassesSet 
    5151        { 
    5252            get 
     
    5555                int rand = prng.Next(); 
    5656 
    57                 return new Pass[] 
     57                return new ErasureMethodPass[] 
    5858                { 
    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) }) 
    6262                }; 
    6363            } 
  • branches/eraser6/DefaultPlugins/EraseVSITR.cs

    r905 r956  
    4848        } 
    4949 
    50         protected override Pass[] PassesSet 
     50        protected override ErasureMethodPass[] PassesSet 
    5151        { 
    5252            get 
    5353            { 
    54                 return new Pass[] 
     54                return new ErasureMethodPass[] 
    5555                { 
    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), 
    6363                }; 
    6464            } 
  • branches/eraser6/Manager/Method.cs

    r952 r956  
    8686 
    8787        /// <summary> 
    88         /// A simple callback for clients to retrieve progress information from 
    89         /// the erase method. 
    90         /// </summary> 
    91         /// <param name="lastWritten">The amount of data written to the stream since 
    92         /// the last call to the delegate.</param> 
    93         /// <param name="currentPass">The current pass number. The total number 
    94         /// of passes can be found from the Passes property.</param> 
    95         public delegate void ProgressFunction(long lastWritten, int currentPass); 
    96  
    97         /// <summary> 
    9888        /// The main bit of the class! This function is called whenever data has 
    9989        /// to be erased. Erase the stream passed in, using the given PRNG for 
     
    110100        /// <param name="callback">The progress callback function.</param> 
    111101        public abstract void Erase(Stream stream, long erasureLength, Prng prng, 
    112             ProgressFunction callback); 
     102            EraserMethodProgressFunction callback); 
    113103 
    114104        /// <summary> 
     
    130120        /// <param name="passes">The input set of passes.</param> 
    131121        /// <returns>The shuffled set of passes.</returns> 
    132         protected static Pass[] ShufflePasses(Pass[] passes) 
     122        protected static ErasureMethodPass[] ShufflePasses(ErasureMethodPass[] passes) 
    133123        { 
    134124            //Make a copy. 
    135             Pass[] result = new Pass[passes.Length]; 
     125            ErasureMethodPass[] result = new ErasureMethodPass[passes.Length]; 
    136126            passes.CopyTo(result, 0); 
    137127 
     
    141131            { 
    142132                int val = rand.Next(result.Length - 1); 
    143                 Pass tmpPass = result[val]; 
     133                ErasureMethodPass tmpPass = result[val]; 
    144134                result[val] = result[i]; 
    145135                result[i] = tmpPass; 
     
    155145        /// <param name="strm">The buffer to populate with data to write to disk.</param> 
    156146        /// <param name="prng">The PRNG used.</param> 
    157         protected static void WriteRandom(byte[] buffer, object value) 
     147        public static void WriteRandom(byte[] buffer, object value) 
    158148        { 
    159149            ((Prng)value).NextBytes(buffer); 
     
    166156        /// <param name="strm">The buffer to populate with data to write to disk.</param> 
    167157        /// <param name="value">The byte[] to write.</param> 
    168         protected static void WriteConstant(byte[] buffer, object value) 
     158        public static void WriteConstant(byte[] buffer, object value) 
    169159        { 
    170160            byte[] constant = (byte[])value; 
     
    172162                buffer[i] = constant[i % constant.Length]; 
    173163        } 
    174  
    175         /// <summary> 
    176         /// A pass object. This object holds both the pass function, as well as the 
    177         /// data used for the pass (random, byte, or triplet) 
    178         /// </summary> 
    179         public class Pass 
    180         { 
    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 stream 
    216             /// </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 the 
    222             /// 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         } 
    237164    } 
     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); 
    238225 
    239226    /// <summary> 
     
    256243        /// <param name="prng">The PRNG source for random data.</param> 
    257244        /// <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) 
    259246        { 
    260247            Erase(stream, long.MaxValue, prng, callback); 
     
    290277        /// The set of Pass objects describing the passes in this erasure method. 
    291278        /// </summary> 
    292         protected abstract Pass[] PassesSet 
     279        protected abstract ErasureMethodPass[] PassesSet 
    293280        { 
    294281            get; 
     
    302289 
    303290        public override void Erase(Stream stream, long erasureLength, Prng prng, 
    304             ProgressFunction callback) 
     291            EraserMethodProgressFunction callback) 
    305292        { 
    306293            //Randomize the order of the passes 
    307             Pass[] randomizedPasses = PassesSet; 
     294            ErasureMethodPass[] randomizedPasses = PassesSet; 
    308295            if (RandomizePasses) 
    309296                randomizedPasses = ShufflePasses(randomizedPasses); 
     
    392379 
    393380            public override void Erase(Stream strm, long erasureLength, Prng prng, 
    394                 ProgressFunction callback) 
     381                EraserMethodProgressFunction callback) 
    395382            { 
    396383                throw new InvalidOperationException(S._("The DefaultMethod class should never " + 
Note: See TracChangeset for help on using the changeset viewer.