~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/mod/sec/shl/Rc4.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ---------------------------------------------------------------------------
 
2
// - Rc4.hpp                                                                 -
 
3
// - afnix:sec module - RC4 block cipher class definition                    -
 
4
// ---------------------------------------------------------------------------
 
5
// - This program is free software;  you can redistribute it  and/or  modify -
 
6
// - it provided that this copyright notice is kept intact.                  -
 
7
// -                                                                         -
 
8
// - This program  is  distributed in  the hope  that it will be useful, but -
 
9
// - without  any  warranty;  without  even   the   implied    warranty   of -
 
10
// - merchantability or fitness for a particular purpose.  In no event shall -
 
11
// - the copyright holder be liable for any  direct, indirect, incidental or -
 
12
// - special damages arising in any way out of the use of this software.     -
 
13
// ---------------------------------------------------------------------------
 
14
// - copyright (c) 1999-2011 amaury darsch                                   -
 
15
// ---------------------------------------------------------------------------
 
16
 
 
17
#ifndef  AFNIX_RC4_HPP
 
18
#define  AFNIX_RC4_HPP
 
19
 
 
20
#ifndef  AFNIX_SERIALCIPHER_HPP
 
21
#include "SerialCipher.hpp"
 
22
#endif
 
23
 
 
24
namespace afnix {
 
25
 
 
26
  /// The Rc4 class is a serial cipher class that implements the RC4
 
27
  /// encryption algorithm. This is an original implementation that
 
28
  /// conforms to ARC4 published specification. The cipher operates with
 
29
  /// a serial key which can be at least 256 bytes.
 
30
  /// @author amaury darsch
 
31
 
 
32
  class Rc4 : public SerialCipher {
 
33
  private:
 
34
    /// the derived s-box
 
35
    t_byte* p_sbox;
 
36
    /// the sbox indexes
 
37
    long d_sidx[2];
 
38
 
 
39
    /// encode a byte into another one
 
40
    /// @param bi the input byte
 
41
    t_byte encode (const t_byte bi);
 
42
    
 
43
    /// decode a byte into another one
 
44
    /// @param bi the input byte
 
45
    t_byte decode (const t_byte bi);
 
46
 
 
47
  public:
 
48
    /// create a new cipher by key
 
49
    /// @param key the cipher key
 
50
    Rc4 (const Key& key);
 
51
 
 
52
    /// create a new cipher by key and flag
 
53
    /// @param key the cipher key
 
54
    /// @param rflg the reverse flag
 
55
    Rc4 (const Key& key, const bool rflg);
 
56
 
 
57
    /// destroy this cipher
 
58
    ~Rc4 (void);
 
59
 
 
60
    /// @return the class name
 
61
    String repr (void) const;
 
62
 
 
63
    /// reset this cipher
 
64
    void reset (void);
 
65
 
 
66
  private:
 
67
    // make the copy constructor private
 
68
    Rc4 (const Rc4&);
 
69
    // make the assignment operator private
 
70
    Rc4& operator = (const Rc4&);
 
71
 
 
72
  public:
 
73
    /// create a new object in a generic way
 
74
    /// @param argv the argument vector
 
75
    static Object* mknew (Vector* argv);
 
76
  };
 
77
}
 
78
 
 
79
#endif