source: branches/eraser6/DefaultPlugins/EraseDoD.cs @ 956

Revision 956, 3.0 KB checked in by lowjoel, 6 years ago (diff)

-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?

  • Property svn:keywords set to Id
Line 
1/*
2 * $Id$
3 * Copyright 2008 The Eraser Project
4 * Original Author: Joel Low <lowjoel@users.sourceforge.net>
5 * Modified By:
6 *
7 * This file is part of Eraser.
8 *
9 * Eraser is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 *
18 * A copy of the GNU General Public License can be found at
19 * <http://www.gnu.org/licenses/>.
20 */
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using Eraser.Manager;
26using Eraser.Util;
27
28namespace Eraser.DefaultPlugins
29{
30    class DoD_EcE : PassBasedErasureMethod
31    {
32        public override string Name
33        {
34            get { return S._("US DoD 5220.22-M (8-306./E, C & E)"); }
35        }
36
37        public override Guid Guid
38        {
39            get { return new Guid("{D1583631-702E-4dbf-A0E9-C35DBA481702}"); }
40        }
41
42        protected override bool RandomizePasses
43        {
44            get { return false; }
45        }
46
47        protected override ErasureMethodPass[] PassesSet
48        {
49            get
50            {
51                //Set passes 1, 4 and 5 to be a random value
52                Prng prng = PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng);
53                int rand = prng.Next();
54
55                ErasureMethodPass[] result = new ErasureMethodPass[]
56                {
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                };
65
66                //Set passes 2 and 6 to be complements of 1 and 5
67                result[1] = new ErasureMethodPass(WriteConstant, new byte[] {
68                    (byte)(~((byte[])result[0].OpaqueValue)[0]) });
69                result[5] = new ErasureMethodPass(WriteConstant, new byte[] {
70                    (byte)(~((byte[])result[4].OpaqueValue)[0]) });
71                return result;
72            }
73        }
74    }
75
76    class DoD_E : PassBasedErasureMethod
77    {
78        public override string Name
79        {
80            get { return S._("US DoD 5220.22-M (8-306./E)"); }
81        }
82
83        public override Guid Guid
84        {
85            get { return new Guid("{ECBF4998-0B4F-445c-9A06-23627659E419}"); }
86        }
87
88        protected override bool RandomizePasses
89        {
90            get { return false; }
91        }
92
93        protected override ErasureMethodPass[] PassesSet
94        {
95            get
96            {
97                return new ErasureMethodPass[]
98                {
99                    new ErasureMethodPass(WriteConstant, new byte[] { 0 }),
100                    new ErasureMethodPass(WriteConstant, new byte[] { 0xFF }),
101                    new ErasureMethodPass(WriteRandom, null)
102                };
103            }
104        }
105    }
106}
Note: See TracBrowser for help on using the repository browser.