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/jsafer.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 "jsafer.h"
|
@@ -10,23 +10,23 @@
|
|
10
10
|
#if ENABLED_SAFER_K_CIPHER
|
11
11
|
BlockCipher* JSAFER_K::getEncryptionObject()
|
12
12
|
{
|
13
|
-
|
13
|
+
return new SAFER_K_Encryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
14
14
|
}
|
15
15
|
|
16
16
|
BlockCipher* JSAFER_K::getDecryptionObject()
|
17
17
|
{
|
18
|
-
|
18
|
+
return new SAFER_K_Decryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
19
19
|
}
|
20
20
|
#endif
|
21
21
|
|
22
22
|
#if ENABLED_SAFER_SK_CIPHER
|
23
23
|
BlockCipher* JSAFER_SK::getEncryptionObject()
|
24
24
|
{
|
25
|
-
|
25
|
+
return new SAFER_SK_Encryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
26
26
|
}
|
27
27
|
|
28
28
|
BlockCipher* JSAFER_SK::getDecryptionObject()
|
29
29
|
{
|
30
|
-
|
30
|
+
return new SAFER_SK_Decryption((byte*) itsKey.data(), itsKeylength, itsRounds);
|
31
31
|
}
|
32
32
|
#endif
|
data/ext/jsafer.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 __JSAFER_H__
|
@@ -23,18 +23,18 @@ using namespace CryptoPP;
|
|
23
23
|
#if ENABLED_SAFER_K_CIPHER
|
24
24
|
class JSAFER_K : public JCipher_Template<SAFER_K_Info, SAFER_K_CIPHER, 6, 1, 13>
|
25
25
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
protected:
|
27
|
+
BlockCipher* getEncryptionObject();
|
28
|
+
BlockCipher* getDecryptionObject();
|
29
29
|
};
|
30
30
|
#endif
|
31
31
|
|
32
32
|
#if ENABLED_SAFER_SK_CIPHER
|
33
33
|
class JSAFER_SK : public JCipher_Template<SAFER_SK_Info, SAFER_SK_CIPHER, 6, 1, 13>
|
34
34
|
{
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
protected:
|
36
|
+
BlockCipher* getEncryptionObject();
|
37
|
+
BlockCipher* getDecryptionObject();
|
38
38
|
};
|
39
39
|
#endif
|
40
40
|
|
data/ext/jseal.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 "jseal.h"
|
@@ -10,23 +10,23 @@
|
|
10
10
|
#if ENABLED_SEAL_LITTLE_ENDIAN_CIPHER
|
11
11
|
SymmetricCipher* JSEAL_LE::getEncryptionObject()
|
12
12
|
{
|
13
|
-
|
13
|
+
return new SEAL<LittleEndian>::Encryption((byte*) itsKey.data(), itsKeylength, (byte*) itsIV.data());
|
14
14
|
}
|
15
15
|
|
16
16
|
SymmetricCipher* JSEAL_LE::getDecryptionObject()
|
17
17
|
{
|
18
|
-
|
18
|
+
return getEncryptionObject();
|
19
19
|
}
|
20
20
|
#endif
|
21
21
|
|
22
22
|
#if ENABLED_SEAL_BIG_ENDIAN_CIPHER
|
23
23
|
SymmetricCipher* JSEAL_BE::getEncryptionObject()
|
24
24
|
{
|
25
|
-
|
25
|
+
return new SEAL<BigEndian>::Encryption((byte*) itsKey.data(), itsKeylength, (byte*) itsIV.data());
|
26
26
|
}
|
27
27
|
|
28
28
|
SymmetricCipher* JSEAL_BE::getDecryptionObject()
|
29
29
|
{
|
30
|
-
|
30
|
+
return getEncryptionObject();
|
31
31
|
}
|
32
32
|
#endif
|
data/ext/jseal.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 __JSEAL_H__
|
@@ -23,18 +23,18 @@ using namespace CryptoPP;
|
|
23
23
|
#if ENABLED_SEAL_LITTLE_ENDIAN_CIPHER
|
24
24
|
class JSEAL_LE : public JStream_Template<SEAL_Info<LittleEndian>, SEAL_LITTLE_ENDIAN_CIPHER>
|
25
25
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
protected:
|
27
|
+
SymmetricCipher* getEncryptionObject();
|
28
|
+
SymmetricCipher* getDecryptionObject();
|
29
29
|
};
|
30
30
|
#endif
|
31
31
|
|
32
32
|
#if ENABLED_SEAL_BIG_ENDIAN_CIPHER
|
33
33
|
class JSEAL_BE : public JStream_Template<SEAL_Info<BigEndian>, SEAL_BIG_ENDIAN_CIPHER>
|
34
34
|
{
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
protected:
|
36
|
+
SymmetricCipher* getEncryptionObject();
|
37
|
+
SymmetricCipher* getDecryptionObject();
|
38
38
|
};
|
39
39
|
#endif
|
40
40
|
|
data/ext/jserpent.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 "jserpent.h"
|
@@ -11,12 +11,12 @@
|
|
11
11
|
|
12
12
|
BlockCipher* JSerpent::getEncryptionObject()
|
13
13
|
{
|
14
|
-
|
14
|
+
return new SerpentEncryption((byte*) itsKey.data(), itsKeylength);
|
15
15
|
}
|
16
16
|
|
17
17
|
BlockCipher* JSerpent::getDecryptionObject()
|
18
18
|
{
|
19
|
-
|
19
|
+
return new SerpentDecryption((byte*) itsKey.data(), itsKeylength);
|
20
20
|
}
|
21
21
|
|
22
22
|
#endif
|
data/ext/jserpent.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 __JSERPENT_H__
|
@@ -22,9 +22,9 @@ using namespace CryptoPP;
|
|
22
22
|
|
23
23
|
class JSerpent : public JCipher_Template<Serpent_Info, SERPENT_CIPHER>
|
24
24
|
{
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
28
|
};
|
29
29
|
|
30
30
|
#endif
|
data/ext/jsha.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 __JSHA_H__
|
@@ -10,14 +10,21 @@
|
|
10
10
|
|
11
11
|
#include "jconfig.h"
|
12
12
|
|
13
|
-
#
|
14
|
-
|
13
|
+
#define ANY_SHA_HASH_ENABLED \
|
14
|
+
ENABLED_SHA1_HASH || ENABLED_SHA_256_HASH || \
|
15
|
+
ENABLED_SHA_384_HASH || ENABLED_SHA_512_HASH
|
15
16
|
|
16
|
-
#
|
17
|
+
#define ANY_SHA_HMAC_ENABLED \
|
18
|
+
ENABLED_SHA1_HMAC || ENABLED_SHA_256_HMAC || \
|
19
|
+
ENABLED_SHA_384_HMAC || ENABLED_SHA_512_HMAC
|
20
|
+
|
21
|
+
#if ANY_SHA_HASH_ENABLED || ANY_SHA_HMAC_ENABLED
|
22
|
+
|
23
|
+
#if ANY_SHA_HASH_ENABLED
|
17
24
|
#include "jhash_t.h"
|
18
25
|
#endif
|
19
26
|
|
20
|
-
#if
|
27
|
+
#if ANY_SHA_HMAC_ENABLED
|
21
28
|
#include "jhmac_t.h"
|
22
29
|
#endif
|
23
30
|
|
@@ -31,10 +38,10 @@ using namespace CryptoPP;
|
|
31
38
|
#if ENABLED_SHA1_HASH
|
32
39
|
class JSHA1 : public JHash_Template<SHA1, SHA1_HASH>
|
33
40
|
{
|
34
|
-
|
35
|
-
|
41
|
+
public:
|
42
|
+
JSHA1(string plaintext = "") : JHash_Template<SHA1, SHA1_HASH>(plaintext) { }
|
36
43
|
|
37
|
-
|
44
|
+
static string getHashName() { return "SHA1"; }
|
38
45
|
};
|
39
46
|
|
40
47
|
typedef JSHA1 JSHA;
|
@@ -43,31 +50,30 @@ typedef JSHA1 JSHA;
|
|
43
50
|
#if ENABLED_SHA256_HASH
|
44
51
|
class JSHA256 : public JHash_Template<SHA256, SHA256_HASH>
|
45
52
|
{
|
46
|
-
|
47
|
-
|
53
|
+
public:
|
54
|
+
JSHA256(string plaintext = "") : JHash_Template<SHA256, SHA256_HASH>(plaintext) { }
|
48
55
|
|
49
|
-
|
56
|
+
static string getHashName() { return "SHA-256"; }
|
50
57
|
};
|
51
58
|
#endif
|
52
59
|
|
53
|
-
#ifdef WORD64_AVAILABLE
|
54
60
|
#if ENABLED_SHA384_HASH
|
55
61
|
class JSHA384 : public JHash_Template<SHA384, SHA384_HASH>
|
56
62
|
{
|
57
|
-
|
58
|
-
|
63
|
+
public:
|
64
|
+
JSHA384(string plaintext = "") : JHash_Template<SHA384, SHA384_HASH>(plaintext) { }
|
59
65
|
|
60
|
-
|
66
|
+
static string getHashName() { return "SHA-384"; }
|
61
67
|
};
|
62
68
|
#endif
|
63
69
|
|
64
70
|
#if ENABLED_SHA512_HASH
|
65
71
|
class JSHA512 : public JHash_Template<SHA512, SHA512_HASH>
|
66
72
|
{
|
67
|
-
|
68
|
-
|
73
|
+
public:
|
74
|
+
JSHA512(string plaintext = "") : JHash_Template<SHA512, SHA512_HASH>(plaintext) { }
|
69
75
|
|
70
|
-
|
76
|
+
static string getHashName() { return "SHA-512"; }
|
71
77
|
};
|
72
78
|
#endif
|
73
79
|
#endif
|
@@ -76,10 +82,10 @@ class JSHA512 : public JHash_Template<SHA512, SHA512_HASH>
|
|
76
82
|
#if ENABLED_SHA1_HMAC
|
77
83
|
class JSHA1_HMAC : public JHMAC_Template<SHA1, SHA1_HMAC>
|
78
84
|
{
|
79
|
-
|
80
|
-
|
85
|
+
public:
|
86
|
+
JSHA1_HMAC(string plaintext = "") : JHMAC_Template<SHA1, SHA1_HMAC>(plaintext) { }
|
81
87
|
|
82
|
-
|
88
|
+
static string getHashName() { return "SHA1-HMAC"; }
|
83
89
|
};
|
84
90
|
|
85
91
|
typedef JSHA1_HMAC JSHA_HMAC;
|
@@ -88,35 +94,30 @@ typedef JSHA1_HMAC JSHA_HMAC;
|
|
88
94
|
#if ENABLED_SHA256_HMAC
|
89
95
|
class JSHA256_HMAC : public JHMAC_Template<SHA256, SHA256_HMAC>
|
90
96
|
{
|
91
|
-
|
92
|
-
|
97
|
+
public:
|
98
|
+
JSHA256_HMAC(string plaintext = "") : JHMAC_Template<SHA256, SHA256_HMAC>(plaintext) { }
|
93
99
|
|
94
|
-
|
100
|
+
static string getHashName() { return "SHA-256-HMAC"; }
|
95
101
|
};
|
96
102
|
#endif
|
97
103
|
|
98
|
-
#ifdef WORD64_AVAILABLE
|
99
104
|
#if ENABLED_SHA384_HMAC
|
100
105
|
class JSHA384_HMAC : public JHMAC_Template<SHA384, SHA384_HMAC>
|
101
106
|
{
|
102
|
-
|
103
|
-
|
107
|
+
public:
|
108
|
+
JSHA384_HMAC(string plaintext = "") : JHMAC_Template<SHA384, SHA384_HMAC>(plaintext) { }
|
104
109
|
|
105
|
-
|
110
|
+
static string getHashName() { return "SHA-384-HMAC"; }
|
106
111
|
};
|
107
112
|
#endif
|
108
113
|
|
109
114
|
#if ENABLED_SHA512_HMAC
|
110
115
|
class JSHA512_HMAC : public JHMAC_Template<SHA512, SHA512_HMAC>
|
111
116
|
{
|
112
|
-
|
113
|
-
|
117
|
+
public:
|
118
|
+
JSHA512_HMAC(string plaintext = "") : JHMAC_Template<SHA512, SHA512_HMAC>(plaintext) { }
|
114
119
|
|
115
|
-
|
120
|
+
static string getHashName() { return "SHA-512-HMAC"; }
|
116
121
|
};
|
117
122
|
#endif
|
118
123
|
#endif
|
119
|
-
|
120
|
-
|
121
|
-
#endif
|
122
|
-
#endif
|
data/ext/jsha3.h
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
|
2
|
+
/*
|
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
|
+
*/
|
7
|
+
|
8
|
+
#ifndef __JSHA3_H__
|
9
|
+
#define __JSHA3_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#define ANY_SHA3_HASH_ENABLED \
|
14
|
+
ENABLED_SHA3_HASH || ENABLED_SHA3_224_HASH || \
|
15
|
+
ENABLED_SHA3_256_HASH || ENABLED_SHA3_384_HASH || \
|
16
|
+
ENABLED_SHA3_512_HASH
|
17
|
+
|
18
|
+
#define ANY_SHA3_HMAC_ENABLED\
|
19
|
+
ENABLED_SHA3_HMAC || ENABLED_SHA3_224_HMAC || \
|
20
|
+
ENABLED_SHA3_256_HMAC || ENABLED_SHA3_384_HMAC || \
|
21
|
+
ENABLED_SHA3_512_HMAC
|
22
|
+
|
23
|
+
#if ANY_SHA3_HASH_ENABLED || ANY_SHA3_HMAC_ENABLED
|
24
|
+
|
25
|
+
#if ANY_SHA3_HASH_ENABLED
|
26
|
+
#include "jhash_t.h"
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#if ANY_SHA3_HMAC_ENABLED
|
30
|
+
#include "jhmac_t.h"
|
31
|
+
#endif
|
32
|
+
|
33
|
+
|
34
|
+
// Crypto++ headers...
|
35
|
+
|
36
|
+
#ifdef HAVE_CRYPTOPP_SHA3_BLOCKSIZE
|
37
|
+
#include "sha3.h"
|
38
|
+
#else
|
39
|
+
#include "jsha3_blocksizes.h"
|
40
|
+
#endif
|
41
|
+
|
42
|
+
using namespace CryptoPP;
|
43
|
+
|
44
|
+
#if ENABLED_SHA3_224_HASH
|
45
|
+
class JSHA3_224 : public JHash_Template<SHA3_224, SHA3_224_HASH>
|
46
|
+
{
|
47
|
+
public:
|
48
|
+
JSHA3_224(string plaintext = "") : JHash_Template<SHA3_224, SHA3_224_HASH>(plaintext) { }
|
49
|
+
|
50
|
+
static string getHashName() { return "SHA3-224"; }
|
51
|
+
};
|
52
|
+
|
53
|
+
typedef JSHA3_224 JSHA3;
|
54
|
+
#endif
|
55
|
+
|
56
|
+
#if ENABLED_SHA3_256_HASH
|
57
|
+
class JSHA3_256 : public JHash_Template<SHA3_256, SHA3_256_HASH>
|
58
|
+
{
|
59
|
+
public:
|
60
|
+
JSHA3_256(string plaintext = "") : JHash_Template<SHA3_256, SHA3_256_HASH>(plaintext) { }
|
61
|
+
|
62
|
+
static string getHashName() { return "SHA-256"; }
|
63
|
+
};
|
64
|
+
#endif
|
65
|
+
|
66
|
+
#if ENABLED_SHA3_384_HASH
|
67
|
+
class JSHA3_384 : public JHash_Template<SHA3_384, SHA3_384_HASH>
|
68
|
+
{
|
69
|
+
public:
|
70
|
+
JSHA3_384(string plaintext = "") : JHash_Template<SHA3_384, SHA3_384_HASH>(plaintext) { }
|
71
|
+
|
72
|
+
static string getHashName() { return "SHA-384"; }
|
73
|
+
};
|
74
|
+
#endif
|
75
|
+
|
76
|
+
#if ENABLED_SHA3_512_HASH
|
77
|
+
class JSHA3_512 : public JHash_Template<SHA3_512, SHA3_512_HASH>
|
78
|
+
{
|
79
|
+
public:
|
80
|
+
JSHA3_512(string plaintext = "") : JHash_Template<SHA3_512, SHA3_512_HASH>(plaintext) { }
|
81
|
+
|
82
|
+
static string getHashName() { return "SHA-512"; }
|
83
|
+
};
|
84
|
+
#endif
|
85
|
+
|
86
|
+
|
87
|
+
#if ENABLED_SHA3_224_HMAC
|
88
|
+
class JSHA3_224_HMAC : public JHMAC_Template<SHA3_224, SHA3_224_HMAC>
|
89
|
+
{
|
90
|
+
public:
|
91
|
+
JSHA3_224_HMAC(string plaintext = "") : JHMAC_Template<SHA3_224, SHA3_224_HMAC>(plaintext) { }
|
92
|
+
|
93
|
+
static string getHashName() { return "SHA-224-HMAC"; }
|
94
|
+
};
|
95
|
+
|
96
|
+
typedef JSHA3_224_HMAC JSHA3_HMAC;
|
97
|
+
#endif
|
98
|
+
|
99
|
+
#if ENABLED_SHA3_256_HMAC
|
100
|
+
class JSHA3_256_HMAC : public JHMAC_Template<SHA3_256, SHA3_256_HMAC>
|
101
|
+
{
|
102
|
+
public:
|
103
|
+
JSHA3_256_HMAC(string plaintext = "") : JHMAC_Template<SHA3_256, SHA3_256_HMAC>(plaintext) { }
|
104
|
+
|
105
|
+
static string getHashName() { return "SHA-256-HMAC"; }
|
106
|
+
};
|
107
|
+
#endif
|
108
|
+
|
109
|
+
#if ENABLED_SHA3_384_HMAC
|
110
|
+
class JSHA3_384_HMAC : public JHMAC_Template<SHA3_384, SHA3_384_HMAC>
|
111
|
+
{
|
112
|
+
public:
|
113
|
+
JSHA3_384_HMAC(string plaintext = "") : JHMAC_Template<SHA3_384, SHA3_384_HMAC>(plaintext) { }
|
114
|
+
|
115
|
+
static string getHashName() { return "SHA-384-HMAC"; }
|
116
|
+
};
|
117
|
+
#endif
|
118
|
+
|
119
|
+
#if ENABLED_SHA3_512_HMAC
|
120
|
+
class JSHA3_512_HMAC : public JHMAC_Template<SHA3_512, SHA3_512_HMAC>
|
121
|
+
{
|
122
|
+
public:
|
123
|
+
JSHA3_512_HMAC(string plaintext = "") : JHMAC_Template<SHA3_512, SHA3_512_HMAC>(plaintext) { }
|
124
|
+
|
125
|
+
static string getHashName() { return "SHA-512-HMAC"; }
|
126
|
+
};
|
127
|
+
#endif
|
128
|
+
|
129
|
+
#endif
|
130
|
+
#endif
|