Changeset 1157


Ignore:
Timestamp:
Feb 21, 2010, 3:11:18 AM (12 years ago)
Author:
Arno Wacker
Message:

AnotherEditor

  • Yet another Invoke during a single log message changed into BeginInvoke

IControlEncryption

  • Removed obsolete signature

CryptoolStream

  • Added a try-catch when deleting a file. An exception occurs when the file is locked. Clearly, in this case there not much one can do.. the file remains on the disk. Waiting for CStream...

AES, DES, SDES

  • Cleanup of IControl interface and general code cleanup
  • Fixed compatibility with KeySearcher - now all three should work again. (However, kind of slow)

StreamToStringConverter

  • Updated license

Sample update

  • KeySearcher-Sample-DES.cte, KeySearcher-Sample-DES.cte, KeySearcher-Sample-SDES.cte: Compatibility with IControl changes and slight rearrangement.
  • P2P-DES-BruteforceManger.cte, P2P-DES-BruteforceWorker.cte: Compatibility

New binaries

  • CrypWin.exe
  • AnotherEditor.dll
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginBase/Control/IControlEncryption.cs

    r1121 r1157  
    3131        IControlEncryption clone();
    3232        event KeyPatternChanged keyPatternChanged;
    33 
    34         [Obsolete("This signature doesn't pass the ciphertext, use Decrypt(byte[], byte[]) instead")]
    35         byte[] Decrypt(byte[] key, int blocksize);
    3633    }
    3734}
  • trunk/CrypPluginBase/IO/CryptoolStream.cs

    r1153 r1157  
    107107                if (deleteOnDispose)
    108108                {
    109                     File.Delete(fileName);
     109                    try
     110                    {
     111                        File.Delete(fileName);
     112                    }
     113                    catch (Exception)
     114                    {
     115                      //WA: Ignore ?? can't do anything since file is locked by other process and thus file remains.
     116                    }
    110117                }
    111118            }
  • trunk/CrypPlugins/AES/AES.cs

    r1121 r1157  
    22                           Version 2.0, January 2004
    33                        http://www.apache.org/licenses/
    4 
    5    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
    6 
    7    1. Definitions.
    8 
    9       "License" shall mean the terms and conditions for use, reproduction,
    10       and distribution as defined by Sections 1 through 9 of this document.
    11 
    12       "Licensor" shall mean the copyright owner or entity authorized by
    13       the copyright owner that is granting the License.
    14 
    15       "Legal Entity" shall mean the union of the acting entity and all
    16       other entities that control, are controlled by, or are under common
    17       control with that entity. For the purposes of this definition,
    18       "control" means (i) the power, direct or indirect, to cause the
    19       direction or management of such entity, whether by contract or
    20       otherwise, or (ii) ownership of fifty percent (50%) or more of the
    21       outstanding shares, or (iii) beneficial ownership of such entity.
    22 
    23       "You" (or "Your") shall mean an individual or Legal Entity
    24       exercising permissions granted by this License.
    25 
    26       "Source" form shall mean the preferred form for making modifications,
    27       including but not limited to software source code, documentation
    28       source, and configuration files.
    29 
    30       "Object" form shall mean any form resulting from mechanical
    31       transformation or translation of a Source form, including but
    32       not limited to compiled object code, generated documentation,
    33       and conversions to other media types.
    34 
    35       "Work" shall mean the work of authorship, whether in Source or
    36       Object form, made available under the License, as indicated by a
    37       copyright notice that is included in or attached to the work
    38       (an example is provided in the Appendix below).
    39 
    40       "Derivative Works" shall mean any work, whether in Source or Object
    41       form, that is based on (or derived from) the Work and for which the
    42       editorial revisions, annotations, elaborations, or other modifications
    43       represent, as a whole, an original work of authorship. For the purposes
    44       of this License, Derivative Works shall not include works that remain
    45       separable from, or merely link (or bind by name) to the interfaces of,
    46       the Work and Derivative Works thereof.
    47 
    48       "Contribution" shall mean any work of authorship, including
    49       the original version of the Work and any modifications or additions
    50       to that Work or Derivative Works thereof, that is intentionally
    51       submitted to Licensor for inclusion in the Work by the copyright owner
    52       or by an individual or Legal Entity authorized to submit on behalf of
    53       the copyright owner. For the purposes of this definition, "submitted"
    54       means any form of electronic, verbal, or written communication sent
    55       to the Licensor or its representatives, including but not limited to
    56       communication on electronic mailing lists, source code control systems,
    57       and issue tracking systems that are managed by, or on behalf of, the
    58       Licensor for the purpose of discussing and improving the Work, but
    59       excluding communication that is conspicuously marked or otherwise
    60       designated in writing by the copyright owner as "Not a Contribution."
    61 
    62       "Contributor" shall mean Licensor and any individual or Legal Entity
    63       on behalf of whom a Contribution has been received by Licensor and
    64       subsequently incorporated within the Work.
    65 
    66    2. Grant of Copyright License. Subject to the terms and conditions of
    67       this License, each Contributor hereby grants to You a perpetual,
    68       worldwide, non-exclusive, no-charge, royalty-free, irrevocable
    69       copyright license to reproduce, prepare Derivative Works of,
    70       publicly display, publicly perform, sublicense, and distribute the
    71       Work and such Derivative Works in Source or Object form.
    72 
    73    3. Grant of Patent License. Subject to the terms and conditions of
    74       this License, each Contributor hereby grants to You a perpetual,
    75       worldwide, non-exclusive, no-charge, royalty-free, irrevocable
    76       (except as stated in this section) patent license to make, have made,
    77       use, offer to sell, sell, import, and otherwise transfer the Work,
    78       where such license applies only to those patent claims licensable
    79       by such Contributor that are necessarily infringed by their
    80       Contribution(s) alone or by combination of their Contribution(s)
    81       with the Work to which such Contribution(s) was submitted. If You
    82       institute patent litigation against any entity (including a
    83       cross-claim or counterclaim in a lawsuit) alleging that the Work
    84       or a Contribution incorporated within the Work constitutes direct
    85       or contributory patent infringement, then any patent licenses
    86       granted to You under this License for that Work shall terminate
    87       as of the date such litigation is filed.
    88 
    89    4. Redistribution. You may reproduce and distribute copies of the
    90       Work or Derivative Works thereof in any medium, with or without
    91       modifications, and in Source or Object form, provided that You
    92       meet the following conditions:
    93 
    94       (a) You must give any other recipients of the Work or
    95           Derivative Works a copy of this License; and
    96 
    97       (b) You must cause any modified files to carry prominent notices
    98           stating that You changed the files; and
    99 
    100       (c) You must retain, in the Source form of any Derivative Works
    101           that You distribute, all copyright, patent, trademark, and
    102           attribution notices from the Source form of the Work,
    103           excluding those notices that do not pertain to any part of
    104           the Derivative Works; and
    105 
    106       (d) If the Work includes a "NOTICE" text file as part of its
    107           distribution, then any Derivative Works that You distribute must
    108           include a readable copy of the attribution notices contained
    109           within such NOTICE file, excluding those notices that do not
    110           pertain to any part of the Derivative Works, in at least one
    111           of the following places: within a NOTICE text file distributed
    112           as part of the Derivative Works; within the Source form or
    113           documentation, if provided along with the Derivative Works; or,
    114           within a display generated by the Derivative Works, if and
    115           wherever such third-party notices normally appear. The contents
    116           of the NOTICE file are for informational purposes only and
    117           do not modify the License. You may add Your own attribution
    118           notices within Derivative Works that You distribute, alongside
    119           or as an addendum to the NOTICE text from the Work, provided
    120           that such additional attribution notices cannot be construed
    121           as modifying the License.
    122 
    123       You may add Your own copyright statement to Your modifications and
    124       may provide additional or different license terms and conditions
    125       for use, reproduction, or distribution of Your modifications, or
    126       for any such Derivative Works as a whole, provided Your use,
    127       reproduction, and distribution of the Work otherwise complies with
    128       the conditions stated in this License.
    129 
    130    5. Submission of Contributions. Unless You explicitly state otherwise,
    131       any Contribution intentionally submitted for inclusion in the Work
    132       by You to the Licensor shall be under the terms and conditions of
    133       this License, without any additional terms or conditions.
    134       Notwithstanding the above, nothing herein shall supersede or modify
    135       the terms of any separate license agreement you may have executed
    136       with Licensor regarding such Contributions.
    137 
    138    6. Trademarks. This License does not grant permission to use the trade
    139       names, trademarks, service marks, or product names of the Licensor,
    140       except as required for reasonable and customary use in describing the
    141       origin of the Work and reproducing the content of the NOTICE file.
    142 
    143    7. Disclaimer of Warranty. Unless required by applicable law or
    144       agreed to in writing, Licensor provides the Work (and each
    145       Contributor provides its Contributions) on an "AS IS" BASIS,
    146       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    147       implied, including, without limitation, any warranties or conditions
    148       of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
    149       PARTICULAR PURPOSE. You are solely responsible for determining the
    150       appropriateness of using or redistributing the Work and assume any
    151       risks associated with Your exercise of permissions under this License.
    152 
    153    8. Limitation of Liability. In no event and under no legal theory,
    154       whether in tort (including negligence), contract, or otherwise,
    155       unless required by applicable law (such as deliberate and grossly
    156       negligent acts) or agreed to in writing, shall any Contributor be
    157       liable to You for damages, including any direct, indirect, special,
    158       incidental, or consequential damages of any character arising as a
    159       result of this License or out of the use or inability to use the
    160       Work (including but not limited to damages for loss of goodwill,
    161       work stoppage, computer failure or malfunction, or any and all
    162       other commercial damages or losses), even if such Contributor
    163       has been advised of the possibility of such damages.
    164 
    165    9. Accepting Warranty or Additional Liability. While redistributing
    166       the Work or Derivative Works thereof, You may choose to offer,
    167       and charge a fee for, acceptance of support, warranty, indemnity,
    168       or other liability obligations and/or rights consistent with this
    169       License. However, in accepting such obligations, You may act only
    170       on Your own behalf and on Your sole responsibility, not on behalf
    171       of any other Contributor, and only if You agree to indemnify,
    172       defend, and hold each Contributor harmless for any liability
    173       incurred by, or claims asserted against, such Contributor by reason
    174       of your accepting any such warranty or additional liability.
    175 
    176    END OF TERMS AND CONDITIONS
    177 
    178    APPENDIX: How to apply the Apache License to your work.
    179 
    180       To apply the Apache License to your work, attach the following
    181       boilerplate notice, with the fields enclosed by brackets "[]"
    182       replaced with your own identifying information. (Don't include
    183       the brackets!)  The text should be enclosed in the appropriate
    184       comment syntax for the file format. We also recommend that a
    185       file or class name and description of purpose be included on the
    186       same "printed page" as the copyright notice for easier
    187       identification within third-party archives.
    1884
    1895   Copyright [2008] [Dr. Arno Wacker, University of Duisburg-Essen]
     
    357173                inputKey = new byte[16];
    358174                // write a warning to the ouside word
    359                 GuiLogMessage("WARNING - No key provided. Using 0x000..00!", NotificationLevel.Warning);
     175                GuiLogMessage("ERROR: No key provided. Using 0x000..00!", NotificationLevel.Error);
    360176            }
    361177
     
    386202                //create a trivial key
    387203                inputIV = new byte[alg.BlockSize / 8];
    388                 GuiLogMessage("WARNING - No IV provided. Using 0x000..00!", NotificationLevel.Warning);
     204                GuiLogMessage("NOTE: No IV provided. Using 0x000..00!", NotificationLevel.Info);
    389205            }
    390206            alg.IV = this.inputIV;
     
    408224                String dummystring = "Dummy string - no input provided - \"Hello AES World\" - dummy string - no input provided!";
    409225                this.inputStream = new CryptoolStream();
    410                 this.inputStream.OpenRead(this.GetPluginInfoAttribute().Caption, Encoding.Default.GetBytes(dummystring.ToCharArray()));
     226                this.inputStream.OpenRead(Encoding.Default.GetBytes(dummystring.ToCharArray()));
    411227                // write a warning to the ouside word
    412                 GuiLogMessage("WARNING - No input provided. Using dummy data. (" + dummystring + ")", NotificationLevel.Warning);
     228                GuiLogMessage("WARNING: No input provided. Using dummy data. (" + dummystring + ")", NotificationLevel.Warning);
    413229            }
    414230        }
     
    416232        public void Execute()
    417233        {
    418             try
    419             {
    420                 //copy inputStream for Slave
    421                 if (controlSlave is object && InputStream is object && InputIV is object)
    422                 {
    423                     CryptoolStream cs = new CryptoolStream();
    424                     cs.OpenRead(inputStream.FileName);
    425                     ((AESControl)controlSlave).InputStream = cs;
    426                 }
    427 
    428                 process(settings.Action);
    429 
    430                 //Work with slave
    431                 if (controlSlave is object && InputStream is object && InputIV is object)
    432                 {
    433                     ((AESControl)controlSlave).reset();
    434                     ((AESControl)controlSlave).onStatusChanged();
    435 
    436                 }
    437             }
    438             finally
    439             {
    440                 if (controlSlave is object && ((AESControl)controlSlave).InputStream is object)
    441                     ((AESControl)controlSlave).closeStreams();
    442             }
     234            process(settings.Action);
    443235        }
    444236
     
    483275            outputStream = new CryptoolStream();
    484276            listCryptoolStreamsOut.Add(outputStream);
    485             outputStream.OpenWrite(this.GetPluginInfoAttribute().Caption);
     277            outputStream.OpenWrite();
    486278            p_crypto_stream = new CryptoStream((Stream)inputStream, p_encryptor, CryptoStreamMode.Read);
    487279            byte[] buffer = new byte[p_alg.BlockSize / 8];
     
    688480        public event KeyPatternChanged keyPatternChanged;
    689481        public event IControlStatusChangedEventHandler OnStatusChanged;
     482
    690483        private AES plugin;
    691         private SymmetricAlgorithm aes_algorithm = null;
    692         private byte[] input;
    693         private Stream inputStream;
    694 
    695         public void reset()
    696         {
    697             input = null;
    698             aes_algorithm = null;
    699         }
    700 
    701         public CryptoolStream InputStream{
    702             get;set;
    703         }
    704 
     484     
    705485        public AESControl(AES Plugin)
    706486        {
     
    716496        }
    717497
    718         public void closeStreams()
    719         {
    720             if (inputStream != null)
    721                 inputStream.Close();
    722             if (InputStream != null)
    723                 InputStream.Close();
    724         }
     498       
    725499
    726500        public byte[] Decrypt(byte[] ciphertext, byte[] key)
    727501        {
    728             throw new NotImplementedException();
    729         }
    730 
    731         public byte[] Decrypt(byte[] key, int blocksize)
    732         {
    733             int size = (int)this.InputStream.Length;
    734            
    735             if (blocksize < size)
    736                 size = blocksize;
    737            
    738             if (!(this.input is object))
    739             {
    740                 input = new byte[size];
    741                 this.InputStream.Seek(0, 0);
    742                 for (int i = 0; i < size && i < this.InputStream.Length; i++)
    743                     input[i] = (byte)this.InputStream.ReadByte();
    744                 inputStream = new MemoryStream(input);
    745             }
    746             inputStream.Seek(0, 0);
    747 
    748502            CryptoStream crypto_stream = null;
    749             byte[] output = new byte[blocksize];
     503            byte[] output = new byte[ciphertext.Length];
     504
     505
     506            SymmetricAlgorithm aes_algorithm = null;
    750507
    751508            //Decrypt Stream
     
    757514                    { aes_algorithm = new RijndaelManaged(); }
    758515                    else
    759                     { aes_algorithm = new AesCryptoServiceProvider(); }                   
     516                    { aes_algorithm = new AesCryptoServiceProvider(); }
    760517                }
    761                
     518
    762519                this.ConfigureAlg(aes_algorithm, key);
    763                
     520
    764521                ICryptoTransform p_decryptor;
    765522                try
    766523                {
    767524                    p_decryptor = aes_algorithm.CreateDecryptor();
    768                 }               
     525                }
    769526                catch
    770527                {
     
    775532                }
    776533
    777                 crypto_stream = new CryptoStream((Stream)inputStream, p_decryptor, CryptoStreamMode.Read);
     534                crypto_stream = new CryptoStream(new MemoryStream(ciphertext), p_decryptor, CryptoStreamMode.Read);
    778535
    779536                byte[] buffer = new byte[aes_algorithm.BlockSize / 8];
     
    793550                            break;
    794551                        }
    795                     }                   
     552                    }
    796553                    position += bytesRead;
    797554                }
     
    802559                aes_algorithm = null;   // we got an exception so we do not use this object any more
    803560                throw exception;
    804             }           
     561            }
    805562
    806563            return output;
    807564        }
    808565
     566     
     567
    809568        private void ConfigureAlg(SymmetricAlgorithm alg, byte[] key)
    810569        {
     
    816575            {
    817576                //dirty hack to allow weak keys:
    818                 FieldInfo field = aes_algorithm.GetType().GetField("KeyValue", BindingFlags.NonPublic | BindingFlags.Instance);
     577                FieldInfo field = alg.GetType().GetField("KeyValue", BindingFlags.NonPublic | BindingFlags.Instance);
    819578                field.SetValue(alg, key);
    820579            }
    821580
    822             try
    823             {
    824                 alg.IV = this.plugin.InputIV;
    825             }
    826             catch
    827             {
    828                 //dirty hack to allow weak keys:
    829                 FieldInfo field = aes_algorithm.GetType().GetField("IVValue", BindingFlags.NonPublic | BindingFlags.Instance);
    830                 field.SetValue(alg, this.plugin.InputIV);
    831             }
     581            //try
     582            //{
     583            //    alg.IV = this.plugin.InputIV;
     584            //}
     585            //catch
     586            //{
     587            //    //dirty hack to allow weak keys:
     588            //    FieldInfo field = aes_algorithm.GetType().GetField("IVValue", BindingFlags.NonPublic | BindingFlags.Instance);
     589            //    field.SetValue(alg, this.plugin.InputIV);
     590            //}
     591            alg.IV = new byte[alg.BlockSize / 8];
     592
    832593
    833594            switch (((AESSettings)plugin.Settings).Mode)
     
    838599                default: alg.Mode = CipherMode.ECB; break;
    839600            }
    840             switch (((AESSettings)plugin.Settings).Padding)
    841             { //0="Zeros"=default, 1="None", 2="PKCS7"
    842                 case 1: alg.Padding = PaddingMode.None; break;
    843                 case 2: alg.Padding = PaddingMode.PKCS7; break;
    844                 case 3: alg.Padding = PaddingMode.ANSIX923; break;
    845                 case 4: alg.Padding = PaddingMode.ISO10126; break;
    846                 default: alg.Padding = PaddingMode.Zeros; break;
    847             }
     601
     602            alg.Padding = PaddingMode.Zeros;
     603
     604            //switch (((AESSettings)plugin.Settings).Padding)
     605            //{ //0="Zeros"=default, 1="None", 2="PKCS7"
     606            //    case 1: alg.Padding = PaddingMode.None; break;
     607            //    case 2: alg.Padding = PaddingMode.PKCS7; break;
     608            //    case 3: alg.Padding = PaddingMode.ANSIX923; break;
     609            //    case 4: alg.Padding = PaddingMode.ISO10126; break;
     610            //    default: alg.Padding = PaddingMode.Zeros; break;
     611            //}
    848612           
    849613        }
    850 
    851         /// <summary>
    852         /// Called by AES if its status changes
    853         /// </summary>
    854         public void onStatusChanged()
    855         {
    856             if (OnStatusChanged != null)
    857                 OnStatusChanged(this, true);
    858         }
    859 
     614       
    860615        public string getKeyPattern()
    861616        {
     
    950705        {
    951706            AESControl aes = new AESControl(plugin);
    952             CryptoolStream cs = new CryptoolStream();
    953             cs.OpenRead(InputStream.FileName);
    954             aes.InputStream = cs;
    955             aes.reset();
    956707            return aes;
    957708        }
     
    959710        public void Dispose()
    960711        {
    961             closeStreams();
    962712        }
    963713
  • trunk/CrypPlugins/DES/DES.cs

    r1121 r1157  
    1717namespace Cryptool.Plugins.Cryptography.Encryption
    1818{
     19    [Author("Dr. Arno Wacker", "arno.wacker@cryptool.org", "Uni Duisburg", "http://www.uni-duisburg-essen.de")]
    1920    [PluginInfo(false, "DES", "Data Encryption Standard", "DES/DetailedDescription/Description.xaml", "DES/icon.png", "DES/Images/encrypt.png", "DES/Images/decrypt.png")]
    2021    [EncryptionType(EncryptionType.SymmetricBlock)]
     
    3334        #endregion
    3435
     36
     37        #region Initialisation
     38       
    3539        public DES()
    3640        {
    3741            this.settings = new DESSettings();
    38             this.settings.OnPluginStatusChanged += settings_OnPluginStatusChanged;
    39         }
    40 
    41         void settings_OnPluginStatusChanged(IPlugin sender, StatusEventArgs args)
    42         {
    43             if(OnPluginStatusChanged != null)OnPluginStatusChanged(this, args);
    44         }
    45 
    46         public ISettings Settings
    47         {
    48             get { return this.settings; }
    49             set { this.settings = (DESSettings)value; }
    50         }
     42        }
     43
     44
     45       
     46
     47        #endregion
     48
     49        #region External connection properties
     50
     51        [PropertyInfo(Direction.ControlSlave, "DES Slave for Cryptanalysis", "Direct access to the DES component for cryptanalysis.", "", DisplayLevel.Beginner)]
     52        public IControlEncryption ControlSlave
     53        {
     54            get
     55            {
     56                if (controlSlave == null)
     57                    controlSlave = new DESControl(this);
     58                return controlSlave;
     59            }
     60        }
     61
     62        private IControlCubeAttack desSlave;
     63        [PropertyInfo(Direction.ControlSlave, "DES Slave for cube attack", "Direct access to the DES component for usage with the cube attack plugin.", "", DisplayLevel.Beginner)]
     64        public IControlCubeAttack DESSlave
     65        {
     66            get
     67            {
     68                if (desSlave == null)
     69                    desSlave = new CubeAttackControl(this);
     70                return desSlave;
     71            }
     72        }
     73
    5174
    5275        [PropertyInfo(Direction.InputData, "Input", "Data to be encrypted or decrypted", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     
    7295        }
    7396
    74         [PropertyInfo(Direction.InputData, "Key", "Must be 8 bytes.", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     97        [PropertyInfo(Direction.InputData, "Key", "The key for encryption7decryption. It must be exactly 8 bytes (64 Bits).", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    7598        public byte[] InputKey
    7699        {
     
    83106        }
    84107
    85         [PropertyInfo(Direction.InputData, "IV", "IV to be used in chaining modes, must be the same as the Blocksize in bytes (8 bytes).", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     108        [PropertyInfo(Direction.InputData, "IV", "IV to be used in chaining modes, must be the same as the Blocksize in bytes (8 bytes).", null, false, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    86109        public byte[] InputIV
    87110        {
     
    116139        }
    117140
     141        #endregion       
     142
     143        #region Public IPlugin Member
     144
     145        #region Events
     146        public event StatusChangedEventHandler OnPluginStatusChanged;
     147        public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
     148        public event PluginProgressChangedEventHandler OnPluginProgressChanged;
     149        #endregion
     150
     151        public ISettings Settings
     152        {
     153            get { return this.settings; }
     154            set { this.settings = (DESSettings)value; }
     155        }
     156
     157        public UserControl Presentation
     158        {
     159            get { return null; }
     160        }
     161
     162        public UserControl QuickWatchPresentation
     163        {
     164            get { return null; }
     165        }
     166
     167        public void Initialize()
     168        {
     169        }
     170
     171        public void Execute()
     172        {
     173            process(settings.Action);
     174        }
     175
     176
     177        public void Pause()
     178        {
     179
     180        }
     181
     182        public void Stop()
     183        {
     184            this.stop = true;
     185        }
     186
     187        public void Dispose()
     188        {
     189            try
     190            {
     191                stop = false;
     192                inputKey = null;
     193                inputIV = null;
     194
     195                inputStream = null;
     196                outputStream = null;
     197
     198                foreach (CryptoolStream stream in listCryptoolStreamsOut)
     199                {
     200                    stream.Close();
     201                }
     202                listCryptoolStreamsOut.Clear();
     203
     204                if (p_crypto_stream != null)
     205                {
     206                    p_crypto_stream.Flush();
     207                    p_crypto_stream.Close();
     208                    p_crypto_stream = null;
     209                }
     210            }
     211            catch (Exception ex)
     212            {
     213                GuiLogMessage(ex.Message, NotificationLevel.Error);
     214            }
     215            this.stop = false;
     216        }
     217
     218       
     219
     220        public void PostExecution()
     221        {
     222            Dispose();
     223        }
     224
     225        public void PreExecution()
     226        {
     227            Dispose();
     228        }
     229
     230        #endregion
     231
     232        #region INotifyPropertyChanged Members
     233
     234        public event PropertyChangedEventHandler PropertyChanged;
     235
     236        public void OnPropertyChanged(string name)
     237        {
     238            if (PropertyChanged != null)
     239            {
     240                PropertyChanged(this, new PropertyChangedEventArgs(name));
     241            }
     242        }
     243
     244        #endregion
     245
     246           
     247
     248        #region Public DES specific members
     249
     250        public bool isStopped()
     251        {
     252
     253            return this.stop;
     254        }
     255
     256        #endregion
     257
     258
     259        #region Private methods
     260
    118261        private void ConfigureAlg(SymmetricAlgorithm alg)
    119262        {
     
    124267                inputKey = new byte[8];
    125268                // write a warning to the ouside word
    126                 GuiLogMessage("WARNING - No key provided. Using 0x000..00!", NotificationLevel.Warning);
     269                GuiLogMessage("ERROR: No key provided. Using 0x000..00!", NotificationLevel.Error);
    127270            }
    128271            alg.Key = this.inputKey;
     
    133276                //create a trivial key
    134277                inputIV = new byte[alg.BlockSize / 8];
    135                GuiLogMessage("WARNING - No IV provided. Using 0x000..00!", NotificationLevel.Warning);
     278                GuiLogMessage("NOTE: No IV provided. Using 0x000..00!", NotificationLevel.Info);
    136279            }
    137280            alg.IV = this.inputIV;
     
    160303                String dummystring = "Dummy string - no input provided - \"Hello DES World\" - dummy string - no input provided!";
    161304                this.inputStream = new CryptoolStream();
    162                 this.inputStream.OpenRead(this.GetPluginInfoAttribute().Caption, Encoding.Default.GetBytes(dummystring.ToCharArray()));
     305                this.inputStream.OpenRead(Encoding.Default.GetBytes(dummystring.ToCharArray()));
    163306                // write a warning to the ouside word
    164307                GuiLogMessage("WARNING - No input provided. Using dummy data. (" + dummystring + ")", NotificationLevel.Warning);
    165             }
    166         }
    167 
    168         public void Execute()
    169         {
    170             try
    171             {
    172                 //copy inputStream for Slave
    173                 if (controlSlave is object && InputStream is object && InputIV is object)
    174                 {
    175                     CryptoolStream cs = new CryptoolStream();
    176                     cs.OpenRead(inputStream.FileName);
    177                     ((DESControl)controlSlave).InputStream = cs;
    178                 }
    179 
    180                 process(settings.Action);
    181 
    182                 //Work with slave
    183                 if (controlSlave is object && InputStream is object && InputIV is object)
    184                 {
    185                     ((DESControl)controlSlave).reset();
    186                     ((DESControl)controlSlave).onStatusChanged();
    187 
    188                 }
    189             }
    190             finally
    191             {
    192                 if (controlSlave is object && ((DESControl)controlSlave).InputStream is object)
    193                     ((DESControl)controlSlave).closeStreams();
    194308            }
    195309        }
     
    225339                outputStream = new CryptoolStream();
    226340                listCryptoolStreamsOut.Add(outputStream);
    227                 outputStream.OpenWrite(this.GetPluginInfoAttribute().Caption);
     341                outputStream.OpenWrite();
    228342                p_crypto_stream = new CryptoStream((Stream)inputStream, p_encryptor, CryptoStreamMode.Read);
    229343                byte[] buffer = new byte[p_alg.BlockSize / 8];
     
    244358
    245359                p_crypto_stream.Flush();
    246                 outputStream.Close();
    247360                DateTime stopTime = DateTime.Now;
    248361                TimeSpan duration = stopTime - startTime;
     
    252365                    GuiLogMessage("Wrote data to file: " + outputStream.FileName, NotificationLevel.Info);
    253366                    GuiLogMessage("Time used: " + duration.ToString(), NotificationLevel.Debug);
     367                    outputStream.Close();
    254368                    OnPropertyChanged("OutputStream");
    255369                }
    256370                if (stop)
    257371                {
     372                    outputStream.Close();
    258373                    GuiLogMessage("Aborted!", NotificationLevel.Info);
    259374                }
     375                ProgressChanged(1, 1);
     376
    260377            }
    261378            catch (CryptographicException cryptographicException)
     
    274391        }
    275392
    276         public void Encrypt()
    277         {
    278             //Encrypt Stream
    279             process(0);
    280         }
    281 
    282         public void Decrypt()
    283         {
    284             //Decrypt Stream
    285             process(1);
    286         }
    287 
    288         #region IPlugin Member
    289 
    290         public UserControl Presentation
    291         {
    292             get { return null; }
    293         }
    294 
    295         public UserControl QuickWatchPresentation
    296         {
    297           get { return null; }
    298         }
    299 
    300         public void Initialize()
    301         {
    302         }
    303 
    304         public void Dispose()
    305         {
    306             try
    307             {
    308                 stop = false;
    309                 inputKey = null;
    310                 inputIV = null;
    311 
    312                 inputStream = null;
    313                 outputStream = null;
    314 
    315                 foreach (CryptoolStream stream in listCryptoolStreamsOut)
    316                 {
    317                     stream.Close();
    318                 }
    319                 listCryptoolStreamsOut.Clear();
    320 
    321                 if (p_crypto_stream != null)
    322                 {
    323                     p_crypto_stream.Flush();
    324                     p_crypto_stream.Close();
    325                     p_crypto_stream = null;
    326                 }
    327             }
    328             catch (Exception ex)
    329             {
    330                 GuiLogMessage(ex.Message, NotificationLevel.Error);
    331             }
    332             this.stop = false;
    333         }
    334 
    335         public void Stop()
    336         {
    337             this.stop = true;
    338         }
    339 
    340         public bool isStopped(){
    341 
    342             return this.stop;
    343         }
    344 
    345         public void PostExecution()
    346         {
    347             Dispose();
    348         }
    349 
    350         public void PreExecution()
    351         {
    352             Dispose();
    353         }
    354 
    355         #endregion
    356 
    357         #region INotifyPropertyChanged Members
    358 
    359         public event PropertyChangedEventHandler PropertyChanged;
    360 
    361         public void OnPropertyChanged(string name)
    362         {
    363             if (PropertyChanged != null)
    364             {
    365                 PropertyChanged(this, new PropertyChangedEventArgs(name));
    366             }
    367         }
    368 
    369         #endregion
    370 
    371         #region IPlugin Members
    372 
    373         public event StatusChangedEventHandler OnPluginStatusChanged;
    374 
    375         public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
    376         public void GuiLogMessage(string message, NotificationLevel logLevel)
    377         {
    378           if (OnGuiLogNotificationOccured != null)
    379           {
    380             OnGuiLogNotificationOccured(this, new GuiLogEventArgs(message, this, logLevel));
    381           }
    382         }
    383 
    384         public event PluginProgressChangedEventHandler OnPluginProgressChanged;
     393        private void GuiLogMessage(string message, NotificationLevel logLevel)
     394        {
     395            if (OnGuiLogNotificationOccured != null)
     396            {
     397                OnGuiLogNotificationOccured(this, new GuiLogEventArgs(message, this, logLevel));
     398            }
     399        }
     400
     401
    385402        private void ProgressChanged(double value, double max)
    386403        {
    387           if (OnPluginProgressChanged != null)
    388           {
    389             OnPluginProgressChanged(this, new PluginProgressEventArgs(value, max));
    390           }
    391         }
    392 
    393         public void Pause()
    394         {
    395          
    396         }
    397 
    398         #endregion
    399 
    400         [PropertyInfo(Direction.ControlSlave, "DES Slave", "Direct access to DES.", "", DisplayLevel.Beginner)]
    401         public IControlEncryption ControlSlave
    402         {
    403           get
    404           {
    405               if (controlSlave == null)
    406                   controlSlave = new DESControl(this);
    407               return controlSlave;
    408           }
    409         }
    410 
    411         private IControlCubeAttack desSlave;
    412         [PropertyInfo(Direction.ControlSlave, "DES for cube attack", "Direct access to DES.", "", DisplayLevel.Beginner)]
    413         public IControlCubeAttack DESSlave
    414         {
    415             get
    416             {
    417                 if (desSlave == null)
    418                     desSlave = new CubeAttackControl(this);
    419                 return desSlave;
    420             }
    421         }
     404            if (OnPluginProgressChanged != null)
     405            {
     406                OnPluginProgressChanged(this, new PluginProgressEventArgs(value, max));
     407            }
     408        }
     409
     410        #endregion
     411
    422412    }
    423413
     414   
    424415    #region DESControl : IControlCubeAttack
    425416
     
    528519    #endregion
    529520
     521
     522    #region DESControl : IControlEncryption
    530523    public class DESControl : IControlEncryption
    531524    {
    532525        public event KeyPatternChanged keyPatternChanged;
    533526        public event IControlStatusChangedEventHandler OnStatusChanged;
     527
     528       
    534529        private DES plugin;
    535         private SymmetricAlgorithm des_algorithm = null;
    536         private byte[] input;
    537         private Stream inputStream;
    538  
    539         public CryptoolStream InputStream{
    540             get;set;
    541         }
    542 
    543         public void reset()
    544         {
    545             input = null;
    546             des_algorithm = null;
    547         }
    548 
    549         public void closeStreams()
    550         {
    551             if (inputStream != null)
    552                 inputStream.Close();
    553             if (InputStream != null)
    554                 InputStream.Close();
    555         }
    556530
    557531        public DESControl(DES Plugin)
    558532        {
    559533            this.plugin = Plugin;
    560         }
    561 
    562         #region IControlEncryption Members
     534
     535            // Change the padding mode to zeroes, since we want to do bruteforcing..
     536            ((DESSettings)plugin.Settings).Padding = 0;
     537        }
     538
     539       
    563540
    564541        public byte[] Encrypt(byte[] key, int blocksize)
     
    572549        {
    573550            CryptoStream crypto_stream = null;
    574             byte[] output = new byte[8];
     551            byte[] output = new byte[ciphertext.Length];
    575552           
    576553            // always recreating this instance is thread-safe, but may cost us some performance
    577554            SymmetricAlgorithm des_algorithm  = new DESCryptoServiceProvider();
    578555
    579             // TODO: this should be configurable via method signature
    580             des_algorithm.Mode = CipherMode.ECB;
    581             des_algorithm.Padding = PaddingMode.PKCS7;
     556            switch (((DESSettings)plugin.Settings).Mode)
     557            { //0="ECB"=default, 1="CBC", 2="CFB", 3="OFB"
     558                case 1: des_algorithm.Mode = CipherMode.CBC; break;
     559                case 2: des_algorithm.Mode = CipherMode.CFB; break;
     560                case 3: des_algorithm.Mode = CipherMode.OFB; break;
     561                default: des_algorithm.Mode = CipherMode.ECB; break;
     562            }
     563
     564            // Padding for DES must always be set to zeroes
     565            // other padding types lead to error while decrypting
     566            // padding type of none leads to error if size does not match exactly a multiple of 8 Byte
     567            des_algorithm.Padding = PaddingMode.Zeros;
     568
     569            // TODO: this must be passed via the interface
     570            des_algorithm.IV = new byte[des_algorithm.BlockSize / 8]; // IV of 0x00..00
    582571
    583572            try
     
    589578                //dirty hack to allow weak keys:
    590579                FieldInfo field = des_algorithm.GetType().GetField("KeyValue", BindingFlags.NonPublic | BindingFlags.Instance);
    591                 Console.WriteLine(des_algorithm.GetType());
     580                //Console.WriteLine(des_algorithm.GetType());
    592581                field.SetValue(des_algorithm, key);
    593582            }
     
    606595            }
    607596
    608             crypto_stream = new CryptoStream(new MemoryStream(ciphertext, false), p_decryptor, CryptoStreamMode.Read);
     597            crypto_stream = new CryptoStream(new MemoryStream(ciphertext), p_decryptor, CryptoStreamMode.Read);
    609598
    610599            int read, readOverall = 0;
     
    616605
    617606            return output;
    618 
    619             //try
    620             //{
    621             //    des_algorithm.IV = this.plugin.InputIV;
    622             //}
    623             //catch
    624             //{
    625             //    //dirty hack to allow weak keys:
    626             //    FieldInfo field = des_algorithm.GetType().GetField("IVValue", BindingFlags.NonPublic | BindingFlags.Instance);
    627             //    field.SetValue(des_algorithm, this.plugin.InputIV);
    628             //}
    629 
    630             //switch (((DESSettings)plugin.Settings).Mode)
    631             //{ //0="ECB"=default, 1="CBC", 2="CFB", 3="OFB"
    632             //    case 1: alg.Mode = CipherMode.CBC; break;
    633             //    case 2: alg.Mode = CipherMode.CFB; break;
    634             //    case 3: alg.Mode = CipherMode.OFB; break;
    635             //    default: alg.Mode = CipherMode.ECB; break;
    636             //}
    637             //switch (((DESSettings)plugin.Settings).Padding)
    638             //{ //0="Zeros"=default, 1="None", 2="PKCS7"
    639             //    case 1: alg.Padding = PaddingMode.None; break;
    640             //    case 2: alg.Padding = PaddingMode.PKCS7; break;
    641             //    case 3: alg.Padding = PaddingMode.ANSIX923; break;
    642             //    case 4: alg.Padding = PaddingMode.ISO10126; break;
    643             //    default: alg.Padding = PaddingMode.Zeros; break;
    644             //}
    645         }
    646 
    647         [Obsolete("this signature doesn't pass the ciphertext, use Decrypt(byte[], byte[]) instead")]
    648         public byte[] Decrypt(byte[] key, int blocksize)
    649         {
    650             int size = (int)this.InputStream.Length;
    651 
    652             if (blocksize < size)
    653                 size = blocksize;
    654 
    655             if (!(this.input is object))
    656             {
    657                 input = new byte[size];
    658                 this.InputStream.Seek(0, 0);
    659                 for (int i = 0; i < size && i < this.InputStream.Length; i++)
    660                     input[i] = (byte)this.InputStream.ReadByte();
    661                 inputStream = new MemoryStream(input);
    662             }
    663             inputStream.Seek(0, 0);
    664 
    665             CryptoStream crypto_stream = null;
    666             byte[] output = new byte[blocksize];
    667 
    668             //Decrypt Stream
    669             try
    670             {
    671                 if (!(des_algorithm is object))
    672                 {
    673                     des_algorithm = new DESCryptoServiceProvider();
    674                 }
    675 
    676                 this.ConfigureAlg(des_algorithm, key);
    677 
    678                 ICryptoTransform p_decryptor;
    679                 try
    680                 {
    681                     p_decryptor = des_algorithm.CreateDecryptor();
    682                 }
    683                 catch
    684                 {
    685                     //dirty hack to allow weak keys:
    686                     MethodInfo mi = des_algorithm.GetType().GetMethod("_NewEncryptor", BindingFlags.NonPublic | BindingFlags.Instance);
    687                     object[] Par = { des_algorithm.Key, des_algorithm.Mode, des_algorithm.IV, des_algorithm.FeedbackSize, 0 };
    688                     p_decryptor = mi.Invoke(des_algorithm, Par) as ICryptoTransform;
    689                 }
    690 
    691                 crypto_stream = new CryptoStream((Stream)inputStream, p_decryptor, CryptoStreamMode.Read);
    692 
    693                 byte[] buffer = new byte[des_algorithm.BlockSize / 8];
    694                 int bytesRead;
    695                 int position = 0;
    696 
    697                 while ((bytesRead = crypto_stream.Read(buffer, 0, buffer.Length)) > 0 && !plugin.isStopped())
    698                 {
    699                     for (int i = 0; i < bytesRead; i++)
    700                     {
    701                         if (position + i < output.Length)
    702                         {
    703                             output[position + i] = buffer[i];
    704                         }
    705                         else
    706                         {
    707                             break;
    708                         }
    709                     }
    710                     position += bytesRead;
    711                 }
    712 
    713 
    714             }
    715             catch (Exception exception)
    716             {
    717                 des_algorithm = null;   // we got an exception so we do not use this object any more
    718                 throw exception;
    719             }
    720 
    721             return output;
    722         }
    723 
    724         [Obsolete("being used by obsolete Decrypt(byte[], int)")]
    725         private void ConfigureAlg(SymmetricAlgorithm alg, byte[] key)
    726         {
    727             try
    728             {
    729                 alg.Key = key;
    730             }
    731             catch
    732             {
    733                 //dirty hack to allow weak keys:
    734                 FieldInfo field = des_algorithm.GetType().GetField("KeyValue", BindingFlags.NonPublic | BindingFlags.Instance);
    735                 field.SetValue(alg, key);
    736             }
    737 
    738             try
    739             {
    740                 alg.IV = this.plugin.InputIV;
    741             }
    742             catch
    743             {
    744                 //dirty hack to allow weak keys:
    745                 FieldInfo field = des_algorithm.GetType().GetField("IVValue", BindingFlags.NonPublic | BindingFlags.Instance);
    746                 field.SetValue(alg, this.plugin.InputIV);
    747             }
    748 
    749             switch (((DESSettings)plugin.Settings).Mode)
    750             { //0="ECB"=default, 1="CBC", 2="CFB", 3="OFB"
    751                 case 1: alg.Mode = CipherMode.CBC; break;
    752                 case 2: alg.Mode = CipherMode.CFB; break;
    753                 case 3: alg.Mode = CipherMode.OFB; break;
    754                 default: alg.Mode = CipherMode.ECB; break;
    755             }
    756             switch (((DESSettings)plugin.Settings).Padding)
    757             { //0="Zeros"=default, 1="None", 2="PKCS7"
    758                 case 1: alg.Padding = PaddingMode.None; break;
    759                 case 2: alg.Padding = PaddingMode.PKCS7; break;
    760                 case 3: alg.Padding = PaddingMode.ANSIX923; break;
    761                 case 4: alg.Padding = PaddingMode.ISO10126; break;
    762                 default: alg.Padding = PaddingMode.Zeros; break;
    763             }
    764 
    765         }
    766 
    767         /// <summary>
    768         /// Called by DES if its status changes
    769         /// </summary>
    770         public void onStatusChanged()
    771         {
    772             if (OnStatusChanged != null)
    773                 OnStatusChanged(this, true);
    774607        }
    775608
     
    833666        {
    834667            DESControl des = new DESControl(plugin);
    835             CryptoolStream cs = new CryptoolStream();
    836             cs.OpenRead(InputStream.FileName);
    837             des.InputStream = cs;
    838             des.reset();
    839668            return des;
    840669        }
     
    842671        public void Dispose()
    843672        {
    844             closeStreams();
    845         }
    846 
    847         void IControlEncryption.changeSettings(string setting, object value)
     673           
     674        }
     675
     676        public void changeSettings(string setting, object value)
    848677        {
    849678            throw new NotImplementedException();
    850679        }
    851680
    852 
    853         #endregion
    854681    }
     682    #endregion
    855683}
  • trunk/CrypPlugins/DES/DESSettings.cs

    r230 r1157  
    7676        #endregion
    7777
    78         public event StatusChangedEventHandler OnPluginStatusChanged;
    79 
    80         private void ChangePluginIcon(int Icon)
    81         {
    82             if (OnPluginStatusChanged != null) OnPluginStatusChanged(null, new StatusEventArgs(StatusChangedMode.ImageUpdate, Icon));
    83         }
    84 
    8578    }
    8679}
  • trunk/CrypPlugins/SDES/SDES.cs

    r1121 r1157  
    586586        }
    587587
     588        /// <summary>
     589        /// Called by a Master to start decryption with ciphertext
     590        /// </summary>
     591        /// <param name="key">key</param>
     592        /// <param name="bytesToUse">bytesToUse</param>
     593        /// <returns>decrypted text</returns>
    588594        public byte[] Decrypt(byte[] ciphertext, byte[] key)
    589595        {
    590             throw new NotImplementedException();
     596            return execute(ciphertext, key, ciphertext.Length, 1);
    591597        }
    592598
     
    652658        /// Called by itself to start encryption/decryption
    653659        /// </summary>
     660        /// /// <param name="data">The data for encryption/decryption</param>
     661        /// <param name="key">key</param>
     662        /// <param name="bytesToUse">bytesToUse</param>
     663        /// <returns>encrypted/decrypted text</returns>
     664        private byte[] execute(byte[] data, byte[] key, int bytesToUse, int action)
     665        {
     666            byte[] output;
     667            if (bytesToUse > 0)
     668                output = new byte[bytesToUse];
     669            else
     670                output = new byte[data.Length];
     671
     672
     673            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
     674
     675            string IVString = "00000000";
     676            if (plugin.InputIV != null)
     677            {
     678                IVString = enc.GetString(plugin.InputIV);
     679            }
     680           
     681            if (((SDESSettings)plugin.Settings).Mode == 0 && action == 0)
     682            {
     683                output = ecb.encrypt(data, key, bytesToUse);
     684            }
     685            else if (((SDESSettings)plugin.Settings).Mode == 1 && action == 0)
     686            {
     687                output = cbc.encrypt(data, key, Tools.stringToBinaryByteArray(IVString), bytesToUse);
     688            }
     689            else if (((SDESSettings)plugin.Settings).Mode == 0 && action == 1)
     690            {
     691                output = ecb.decrypt(data, key, bytesToUse);
     692            }
     693            else if (((SDESSettings)plugin.Settings).Mode == 1 && action == 1)
     694            {
     695                output = cbc.decrypt(data, key, Tools.stringToBinaryByteArray(IVString), bytesToUse);
     696            }
     697            return output;
     698
     699        }
     700
     701        /// <summary>
     702        /// Called by itself to start encryption/decryption
     703        /// </summary>
    654704        /// <param name="key">key</param>
    655705        /// <param name="bytesToUse">bytesToUse</param>
     
    657707        private byte[] execute(byte[] key, int bytesToUse, int action)
    658708        {
    659             byte[] output;
    660             if (bytesToUse > 0)
    661                 output = new byte[bytesToUse];
    662             else
    663                 output = new byte[plugin.InputStream.Length];
    664 
     709           
    665710            if (input == null || plugin.InputChanged)
    666711            {
     
    678723                }
    679724            }
    680          
    681             System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
    682             if (((SDESSettings)plugin.Settings).Mode == 0 && action == 0)
    683             {                               
    684                 output = ecb.encrypt(input, key, bytesToUse);
    685             }
    686             else if(((SDESSettings)plugin.Settings).Mode == 1 && action == 0)
    687             {               
    688                 output = cbc.encrypt(input, key, Tools.stringToBinaryByteArray(enc.GetString(plugin.InputIV)),bytesToUse);
    689             }           
    690             else if(((SDESSettings)plugin.Settings).Mode == 0 && action == 1)
    691             {
    692                 output = ecb.decrypt(input, key,bytesToUse);
    693             }
    694             else if (((SDESSettings)plugin.Settings).Mode == 1 && action == 1)
    695             {
    696                 output = cbc.decrypt(input, key, Tools.stringToBinaryByteArray(enc.GetString(plugin.InputIV)), bytesToUse);
    697             }   
    698             return output;
     725
     726            return execute(input, key, bytesToUse, action);
    699727        }
    700728
  • trunk/CrypPlugins/StreamToStringConverter/StreamToStringConverter.cs

    r438 r1157  
    22                           Version 2.0, January 2004
    33                        http://www.apache.org/licenses/
    4 
    5    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
    6 
    7    1. Definitions.
    8 
    9       "License" shall mean the terms and conditions for use, reproduction,
    10       and distribution as defined by Sections 1 through 9 of this document.
    11 
    12       "Licensor" shall mean the copyright owner or entity authorized by
    13       the copyright owner that is granting the License.
    14 
    15       "Legal Entity" shall mean the union of the acting entity and all
    16       other entities that control, are controlled by, or are under common
    17       control with that entity. For the purposes of this definition,
    18       "control" means (i) the power, direct or indirect, to cause the
    19       direction or management of such entity, whether by contract or
    20       otherwise, or (ii) ownership of fifty percent (50%) or more of the
    21       outstanding shares, or (iii) beneficial ownership of such entity.
    22 
    23       "You" (or "Your") shall mean an individual or Legal Entity
    24       exercising permissions granted by this License.
    25 
    26       "Source" form shall mean the preferred form for making modifications,
    27       including but not limited to software source code, documentation
    28       source, and configuration files.
    29 
    30       "Object" form shall mean any form resulting from mechanical
    31       transformation or translation of a Source form, including but
    32       not limited to compiled object code, generated documentation,
    33       and conversions to other media types.
    34 
    35       "Work" shall mean the work of authorship, whether in Source or
    36       Object form, made available under the License, as indicated by a
    37       copyright notice that is included in or attached to the work
    38       (an example is provided in the Appendix below).
    39 
    40       "Derivative Works" shall mean any work, whether in Source or Object
    41       form, that is based on (or derived from) the Work and for which the
    42       editorial revisions, annotations, elaborations, or other modifications
    43       represent, as a whole, an original work of authorship. For the purposes
    44       of this License, Derivative Works shall not include works that remain
    45       separable from, or merely link (or bind by name) to the interfaces of,
    46       the Work and Derivative Works thereof.
    47 
    48       "Contribution" shall mean any work of authorship, including
    49       the original version of the Work and any modifications or additions
    50       to that Work or Derivative Works thereof, that is intentionally
    51       submitted to Licensor for inclusion in the Work by the copyright owner
    52       or by an individual or Legal Entity authorized to submit on behalf of
    53       the copyright owner. For the purposes of this definition, "submitted"
    54       means any form of electronic, verbal, or written communication sent
    55       to the Licensor or its representatives, including but not limited to
    56       communication on electronic mailing lists, source code control systems,
    57       and issue tracking systems that are managed by, or on behalf of, the
    58       Licensor for the purpose of discussing and improving the Work, but
    59       excluding communication that is conspicuously marked or otherwise
    60       designated in writing by the copyright owner as "Not a Contribution."
    61 
    62       "Contributor" shall mean Licensor and any individual or Legal Entity
    63       on behalf of whom a Contribution has been received by Licensor and
    64       subsequently incorporated within the Work.
    65 
    66    2. Grant of Copyright License. Subject to the terms and conditions of
    67       this License, each Contributor hereby grants to You a perpetual,
    68       worldwide, non-exclusive, no-charge, royalty-free, irrevocable
    69       copyright license to reproduce, prepare Derivative Works of,
    70       publicly display, publicly perform, sublicense, and distribute the
    71       Work and such Derivative Works in Source or Object form.
    72 
    73    3. Grant of Patent License. Subject to the terms and conditions of
    74       this License, each Contributor hereby grants to You a perpetual,
    75       worldwide, non-exclusive, no-charge, royalty-free, irrevocable
    76       (except as stated in this section) patent license to make, have made,
    77       use, offer to sell, sell, import, and otherwise transfer the Work,
    78       where such license applies only to those patent claims licensable
    79       by such Contributor that are necessarily infringed by their
    80       Contribution(s) alone or by combination of their Contribution(s)
    81       with the Work to which such Contribution(s) was submitted. If You
    82       institute patent litigation against any entity (including a
    83       cross-claim or counterclaim in a lawsuit) alleging that the Work
    84       or a Contribution incorporated within the Work constitutes direct
    85       or contributory patent infringement, then any patent licenses
    86       granted to You under this License for that Work shall terminate
    87       as of the date such litigation is filed.
    88 
    89    4. Redistribution. You may reproduce and distribute copies of the
    90       Work or Derivative Works thereof in any medium, with or without
    91       modifications, and in Source or Object form, provided that You
    92       meet the following conditions:
    93 
    94       (a) You must give any other recipients of the Work or
    95           Derivative Works a copy of this License; and
    96 
    97       (b) You must cause any modified files to carry prominent notices
    98           stating that You changed the files; and
    99 
    100       (c) You must retain, in the Source form of any Derivative Works
    101           that You distribute, all copyright, patent, trademark, and
    102           attribution notices from the Source form of the Work,
    103           excluding those notices that do not pertain to any part of
    104           the Derivative Works; and
    105 
    106       (d) If the Work includes a "NOTICE" text file as part of its
    107           distribution, then any Derivative Works that You distribute must
    108           include a readable copy of the attribution notices contained
    109           within such NOTICE file, excluding those notices that do not
    110           pertain to any part of the Derivative Works, in at least one
    111           of the following places: within a NOTICE text file distributed
    112           as part of the Derivative Works; within the Source form or
    113           documentation, if provided along with the Derivative Works; or,
    114           within a display generated by the Derivative Works, if and
    115           wherever such third-party notices normally appear. The contents
    116           of the NOTICE file are for informational purposes only and
    117           do not modify the License. You may add Your own attribution
    118           notices within Derivative Works that You distribute, alongside
    119           or as an addendum to the NOTICE text from the Work, provided
    120           that such additional attribution notices cannot be construed
    121           as modifying the License.
    122 
    123       You may add Your own copyright statement to Your modifications and
    124       may provide additional or different license terms and conditions
    125       for use, reproduction, or distribution of Your modifications, or
    126       for any such Derivative Works as a whole, provided Your use,
    127       reproduction, and distribution of the Work otherwise complies with
    128       the conditions stated in this License.
    129 
    130    5. Submission of Contributions. Unless You explicitly state otherwise,
    131       any Contribution intentionally submitted for inclusion in the Work
    132       by You to the Licensor shall be under the terms and conditions of
    133       this License, without any additional terms or conditions.
    134       Notwithstanding the above, nothing herein shall supersede or modify
    135       the terms of any separate license agreement you may have executed
    136       with Licensor regarding such Contributions.
    137 
    138    6. Trademarks. This License does not grant permission to use the trade
    139       names, trademarks, service marks, or product names of the Licensor,
    140       except as required for reasonable and customary use in describing the
    141       origin of the Work and reproducing the content of the NOTICE file.
    142 
    143    7. Disclaimer of Warranty. Unless required by applicable law or
    144       agreed to in writing, Licensor provides the Work (and each
    145       Contributor provides its Contributions) on an "AS IS" BASIS,
    146       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    147       implied, including, without limitation, any warranties or conditions
    148       of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
    149       PARTICULAR PURPOSE. You are solely responsible for determining the
    150       appropriateness of using or redistributing the Work and assume any
    151       risks associated with Your exercise of permissions under this License.
    152 
    153    8. Limitation of Liability. In no event and under no legal theory,
    154       whether in tort (including negligence), contract, or otherwise,
    155       unless required by applicable law (such as deliberate and grossly
    156       negligent acts) or agreed to in writing, shall any Contributor be
    157       liable to You for damages, including any direct, indirect, special,
    158       incidental, or consequential damages of any character arising as a
    159       result of this License or out of the use or inability to use the
    160       Work (including but not limited to damages for loss of goodwill,
    161       work stoppage, computer failure or malfunction, or any and all
    162       other commercial damages or losses), even if such Contributor
    163       has been advised of the possibility of such damages.
    164 
    165    9. Accepting Warranty or Additional Liability. While redistributing
    166       the Work or Derivative Works thereof, You may choose to offer,
    167       and charge a fee for, acceptance of support, warranty, indemnity,
    168       or other liability obligations and/or rights consistent with this
    169       License. However, in accepting such obligations, You may act only
    170       on Your own behalf and on Your sole responsibility, not on behalf
    171       of any other Contributor, and only if You agree to indemnify,
    172       defend, and hold each Contributor harmless for any liability
    173       incurred by, or claims asserted against, such Contributor by reason
    174       of your accepting any such warranty or additional liability.
    175 
    176    END OF TERMS AND CONDITIONS
    177 
    178    APPENDIX: How to apply the Apache License to your work.
    179 
    180       To apply the Apache License to your work, attach the following
    181       boilerplate notice, with the fields enclosed by brackets "[]"
    182       replaced with your own identifying information. (Don't include
    183       the brackets!)  The text should be enclosed in the appropriate
    184       comment syntax for the file format. We also recommend that a
    185       file or class name and description of purpose be included on the
    186       same "printed page" as the copyright notice for easier
    187       identification within third-party archives.
    1884
    1895   Copyright [2008] [Dr. Arno Wacker, University of Duisburg-Essen]
Note: See TracChangeset for help on using the changeset viewer.