cryptopp 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/jdes_ede2.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 "jdes_ede2.h"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
BlockCipher* JDES_EDE2::getEncryptionObject()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
return new DES_EDE2_Encryption((byte*) itsKey.data(), itsKeylength);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
BlockCipher* JDES_EDE2::getDecryptionObject()
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
return new DES_EDE2_Decryption((byte*) itsKey.data(), itsKeylength);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
#endif
|
data/ext/jdes_ede2.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 __JDES_EDE2_H__
|
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
|
22
22
|
|
|
23
23
|
class JDES_EDE2 : public JCipher_Template<DES_EDE2_Info, DES_EDE2_CIPHER>
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
protected:
|
|
26
|
+
BlockCipher* getEncryptionObject();
|
|
27
|
+
BlockCipher* getDecryptionObject();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
#endif
|
data/ext/jdes_ede3.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 "jdes_ede3.h"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
BlockCipher* JDES_EDE3::getEncryptionObject()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
return new DES_EDE3_Encryption((byte*) itsKey.data(), itsKeylength);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
BlockCipher* JDES_EDE3::getDecryptionObject()
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
return new DES_EDE3_Decryption((byte*) itsKey.data(), itsKeylength);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
#endif
|
data/ext/jdes_ede3.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 __JDES_EDE3_H__
|
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
|
22
22
|
|
|
23
23
|
class JDES_EDE3 : public JCipher_Template<DES_EDE3_Info, DES_EDE3_CIPHER>
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
protected:
|
|
26
|
+
BlockCipher* getEncryptionObject();
|
|
27
|
+
BlockCipher* getDecryptionObject();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
#endif
|
data/ext/jdes_xex3.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 "jdes_xex3.h"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
BlockCipher* JDES_XEX3::getEncryptionObject()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
return new DES_XEX3_Encryption((byte*) itsKey.data(), itsKeylength);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
BlockCipher* JDES_XEX3::getDecryptionObject()
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
return new DES_XEX3_Decryption((byte*) itsKey.data(), itsKeylength);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
#endif
|
data/ext/jdes_xex3.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 __JDES_XEX3_H__
|
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
|
22
22
|
|
|
23
23
|
class JDES_XEX3 : public JCipher_Template<DES_XEX3_Info, DES_XEX3_CIPHER>
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
protected:
|
|
26
|
+
BlockCipher* getEncryptionObject();
|
|
27
|
+
BlockCipher* getDecryptionObject();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
#endif
|
data/ext/jdiamond2.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 "jdiamond2.h"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
BlockCipher* JDiamond2::getEncryptionObject()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
return new Diamond2Encryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
BlockCipher* JDiamond2::getDecryptionObject()
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
return new Diamond2Decryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
#endif
|
data/ext/jdiamond2.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 __JDIAMOND2_H__
|
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
|
22
22
|
|
|
23
23
|
class JDiamond2 : public JCipher_Template<Diamond2_Info, DIAMOND2_CIPHER, 10, 1, INT_MAX>
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
protected:
|
|
26
|
+
BlockCipher* getEncryptionObject();
|
|
27
|
+
BlockCipher* getDecryptionObject();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
#endif
|
data/ext/jdiamond2lite.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 "jdiamond2lite.h"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
BlockCipher* JDiamond2Lite::getEncryptionObject()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
return new Diamond2LiteEncryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
BlockCipher* JDiamond2Lite::getDecryptionObject()
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
return new Diamond2LiteDecryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
#endif
|
data/ext/jdiamond2lite.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 __JDIAMOND2LITE_H__
|
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
|
22
22
|
|
|
23
23
|
class JDiamond2Lite : public JCipher_Template<Diamond2Lite_Info, DIAMOND2_LITE_CIPHER, 8, 1, INT_MAX>
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
protected:
|
|
26
|
+
BlockCipher* getEncryptionObject();
|
|
27
|
+
BlockCipher* getDecryptionObject();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
#endif
|
data/ext/jexception.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 __JEXCEPTION_H__
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
class JException : public CryptoPP::Exception
|
|
15
15
|
{
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
public:
|
|
17
|
+
explicit JException(const std::string& w) : CryptoPP::Exception(CryptoPP::Exception::OTHER_ERROR, w) {};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
#endif
|
data/ext/jgost.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 "jgost.h"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
BlockCipher* JGOST::getEncryptionObject()
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
return new GOSTEncryption((byte*) itsKey.data(), itsKeylength);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
BlockCipher* JGOST::getDecryptionObject()
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
return new GOSTDecryption((byte*) itsKey.data(), itsKeylength);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
#endif
|
data/ext/jgost.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 __JGOST_H__
|
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
|
22
22
|
|
|
23
23
|
class JGOST : public JCipher_Template<GOST_Info, GOST_CIPHER>
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
protected:
|
|
26
|
+
BlockCipher* getEncryptionObject();
|
|
27
|
+
BlockCipher* getDecryptionObject();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
#endif
|
data/ext/jhash.cpp
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
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 "jhash.h"
|
|
9
9
|
|
|
10
10
|
JHash::JHash(string plaintext, bool hex)
|
|
11
11
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (hex) {
|
|
13
|
+
itsPlaintext = hex2bin(plaintext);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
itsPlaintext = plaintext;
|
|
17
|
+
}
|
|
18
|
+
itsHashModule = NULL;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
JHash::~JHash()
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
if (itsHashModule != NULL) {
|
|
24
|
+
delete itsHashModule;
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
string JHash::getPlaintext(bool hex) const
|
|
29
29
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
if (hex) {
|
|
31
|
+
return bin2hex(itsPlaintext);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return itsPlaintext;
|
|
35
|
+
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
string JHash::getHashtext(bool hex) const
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
if (hex) {
|
|
41
|
+
return bin2hex(itsHashtext);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return itsHashtext;
|
|
45
|
+
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
unsigned int JHash::getDigestSize() const
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
if (itsHashModule != NULL) {
|
|
51
|
+
return itsHashModule->DigestSize() * 2;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
void JHash::setPlaintext(const string plaintext, bool hex)
|
|
59
59
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
if (hex) {
|
|
61
|
+
hex2bin(plaintext);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
itsPlaintext = plaintext;
|
|
65
|
+
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
void JHash::setHashtext(const string hashtext, bool hex)
|
|
69
69
|
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
if (hex) {
|
|
71
|
+
itsHashtext = hex2bin(hashtext);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
itsHashtext = hashtext;
|
|
75
|
+
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
void JHash::updatePlaintext(const string plaintext, bool hex)
|
|
79
79
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
if (hex) {
|
|
81
|
+
itsPlaintext += hex2bin(plaintext);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
itsPlaintext += plaintext;
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
void JHash::clear()
|
|
89
89
|
{
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
itsPlaintext.erase();
|
|
91
|
+
itsHashtext.erase();
|
|
92
92
|
}
|