cryptopp 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +14 -0
- data/Guardfile +17 -0
- data/MIT-LICENSE +1 -1
- data/Rakefile +20 -27
- data/VERSION +1 -0
- data/cryptopp.gemspec +7 -182
- data/ext/Rakefile +2 -2
- data/ext/ciphers.cpp +619 -619
- data/ext/cryptopp.cpp +220 -217
- data/ext/cryptopp_ruby_api.h +7 -7
- data/ext/defs/hashes.def +16 -0
- data/ext/defs/hmacs.def +16 -0
- data/ext/digests.cpp +635 -601
- data/ext/extconf.rb +61 -19
- data/ext/j3way.cpp +5 -5
- data/ext/j3way.h +6 -6
- data/ext/jadler32.h +6 -6
- data/ext/jaes.cpp +5 -5
- data/ext/jaes.h +6 -6
- data/ext/jarc4.cpp +5 -5
- data/ext/jarc4.h +6 -6
- data/ext/jbase.cpp +94 -94
- data/ext/jbase.h +49 -55
- data/ext/jbasiccipherinfo.h +23 -23
- data/ext/jblowfish.cpp +5 -5
- data/ext/jblowfish.h +6 -6
- data/ext/jcamellia.cpp +5 -7
- data/ext/jcamellia.h +6 -8
- data/ext/jcast128.cpp +5 -5
- data/ext/jcast128.h +6 -6
- data/ext/jcast256.cpp +5 -5
- data/ext/jcast256.h +6 -6
- data/ext/jcipher.cpp +62 -62
- data/ext/jcipher.h +24 -24
- data/ext/jcipher_t.h +383 -383
- data/ext/jconfig.h +29 -46
- data/ext/jconstants.h +120 -122
- data/ext/jcrc32.h +6 -6
- data/ext/jdes.cpp +5 -5
- data/ext/jdes.h +6 -6
- data/ext/jdes_ede2.cpp +5 -5
- data/ext/jdes_ede2.h +6 -6
- data/ext/jdes_ede3.cpp +5 -5
- data/ext/jdes_ede3.h +6 -6
- data/ext/jdes_xex3.cpp +5 -5
- data/ext/jdes_xex3.h +6 -6
- data/ext/jdiamond2.cpp +5 -5
- data/ext/jdiamond2.h +6 -6
- data/ext/jdiamond2lite.cpp +5 -5
- data/ext/jdiamond2lite.h +6 -6
- data/ext/jexception.h +5 -5
- data/ext/jgost.cpp +5 -5
- data/ext/jgost.h +6 -6
- data/ext/jhash.cpp +51 -51
- data/ext/jhash.h +22 -27
- data/ext/jhash_t.h +59 -59
- data/ext/jhaval.h +15 -15
- data/ext/jhelpers.cpp +54 -54
- data/ext/jhelpers.h +3 -3
- data/ext/jhmac.cpp +20 -20
- data/ext/jhmac.h +15 -15
- data/ext/jhmac_t.h +40 -72
- data/ext/jidea.cpp +5 -5
- data/ext/jidea.h +6 -6
- data/ext/jmarc4.cpp +5 -5
- data/ext/jmarc4.h +6 -6
- data/ext/jmars.cpp +5 -5
- data/ext/jmars.h +6 -6
- data/ext/jmd2.h +9 -9
- data/ext/jmd4.h +9 -9
- data/ext/jmd5.h +9 -9
- data/ext/jpanamacipher.cpp +7 -7
- data/ext/jpanamacipher.h +9 -9
- data/ext/jpanamahash.h +9 -9
- data/ext/jrc2.cpp +15 -15
- data/ext/jrc2.h +11 -11
- data/ext/jrc5.cpp +5 -5
- data/ext/jrc5.h +6 -6
- data/ext/jrc6.cpp +5 -5
- data/ext/jrc6.h +6 -6
- data/ext/jripemd160.h +28 -28
- data/ext/jsafer.cpp +7 -7
- data/ext/jsafer.h +9 -9
- data/ext/jseal.cpp +7 -7
- data/ext/jseal.h +9 -9
- data/ext/jserpent.cpp +5 -5
- data/ext/jserpent.h +6 -6
- data/ext/jsha.h +38 -37
- data/ext/jsha3.h +130 -0
- data/ext/jsha3_blocksizes.h +73 -0
- data/ext/jshacal2.cpp +5 -5
- data/ext/jshacal2.h +6 -6
- data/ext/jshark.cpp +5 -7
- data/ext/jshark.h +6 -8
- data/ext/jsink.cpp +57 -57
- data/ext/jsink.h +127 -123
- data/ext/jskipjack.cpp +5 -5
- data/ext/jskipjack.h +6 -6
- data/ext/jsquare.cpp +5 -5
- data/ext/jsquare.h +6 -6
- data/ext/jstream.cpp +3 -3
- data/ext/jstream.h +3 -3
- data/ext/jstream_t.h +74 -126
- data/ext/jtea.cpp +5 -5
- data/ext/jtea.h +6 -6
- data/ext/jtiger.h +9 -11
- data/ext/jtwofish.cpp +5 -5
- data/ext/jtwofish.h +6 -6
- data/ext/jwhirlpool.h +9 -11
- data/ext/utils.cpp +3 -3
- data/extras/parser_c.rb +102 -102
- data/test/ciphers_test.rb +24 -30
- data/test/data/ciphers/3desval.yml +13 -0
- data/test/data/ciphers/3wayval.yml +17 -0
- data/test/data/ciphers/arc4.yml +22 -0
- data/test/data/ciphers/blowfish.yml +9 -0
- data/test/data/ciphers/camellia.yml +21 -0
- data/test/data/ciphers/cast128v.yml +13 -0
- data/test/data/ciphers/cast256v.yml +13 -0
- data/test/data/ciphers/descert.yml +723 -0
- data/test/data/ciphers/diamond.yml +31 -0
- data/test/data/ciphers/gostval.yml +33 -0
- data/test/data/ciphers/ideaval.yml +45 -0
- data/test/data/ciphers/marsval.yml +37 -0
- data/test/data/ciphers/panamac.yml +11 -0
- data/test/data/ciphers/rc2val.yml +49 -0
- data/test/data/ciphers/rc5val.yml +26 -0
- data/test/data/ciphers/rc6val.yml +25 -0
- data/test/data/ciphers/rijndael.yml +37 -0
- data/test/data/ciphers/saferval.yml +77 -0
- data/test/data/ciphers/seal.yml +6 -0
- data/test/data/ciphers/serpentv.yml +37 -0
- data/test/data/ciphers/shacal2.yml +21 -0
- data/test/data/ciphers/sharkval.yml +29 -0
- data/test/data/ciphers/skipjack.yml +5 -0
- data/test/data/ciphers/squareva.yml +33 -0
- data/test/data/ciphers/twofishv.yml +37 -0
- data/test/data/digests/adler32.yml +19 -0
- data/test/data/digests/crc32.yml +25 -0
- data/test/data/digests/haval.yml +7 -0
- data/test/data/digests/havalcer.yml +1 -0
- data/test/data/digests/md2.yml +22 -0
- data/test/data/digests/md4.yml +22 -0
- data/test/data/digests/md5.yml +22 -0
- data/test/data/digests/panamah.yml +13 -0
- data/test/data/digests/ripemd.yml +97 -0
- data/test/data/digests/sha.yml +25 -0
- data/test/data/digests/sha3.yml +23 -0
- data/test/data/digests/tiger.yml +30 -0
- data/test/data/digests/whirlpool.yml +25 -0
- data/test/data/hmacs/hmac.yml +14 -0
- data/test/digests_test.rb +17 -23
- data/test/hmacs_test.rb +25 -31
- data/test/test_helper.rb +31 -37
- metadata +70 -82
- data/test/data/ciphers/3desval.dat +0 -7
- data/test/data/ciphers/3wayval.dat +0 -6
- data/test/data/ciphers/arc4.dat +0 -8
- data/test/data/ciphers/blowfish.dat +0 -5
- data/test/data/ciphers/camellia.dat +0 -7
- data/test/data/ciphers/cast128v.dat +0 -5
- data/test/data/ciphers/cast256v.dat +0 -5
- data/test/data/ciphers/descert.dat +0 -198
- data/test/data/ciphers/diamond.dat +0 -9
- data/test/data/ciphers/gostval.dat +0 -10
- data/test/data/ciphers/ideaval.dat +0 -13
- data/test/data/ciphers/marsval.dat +0 -11
- data/test/data/ciphers/panamac.dat +0 -7
- data/test/data/ciphers/rc2val.dat +0 -10
- data/test/data/ciphers/rc5val.dat +0 -7
- data/test/data/ciphers/rc6val.dat +0 -8
- data/test/data/ciphers/rijndael.dat +0 -11
- data/test/data/ciphers/saferval.dat +0 -27
- data/test/data/ciphers/seal.dat +0 -3
- data/test/data/ciphers/serpentv.dat +0 -11
- data/test/data/ciphers/shacal2.dat +0 -7
- data/test/data/ciphers/sharkval.dat +0 -9
- data/test/data/ciphers/skipjack.dat +0 -3
- data/test/data/ciphers/squareva.dat +0 -10
- data/test/data/ciphers/twofishv.dat +0 -11
- data/test/data/digests/adler32.dat +0 -8
- data/test/data/digests/crc32.dat +0 -10
- data/test/data/digests/haval.dat +0 -4
- data/test/data/digests/havalcer.dat +0 -23
- data/test/data/digests/md2.dat +0 -9
- data/test/data/digests/md4.dat +0 -9
- data/test/data/digests/md5.dat +0 -9
- data/test/data/digests/panamah.dat +0 -8
- data/test/data/digests/ripemd.dat +0 -43
- data/test/data/digests/sha.dat +0 -19
- data/test/data/digests/tiger.dat +0 -11
- data/test/data/digests/whirlpool.dat +0 -13
- data/test/data/hmacs/hmac.dat +0 -6
data/ext/jbase.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#ifndef __JBASE_H__
|
@@ -23,58 +23,52 @@ using namespace CryptoPP;
|
|
23
23
|
|
24
24
|
class JBase
|
25
25
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
string itsCiphertext;
|
73
|
-
string itsKey;
|
74
|
-
string itsIV;
|
75
|
-
|
76
|
-
unsigned int itsKeylength;
|
77
|
-
enum RNGEnum itsRNG;
|
26
|
+
public:
|
27
|
+
JBase();
|
28
|
+
virtual ~JBase() {};
|
29
|
+
|
30
|
+
string getPlaintext(const bool hex = false) const;
|
31
|
+
string getCiphertext(const bool hex = false) const;
|
32
|
+
string getKey(const bool hex = false) const;
|
33
|
+
unsigned int getKeylength() const;
|
34
|
+
|
35
|
+
void setPlaintext(const string plaintext, const bool hex = false);
|
36
|
+
void setCiphertext(const string ciphertext, const bool hex = false);
|
37
|
+
unsigned int setKey(const string key, bool hex = false);
|
38
|
+
unsigned int setKeylength(const unsigned int keylength);
|
39
|
+
|
40
|
+
string getRNGName() const;
|
41
|
+
static string getRNGName(const enum RNGEnum rng);
|
42
|
+
enum RNGEnum getRNG() const;
|
43
|
+
enum RNGEnum setRNG(const enum RNGEnum rng);
|
44
|
+
|
45
|
+
string getIV(bool hex = false) const;
|
46
|
+
void setIV(string iv, bool hex = false);
|
47
|
+
void setRandIV(const unsigned int size);
|
48
|
+
|
49
|
+
virtual unsigned int getDefaultKeylength() const = 0;
|
50
|
+
virtual unsigned int getMaxKeylength() const = 0;
|
51
|
+
virtual unsigned int getMinKeylength() const = 0;
|
52
|
+
virtual unsigned int getMultKeylength() const = 0;
|
53
|
+
virtual unsigned int getValidKeylength(const unsigned int keylength) const = 0;
|
54
|
+
virtual unsigned int getBlockSize() const = 0;
|
55
|
+
virtual enum CipherEnum getCipherType() const = 0;
|
56
|
+
virtual string getCipherName() const = 0;
|
57
|
+
|
58
|
+
virtual bool encrypt() = 0;
|
59
|
+
virtual bool decrypt() = 0;
|
60
|
+
|
61
|
+
virtual bool encryptRubyIO(VALUE* in, VALUE* out) = 0;
|
62
|
+
virtual bool decryptRubyIO(VALUE* in, VALUE* out) = 0;
|
63
|
+
|
64
|
+
protected:
|
65
|
+
string itsPlaintext;
|
66
|
+
string itsCiphertext;
|
67
|
+
string itsKey;
|
68
|
+
string itsIV;
|
69
|
+
|
70
|
+
unsigned int itsKeylength;
|
71
|
+
enum RNGEnum itsRNG;
|
78
72
|
};
|
79
73
|
|
80
74
|
#define getKeyHex() getKey(true)
|
data/ext/jbasiccipherinfo.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#ifndef __JBASICCIPHERINFO_H__
|
@@ -14,61 +14,61 @@
|
|
14
14
|
template <typename INFO, typename BASE>
|
15
15
|
class JBasicCipherInfo : public BASE
|
16
16
|
{
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
public:
|
18
|
+
unsigned int getValidKeylength(const unsigned int length) const;
|
19
|
+
unsigned int getDefaultKeylength() const;
|
20
|
+
unsigned int getMaxKeylength() const;
|
21
|
+
unsigned int getMinKeylength() const;
|
22
|
+
unsigned int getMultKeylength() const;
|
23
|
+
string getCipherName() const;
|
24
|
+
static string getStaticCipherName();
|
25
25
|
};
|
26
26
|
|
27
27
|
template <typename INFO, typename BASE>
|
28
28
|
unsigned int JBasicCipherInfo<INFO, BASE>::getValidKeylength(const unsigned int keylength) const
|
29
29
|
{
|
30
|
-
|
30
|
+
return INFO::StaticGetValidKeyLength(keylength);
|
31
31
|
}
|
32
32
|
|
33
33
|
template <typename INFO, typename BASE>
|
34
34
|
unsigned int JBasicCipherInfo<INFO, BASE>::getDefaultKeylength() const
|
35
35
|
{
|
36
|
-
|
36
|
+
return INFO::DEFAULT_KEYLENGTH;
|
37
37
|
}
|
38
38
|
|
39
39
|
template <typename INFO, typename BASE>
|
40
40
|
unsigned int JBasicCipherInfo<INFO, BASE>::getMaxKeylength() const
|
41
41
|
{
|
42
|
-
|
42
|
+
return INFO::MAX_KEYLENGTH;
|
43
43
|
}
|
44
44
|
|
45
45
|
template <typename INFO, typename BASE>
|
46
46
|
unsigned int JBasicCipherInfo<INFO, BASE>::getMinKeylength() const
|
47
47
|
{
|
48
|
-
|
48
|
+
return INFO::MIN_KEYLENGTH;
|
49
49
|
}
|
50
50
|
|
51
51
|
template <typename INFO, typename BASE>
|
52
52
|
unsigned int JBasicCipherInfo<INFO, BASE>::getMultKeylength() const
|
53
53
|
{
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
if (INFO::MIN_KEYLENGTH == INFO::MAX_KEYLENGTH) {
|
55
|
+
return 0;
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
return INFO::StaticGetValidKeyLength(INFO::MIN_KEYLENGTH + 1) - INFO::MIN_KEYLENGTH;
|
59
|
+
}
|
60
60
|
}
|
61
61
|
|
62
62
|
template <typename INFO, typename BASE>
|
63
63
|
string JBasicCipherInfo<INFO, BASE>::getCipherName() const
|
64
64
|
{
|
65
|
-
|
65
|
+
return INFO::StaticAlgorithmName();
|
66
66
|
}
|
67
67
|
|
68
68
|
template <typename INFO, typename BASE>
|
69
69
|
string JBasicCipherInfo<INFO, BASE>::getStaticCipherName()
|
70
70
|
{
|
71
|
-
|
71
|
+
return INFO::StaticAlgorithmName();
|
72
72
|
}
|
73
73
|
|
74
74
|
#endif
|
data/ext/jblowfish.cpp
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "jblowfish.h"
|
@@ -11,12 +11,12 @@
|
|
11
11
|
|
12
12
|
BlockCipher* JBlowfish::getEncryptionObject()
|
13
13
|
{
|
14
|
-
|
14
|
+
return new BlowfishEncryption((byte*) itsKey.data(), itsKeylength);
|
15
15
|
}
|
16
16
|
|
17
17
|
BlockCipher* JBlowfish::getDecryptionObject()
|
18
18
|
{
|
19
|
-
|
19
|
+
return new BlowfishDecryption((byte*) itsKey.data(), itsKeylength);
|
20
20
|
}
|
21
21
|
|
22
22
|
#endif
|
data/ext/jblowfish.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#ifndef __JBLOWFISH_H__
|
@@ -20,9 +20,9 @@
|
|
20
20
|
|
21
21
|
class JBlowfish : public JCipher_Template<Blowfish_Info, BLOWFISH_CIPHER>
|
22
22
|
{
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
protected:
|
24
|
+
BlockCipher* getEncryptionObject();
|
25
|
+
BlockCipher* getDecryptionObject();
|
26
26
|
};
|
27
27
|
|
28
28
|
#endif
|
data/ext/jcamellia.cpp
CHANGED
@@ -1,24 +1,22 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "jcamellia.h"
|
9
9
|
|
10
|
-
#ifdef WORD64_AVAILABLE
|
11
10
|
#if ENABLED_CAMELLIA_CIPHER
|
12
11
|
|
13
12
|
BlockCipher* JCamellia::getEncryptionObject()
|
14
13
|
{
|
15
|
-
|
14
|
+
return new CamelliaEncryption((byte*) itsKey.data(), itsKeylength);
|
16
15
|
}
|
17
16
|
|
18
17
|
BlockCipher* JCamellia::getDecryptionObject()
|
19
18
|
{
|
20
|
-
|
19
|
+
return new CamelliaDecryption((byte*) itsKey.data(), itsKeylength);
|
21
20
|
}
|
22
21
|
|
23
22
|
#endif
|
24
|
-
#endif
|
data/ext/jcamellia.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#ifndef __JCAMELLIA_H__
|
@@ -10,7 +10,6 @@
|
|
10
10
|
|
11
11
|
#include "jconfig.h"
|
12
12
|
|
13
|
-
#ifdef WORD64_AVAILABLE
|
14
13
|
#if ENABLED_CAMELLIA_CIPHER
|
15
14
|
|
16
15
|
#include "jcipher_t.h"
|
@@ -23,11 +22,10 @@ using namespace CryptoPP;
|
|
23
22
|
|
24
23
|
class JCamellia : public JCipher_Template<Camellia_Info, CAMELLIA_CIPHER>
|
25
24
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
29
28
|
};
|
30
29
|
|
31
30
|
#endif
|
32
31
|
#endif
|
33
|
-
#endif
|
data/ext/jcast128.cpp
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "jcast128.h"
|
@@ -11,12 +11,12 @@
|
|
11
11
|
|
12
12
|
BlockCipher* JCAST128::getEncryptionObject()
|
13
13
|
{
|
14
|
-
|
14
|
+
return new CAST128Encryption((byte*) itsKey.data(), itsKeylength);
|
15
15
|
}
|
16
16
|
|
17
17
|
BlockCipher* JCAST128::getDecryptionObject()
|
18
18
|
{
|
19
|
-
|
19
|
+
return new CAST128Decryption((byte*) itsKey.data(), itsKeylength);
|
20
20
|
}
|
21
21
|
|
22
22
|
#endif
|
data/ext/jcast128.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#ifndef __JCAST128_H__
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
22
22
|
|
23
23
|
class JCAST128 : public JCipher_Template<CAST128_Info, CAST128_CIPHER>
|
24
24
|
{
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
28
|
};
|
29
29
|
|
30
30
|
#endif
|
data/ext/jcast256.cpp
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "jcast256.h"
|
@@ -11,12 +11,12 @@
|
|
11
11
|
|
12
12
|
BlockCipher* JCAST256::getEncryptionObject()
|
13
13
|
{
|
14
|
-
|
14
|
+
return new CAST256Encryption((byte*) itsKey.data(), itsKeylength);
|
15
15
|
}
|
16
16
|
|
17
17
|
BlockCipher* JCAST256::getDecryptionObject()
|
18
18
|
{
|
19
|
-
|
19
|
+
return new CAST256Decryption((byte*) itsKey.data(), itsKeylength);
|
20
20
|
}
|
21
21
|
|
22
22
|
#endif
|
data/ext/jcast256.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#ifndef __JCAST256_H__
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
22
22
|
|
23
23
|
class JCAST256 : public JCipher_Template<CAST256_Info, CAST256_CIPHER>
|
24
24
|
{
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
28
|
};
|
29
29
|
|
30
30
|
#endif
|
data/ext/jcipher.cpp
CHANGED
@@ -1,112 +1,112 @@
|
|
1
1
|
|
2
2
|
/*
|
3
|
-
* Copyright (c) 2002-
|
4
|
-
* Crypto++ copyright (c) 1995-
|
5
|
-
* See
|
3
|
+
* Copyright (c) 2002-2014 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2013 Wei Dai
|
5
|
+
* See MIT-LICENSE for the extact license
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "jcipher.h"
|
9
9
|
|
10
10
|
JCipher::JCipher()
|
11
11
|
{
|
12
|
-
|
13
|
-
|
12
|
+
itsMode = ECB_MODE;
|
13
|
+
itsPadding = ZEROS_PADDING;
|
14
14
|
}
|
15
15
|
|
16
16
|
string JCipher::getModeName() const
|
17
17
|
{
|
18
|
-
|
18
|
+
return getModeName(itsMode);
|
19
19
|
}
|
20
20
|
|
21
21
|
string JCipher::getModeName(const enum ModeEnum mode)
|
22
22
|
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
switch (mode) {
|
24
|
+
case ECB_MODE:
|
25
|
+
return "ECB";
|
26
|
+
case CBC_MODE:
|
27
|
+
return "CBC";
|
28
|
+
case CBC_CTS_MODE:
|
29
|
+
return "CBC with CTS";
|
30
|
+
case CFB_MODE:
|
31
|
+
return "CFB";
|
32
|
+
case CTR_MODE:
|
33
|
+
return "CTR";
|
34
|
+
case OFB_MODE:
|
35
|
+
return "OFB";
|
36
|
+
}
|
37
|
+
|
38
|
+
return "Unknown";
|
39
39
|
}
|
40
40
|
|
41
41
|
enum ModeEnum JCipher::getMode() const
|
42
42
|
{
|
43
|
-
|
43
|
+
return itsMode;
|
44
44
|
}
|
45
45
|
|
46
46
|
void JCipher::setMode(const enum ModeEnum mode)
|
47
47
|
{
|
48
|
-
|
49
|
-
|
48
|
+
itsMode = mode;
|
49
|
+
itsPadding = DEFAULT_PADDING;
|
50
50
|
}
|
51
51
|
|
52
52
|
string JCipher::getPaddingName() const
|
53
53
|
{
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
if (itsPadding == DEFAULT_PADDING) {
|
55
|
+
if (itsMode == ECB_MODE || itsMode == CBC_MODE)
|
56
|
+
return "Default cipher padding (PKCS)";
|
57
|
+
else
|
58
|
+
return "Default cipher padding (none)";
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
return getPaddingName(itsPadding);
|
62
|
+
}
|
63
63
|
}
|
64
64
|
|
65
65
|
string JCipher::getPaddingName(const enum PaddingEnum padding)
|
66
66
|
{
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
67
|
+
switch (padding) {
|
68
|
+
case NO_PADDING:
|
69
|
+
return "None";
|
70
|
+
case ZEROS_PADDING:
|
71
|
+
return "Zeroes";
|
72
|
+
case PKCS_PADDING:
|
73
|
+
return "PKCS";
|
74
|
+
case ONE_AND_ZEROS_PADDING:
|
75
|
+
return "One and zeroes";
|
76
|
+
case DEFAULT_PADDING:
|
77
|
+
return "Default cipher padding";
|
78
|
+
}
|
79
|
+
|
80
|
+
return "Unknown";
|
81
81
|
}
|
82
82
|
|
83
83
|
enum PaddingEnum JCipher::getPadding() const
|
84
84
|
{
|
85
|
-
|
85
|
+
return itsPadding;
|
86
86
|
}
|
87
87
|
|
88
88
|
enum PaddingEnum JCipher::setPadding(const enum PaddingEnum padding)
|
89
89
|
{
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
90
|
+
if (padding == NO_PADDING && (itsMode == ECB_MODE || itsMode == CBC_MODE)) {
|
91
|
+
return itsPadding;
|
92
|
+
}
|
93
|
+
else if ((padding == PKCS_PADDING || padding == ONE_AND_ZEROS_PADDING) && (itsMode == CBC_CTS_MODE || itsMode == CTR_MODE || itsMode == OFB_MODE || itsMode == CFB_MODE)) {
|
94
|
+
return itsPadding;
|
95
|
+
}
|
96
|
+
else {
|
97
|
+
itsPadding = padding;
|
98
|
+
return itsPadding;
|
99
|
+
}
|
100
100
|
}
|
101
101
|
|
102
102
|
unsigned int JCipher::getRounds() const
|
103
103
|
{
|
104
|
-
|
104
|
+
return itsRounds;
|
105
105
|
}
|
106
106
|
|
107
107
|
unsigned int JCipher::setRounds(const unsigned int rounds)
|
108
108
|
{
|
109
|
-
|
109
|
+
itsRounds = getValidRounds(rounds);
|
110
110
|
|
111
|
-
|
111
|
+
return itsRounds;
|
112
112
|
}
|