cryptopp 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/MIT-LICENSE +22 -0
- data/README +7 -0
- data/Rakefile +42 -0
- data/cryptopp.gemspec +199 -0
- data/ext/.gitignore +5 -0
- data/ext/Rakefile +16 -0
- data/ext/ciphers.cpp +1402 -0
- data/ext/cryptopp.cpp +285 -0
- data/ext/cryptopp_ruby_api.h +139 -0
- data/ext/defs/block_modes.def +10 -0
- data/ext/defs/checksums.def +10 -0
- data/ext/defs/ciphers.def +136 -0
- data/ext/defs/hashes.def +78 -0
- data/ext/defs/hmacs.def +54 -0
- data/ext/defs/paddings.def +9 -0
- data/ext/defs/rngs.def +7 -0
- data/ext/digests.cpp +1120 -0
- data/ext/extconf.rb +39 -0
- data/ext/j3way.cpp +22 -0
- data/ext/j3way.h +29 -0
- data/ext/jadler32.h +32 -0
- data/ext/jaes.cpp +22 -0
- data/ext/jaes.h +31 -0
- data/ext/jarc4.cpp +22 -0
- data/ext/jarc4.h +37 -0
- data/ext/jbase.cpp +172 -0
- data/ext/jbase.h +92 -0
- data/ext/jbasiccipherinfo.h +74 -0
- data/ext/jblowfish.cpp +22 -0
- data/ext/jblowfish.h +29 -0
- data/ext/jcamellia.cpp +24 -0
- data/ext/jcamellia.h +33 -0
- data/ext/jcast128.cpp +22 -0
- data/ext/jcast128.h +31 -0
- data/ext/jcast256.cpp +22 -0
- data/ext/jcast256.h +31 -0
- data/ext/jcipher.cpp +112 -0
- data/ext/jcipher.h +42 -0
- data/ext/jcipher_t.h +469 -0
- data/ext/jconfig.h +127 -0
- data/ext/jconstants.h +189 -0
- data/ext/jcrc32.h +32 -0
- data/ext/jdes.cpp +22 -0
- data/ext/jdes.h +31 -0
- data/ext/jdes_ede2.cpp +22 -0
- data/ext/jdes_ede2.h +31 -0
- data/ext/jdes_ede3.cpp +22 -0
- data/ext/jdes_ede3.h +31 -0
- data/ext/jdes_xex3.cpp +22 -0
- data/ext/jdes_xex3.h +31 -0
- data/ext/jdiamond2.cpp +22 -0
- data/ext/jdiamond2.h +31 -0
- data/ext/jdiamond2lite.cpp +22 -0
- data/ext/jdiamond2lite.h +31 -0
- data/ext/jexception.h +20 -0
- data/ext/jgost.cpp +22 -0
- data/ext/jgost.h +31 -0
- data/ext/jhash.cpp +92 -0
- data/ext/jhash.h +54 -0
- data/ext/jhash_t.h +121 -0
- data/ext/jhaval.h +64 -0
- data/ext/jhelpers.cpp +90 -0
- data/ext/jhelpers.h +38 -0
- data/ext/jhmac.cpp +44 -0
- data/ext/jhmac.h +34 -0
- data/ext/jhmac_t.h +125 -0
- data/ext/jidea.cpp +22 -0
- data/ext/jidea.h +31 -0
- data/ext/jmarc4.cpp +22 -0
- data/ext/jmarc4.h +37 -0
- data/ext/jmars.cpp +22 -0
- data/ext/jmars.h +31 -0
- data/ext/jmd2.h +56 -0
- data/ext/jmd4.h +56 -0
- data/ext/jmd5.h +56 -0
- data/ext/jpanamacipher.cpp +32 -0
- data/ext/jpanamacipher.h +46 -0
- data/ext/jpanamahash.h +44 -0
- data/ext/jrc2.cpp +44 -0
- data/ext/jrc2.h +39 -0
- data/ext/jrc5.cpp +22 -0
- data/ext/jrc5.h +31 -0
- data/ext/jrc6.cpp +22 -0
- data/ext/jrc6.h +31 -0
- data/ext/jripemd160.h +113 -0
- data/ext/jsafer.cpp +32 -0
- data/ext/jsafer.h +42 -0
- data/ext/jseal.cpp +32 -0
- data/ext/jseal.h +42 -0
- data/ext/jserpent.cpp +22 -0
- data/ext/jserpent.h +31 -0
- data/ext/jsha.h +122 -0
- data/ext/jshacal2.cpp +22 -0
- data/ext/jshacal2.h +31 -0
- data/ext/jshark.cpp +24 -0
- data/ext/jshark.h +33 -0
- data/ext/jsink.cpp +90 -0
- data/ext/jsink.h +154 -0
- data/ext/jskipjack.cpp +22 -0
- data/ext/jskipjack.h +31 -0
- data/ext/jsquare.cpp +22 -0
- data/ext/jsquare.h +31 -0
- data/ext/jstream.cpp +8 -0
- data/ext/jstream.h +20 -0
- data/ext/jstream_t.h +175 -0
- data/ext/jtea.cpp +22 -0
- data/ext/jtea.h +31 -0
- data/ext/jtiger.h +52 -0
- data/ext/jtwofish.cpp +22 -0
- data/ext/jtwofish.h +31 -0
- data/ext/jwhirlpool.h +52 -0
- data/ext/utils.cpp +8 -0
- data/extras/parser_c.rb +114 -0
- data/test/ciphers_test.rb +37 -0
- data/test/data/ciphers/3desval.dat +7 -0
- data/test/data/ciphers/3wayval.dat +6 -0
- data/test/data/ciphers/arc4.dat +8 -0
- data/test/data/ciphers/blowfish.dat +5 -0
- data/test/data/ciphers/camellia.dat +7 -0
- data/test/data/ciphers/cast128v.dat +5 -0
- data/test/data/ciphers/cast256v.dat +5 -0
- data/test/data/ciphers/descert.dat +198 -0
- data/test/data/ciphers/diamond.dat +9 -0
- data/test/data/ciphers/gostval.dat +10 -0
- data/test/data/ciphers/ideaval.dat +13 -0
- data/test/data/ciphers/marsval.dat +11 -0
- data/test/data/ciphers/panamac.dat +7 -0
- data/test/data/ciphers/rc2val.dat +10 -0
- data/test/data/ciphers/rc5val.dat +7 -0
- data/test/data/ciphers/rc6val.dat +8 -0
- data/test/data/ciphers/rijndael.dat +11 -0
- data/test/data/ciphers/saferval.dat +27 -0
- data/test/data/ciphers/seal.dat +3 -0
- data/test/data/ciphers/serpentv.dat +11 -0
- data/test/data/ciphers/shacal2.dat +7 -0
- data/test/data/ciphers/sharkval.dat +9 -0
- data/test/data/ciphers/skipjack.dat +3 -0
- data/test/data/ciphers/squareva.dat +10 -0
- data/test/data/ciphers/twofishv.dat +11 -0
- data/test/data/digests/adler32.dat +8 -0
- data/test/data/digests/crc32.dat +10 -0
- data/test/data/digests/haval.dat +4 -0
- data/test/data/digests/havalcer.dat +23 -0
- data/test/data/digests/md2.dat +9 -0
- data/test/data/digests/md4.dat +9 -0
- data/test/data/digests/md5.dat +9 -0
- data/test/data/digests/panamah.dat +8 -0
- data/test/data/digests/ripemd.dat +43 -0
- data/test/data/digests/sha.dat +19 -0
- data/test/data/digests/tiger.dat +11 -0
- data/test/data/digests/whirlpool.dat +13 -0
- data/test/data/hmacs/hmac.dat +6 -0
- data/test/digests_test.rb +29 -0
- data/test/hmacs_test.rb +38 -0
- data/test/test_helper.rb +42 -0
- metadata +220 -0
data/ext/jdes_ede3.cpp
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "jdes_ede3.h"
|
9
|
+
|
10
|
+
#if ENABLED_DES_EDE3_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JDES_EDE3::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new DES_EDE3_Encryption((byte*) itsKey.data(), itsKeylength);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JDES_EDE3::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new DES_EDE3_Decryption((byte*) itsKey.data(), itsKeylength);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jdes_ede3.h
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JDES_EDE3_H__
|
9
|
+
#define __JDES_EDE3_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_DES_EDE3_CIPHER
|
14
|
+
|
15
|
+
#include "jcipher_t.h"
|
16
|
+
|
17
|
+
// Crypto++ headers...
|
18
|
+
|
19
|
+
#include "des.h"
|
20
|
+
|
21
|
+
using namespace CryptoPP;
|
22
|
+
|
23
|
+
class JDES_EDE3 : public JCipher_Template<DES_EDE3_Info, DES_EDE3_CIPHER>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|
data/ext/jdes_xex3.cpp
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "jdes_xex3.h"
|
9
|
+
|
10
|
+
#if ENABLED_DES_XEX3_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JDES_XEX3::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new DES_XEX3_Encryption((byte*) itsKey.data(), itsKeylength);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JDES_XEX3::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new DES_XEX3_Decryption((byte*) itsKey.data(), itsKeylength);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jdes_xex3.h
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JDES_XEX3_H__
|
9
|
+
#define __JDES_XEX3_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_DES_XEX3_CIPHER
|
14
|
+
|
15
|
+
#include "jcipher_t.h"
|
16
|
+
|
17
|
+
// Crypto++ headers...
|
18
|
+
|
19
|
+
#include "des.h"
|
20
|
+
|
21
|
+
using namespace CryptoPP;
|
22
|
+
|
23
|
+
class JDES_XEX3 : public JCipher_Template<DES_XEX3_Info, DES_XEX3_CIPHER>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|
data/ext/jdiamond2.cpp
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "jdiamond2.h"
|
9
|
+
|
10
|
+
#if ENABLED_DIAMOND2_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JDiamond2::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new Diamond2Encryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JDiamond2::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new Diamond2Decryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jdiamond2.h
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JDIAMOND2_H__
|
9
|
+
#define __JDIAMOND2_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_DIAMOND2_CIPHER
|
14
|
+
|
15
|
+
#include "jcipher_t.h"
|
16
|
+
|
17
|
+
// Crypto++ headers...
|
18
|
+
|
19
|
+
#include "diamond.h"
|
20
|
+
|
21
|
+
using namespace CryptoPP;
|
22
|
+
|
23
|
+
class JDiamond2 : public JCipher_Template<Diamond2_Info, DIAMOND2_CIPHER, 10, 1, INT_MAX>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "jdiamond2lite.h"
|
9
|
+
|
10
|
+
#if ENABLED_DIAMOND2_LITE_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JDiamond2Lite::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new Diamond2LiteEncryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JDiamond2Lite::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new Diamond2LiteDecryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jdiamond2lite.h
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JDIAMOND2LITE_H__
|
9
|
+
#define __JDIAMOND2LITE_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_DIAMOND2_CIPHER
|
14
|
+
|
15
|
+
#include "jcipher_t.h"
|
16
|
+
|
17
|
+
// Crypto++ headers...
|
18
|
+
|
19
|
+
#include "diamond.h"
|
20
|
+
|
21
|
+
using namespace CryptoPP;
|
22
|
+
|
23
|
+
class JDiamond2Lite : public JCipher_Template<Diamond2Lite_Info, DIAMOND2_LITE_CIPHER, 8, 1, INT_MAX>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|
data/ext/jexception.h
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JEXCEPTION_H__
|
9
|
+
#define __JEXCEPTION_H__
|
10
|
+
|
11
|
+
#include <string>
|
12
|
+
#include "cryptlib.h"
|
13
|
+
|
14
|
+
class JException : public CryptoPP::Exception
|
15
|
+
{
|
16
|
+
public:
|
17
|
+
explicit JException(const std::string& w) : CryptoPP::Exception(CryptoPP::Exception::OTHER_ERROR, w) {};
|
18
|
+
};
|
19
|
+
|
20
|
+
#endif
|
data/ext/jgost.cpp
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "jgost.h"
|
9
|
+
|
10
|
+
#if ENABLED_GOST_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JGOST::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new GOSTEncryption((byte*) itsKey.data(), itsKeylength);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JGOST::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new GOSTDecryption((byte*) itsKey.data(), itsKeylength);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jgost.h
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JGOST_H__
|
9
|
+
#define __JGOST_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_GOST_CIPHER
|
14
|
+
|
15
|
+
#include "jcipher_t.h"
|
16
|
+
|
17
|
+
// Crypto++ headers...
|
18
|
+
|
19
|
+
#include "gost.h"
|
20
|
+
|
21
|
+
using namespace CryptoPP;
|
22
|
+
|
23
|
+
class JGOST : public JCipher_Template<GOST_Info, GOST_CIPHER>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|
data/ext/jhash.cpp
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "jhash.h"
|
9
|
+
|
10
|
+
JHash::JHash(string plaintext, bool hex)
|
11
|
+
{
|
12
|
+
if (hex) {
|
13
|
+
itsPlaintext = hex2bin(plaintext);
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
itsPlaintext = plaintext;
|
17
|
+
}
|
18
|
+
itsHashModule = NULL;
|
19
|
+
}
|
20
|
+
|
21
|
+
JHash::~JHash()
|
22
|
+
{
|
23
|
+
if (itsHashModule != NULL) {
|
24
|
+
delete itsHashModule;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
string JHash::getPlaintext(bool hex) const
|
29
|
+
{
|
30
|
+
if (hex) {
|
31
|
+
return bin2hex(itsPlaintext);
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
return itsPlaintext;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
string JHash::getHashtext(bool hex) const
|
39
|
+
{
|
40
|
+
if (hex) {
|
41
|
+
return bin2hex(itsHashtext);
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
return itsHashtext;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
unsigned int JHash::getDigestSize() const
|
49
|
+
{
|
50
|
+
if (itsHashModule != NULL) {
|
51
|
+
return itsHashModule->DigestSize() * 2;
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
return 0;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
void JHash::setPlaintext(const string plaintext, bool hex)
|
59
|
+
{
|
60
|
+
if (hex) {
|
61
|
+
hex2bin(plaintext);
|
62
|
+
}
|
63
|
+
else {
|
64
|
+
itsPlaintext = plaintext;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
void JHash::setHashtext(const string hashtext, bool hex)
|
69
|
+
{
|
70
|
+
if (hex) {
|
71
|
+
itsHashtext = hex2bin(hashtext);
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
itsHashtext = hashtext;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
void JHash::updatePlaintext(const string plaintext, bool hex)
|
79
|
+
{
|
80
|
+
if (hex) {
|
81
|
+
itsPlaintext += hex2bin(plaintext);
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
itsPlaintext += plaintext;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
void JHash::clear()
|
89
|
+
{
|
90
|
+
itsPlaintext.erase();
|
91
|
+
itsHashtext.erase();
|
92
|
+
}
|
data/ext/jhash.h
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2002-2010 J Smith <dark.panda@gmail.com>
|
4
|
+
* Crypto++ copyright (c) 1995-2010 Wei Dai
|
5
|
+
* See COPYING for the extact license
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JHASH_H__
|
9
|
+
#define __JHASH_H__
|
10
|
+
|
11
|
+
#include "jsink.h"
|
12
|
+
#include "jhelpers.h"
|
13
|
+
#include "jconstants.h"
|
14
|
+
|
15
|
+
|
16
|
+
using namespace CryptoPP;
|
17
|
+
|
18
|
+
class JHash
|
19
|
+
{
|
20
|
+
public:
|
21
|
+
JHash(string plaintext = "", bool hex = false);
|
22
|
+
virtual ~JHash();
|
23
|
+
|
24
|
+
string getPlaintext(bool hex = false) const;
|
25
|
+
string getHashtext(bool hex = true) const;
|
26
|
+
unsigned int getDigestSize() const;
|
27
|
+
virtual enum HashEnum getHashType() const = 0;
|
28
|
+
|
29
|
+
void setPlaintext(string plaintext, bool hex = false);
|
30
|
+
void setHashtext(string hashtext, bool hex = true);
|
31
|
+
|
32
|
+
void updatePlaintext(string plaintext, bool hex = false);
|
33
|
+
|
34
|
+
void clear();
|
35
|
+
|
36
|
+
virtual bool hash() = 0;
|
37
|
+
virtual bool validate() = 0;
|
38
|
+
virtual bool validate(string plaintext, string hashtext) = 0;
|
39
|
+
|
40
|
+
virtual string hashRubyIO(VALUE* in, bool hex = true) = 0;
|
41
|
+
|
42
|
+
/* This is deprecated. It was used before using php_streams. Use it
|
43
|
+
if you're using this code in something other than the cryptopp PHP
|
44
|
+
extension... */
|
45
|
+
//virtual string hashFile(const string filename, bool hex = true) = 0;
|
46
|
+
|
47
|
+
protected:
|
48
|
+
HashTransformation* itsHashModule;
|
49
|
+
|
50
|
+
string itsPlaintext;
|
51
|
+
string itsHashtext;
|
52
|
+
};
|
53
|
+
|
54
|
+
#endif
|