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/jconfig.h
ADDED
@@ -0,0 +1,127 @@
|
|
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 __JCONFIG_H__
|
9
|
+
#define __JCONFIG_H__
|
10
|
+
|
11
|
+
// to enable or disable specific cipher algorithms,
|
12
|
+
// set these to either 1 or 0 -- 1 for enabled, 0 for
|
13
|
+
// disabled, obviously.
|
14
|
+
//
|
15
|
+
// if we have config.h, rely on that, otherwise, below
|
16
|
+
// are the defaults...
|
17
|
+
|
18
|
+
#ifdef HAVE_CONFIG_H
|
19
|
+
#include "config.h"
|
20
|
+
#else
|
21
|
+
|
22
|
+
#define ENABLED_THREEWAY_CIPHER 1
|
23
|
+
#define ENABLED_AES_CIPHER 1
|
24
|
+
#define ENABLED_BLOWFISH_CIPHER 1
|
25
|
+
#define ENABLED_CAMELLIA_CIPHER 1
|
26
|
+
#define ENABLED_CAST128_CIPHER 1
|
27
|
+
#define ENABLED_CAST256_CIPHER 1
|
28
|
+
#define ENABLED_DES_CIPHER 1
|
29
|
+
#define ENABLED_DES_EDE2_CIPHER 1
|
30
|
+
#define ENABLED_DES_EDE3_CIPHER 1
|
31
|
+
#define ENABLED_DES_XEX3_CIPHER 1
|
32
|
+
#define ENABLED_DIAMOND2_CIPHER 0
|
33
|
+
#define ENABLED_DIAMOND2_LITE_CIPHER 0
|
34
|
+
#define ENABLED_GOST_CIPHER 1
|
35
|
+
#define ENABLED_IDEA_CIPHER 1
|
36
|
+
#define ENABLED_MARS_CIPHER 1
|
37
|
+
#define ENABLED_RC2_CIPHER 1
|
38
|
+
#define ENABLED_RC5_CIPHER 1
|
39
|
+
#define ENABLED_RC6_CIPHER 1
|
40
|
+
#define ENABLED_SAFER_K_CIPHER 1
|
41
|
+
#define ENABLED_SAFER_SK_CIPHER 1
|
42
|
+
#define ENABLED_SHACAL2_CIPHER 1
|
43
|
+
#define ENABLED_SHARK_CIPHER 1
|
44
|
+
#define ENABLED_SERPENT_CIPHER 1
|
45
|
+
#define ENABLED_SKIPJACK_CIPHER 1
|
46
|
+
#define ENABLED_SQUARE_CIPHER 1
|
47
|
+
#define ENABLED_TEA_CIPHER 1
|
48
|
+
#define ENABLED_TWOFISH_CIPHER 1
|
49
|
+
|
50
|
+
#define ENABLED_ARC4_CIPHER 1
|
51
|
+
#define ENABLED_MARC4_CIPHER 1
|
52
|
+
#define ENABLED_PANAMA_LITTLE_ENDIAN_CIPHER 1
|
53
|
+
#define ENABLED_PANAMA_BIG_ENDIAN_CIPHER 1
|
54
|
+
#define ENABLED_SEAL_LITTLE_ENDIAN_CIPHER 1
|
55
|
+
#define ENABLED_SEAL_BIG_ENDIAN_CIPHER 1
|
56
|
+
|
57
|
+
#define ENABLED_HAVAL_HASH 0
|
58
|
+
#define ENABLED_HAVAL3_HASH 0
|
59
|
+
#define ENABLED_HAVAL4_HASH 0
|
60
|
+
#define ENABLED_HAVAL5_HASH 0
|
61
|
+
#define ENABLED_MD2_HASH 1
|
62
|
+
#define ENABLED_MD4_HASH 1
|
63
|
+
#define ENABLED_MD5_HASH 1
|
64
|
+
#define ENABLED_PANAMA_LITTLE_ENDIAN_HASH 1
|
65
|
+
#define ENABLED_PANAMA_BIG_ENDIAN_HASH 1
|
66
|
+
#define ENABLED_RIPEMD128_HASH 1
|
67
|
+
#define ENABLED_RIPEMD160_HASH 1
|
68
|
+
#define ENABLED_RIPEMD256_HASH 1
|
69
|
+
#define ENABLED_RIPEMD320_HASH 1
|
70
|
+
#define ENABLED_SHA1_HASH 1
|
71
|
+
#define ENABLED_SHA256_HASH 1
|
72
|
+
#define ENABLED_SHA384_HASH 1
|
73
|
+
#define ENABLED_SHA512_HASH 1
|
74
|
+
#define ENABLED_TIGER_HASH 1
|
75
|
+
#define ENABLED_WHIRLPOOL_HASH 1
|
76
|
+
|
77
|
+
#define ENABLED_MD2_HMAC 1
|
78
|
+
#define ENABLED_MD4_HMAC 1
|
79
|
+
#define ENABLED_MD5_HMAC 1
|
80
|
+
#define ENABLED_RIPEMD128_HMAC 1
|
81
|
+
#define ENABLED_RIPEMD160_HMAC 1
|
82
|
+
#define ENABLED_RIPEMD256_HMAC 1
|
83
|
+
#define ENABLED_RIPEMD320_HMAC 1
|
84
|
+
#define ENABLED_SHA1_HMAC 1
|
85
|
+
#define ENABLED_SHA256_HMAC 1
|
86
|
+
#define ENABLED_SHA384_HMAC 1
|
87
|
+
#define ENABLED_SHA512_HMAC 1
|
88
|
+
#define ENABLED_TIGER_HMAC 1
|
89
|
+
#define ENABLED_WHIRLPOOL_HMAC 1
|
90
|
+
|
91
|
+
#define ENABLED_ADLER32_CHECKSUM 1
|
92
|
+
#define ENABLED_CRC32_CHECKSUM 1
|
93
|
+
|
94
|
+
#endif
|
95
|
+
|
96
|
+
// just to make sure SHARK and such are disabled if we don't
|
97
|
+
// have WORD64 or some version thereof...
|
98
|
+
|
99
|
+
// test if word64 is available for SHARK, SHA-384, SHA-512 and Tiger.
|
100
|
+
|
101
|
+
#if defined(__GNUC__) || defined(__MWERKS__) || defined(_MSC_VER) || defined(__BCPLUSPLUS__)
|
102
|
+
#define WORD64_AVAILABLE
|
103
|
+
#else
|
104
|
+
#undef ENABLED_CAMELLIA_CIPHER
|
105
|
+
#undef ENABLED_SHARK_CIPHER
|
106
|
+
#undef ENABLED_SHA384_HASH
|
107
|
+
#undef ENABLED_SHA512_HASH
|
108
|
+
#undef ENABLED_SHA384_HMAC
|
109
|
+
#undef ENABLED_SHA512_HMAC
|
110
|
+
#undef ENABLED_TIGER_HASH
|
111
|
+
#undef ENABLED_TIGER_HMAC
|
112
|
+
#undef ENABLED_WHIRLPOOL_HASH
|
113
|
+
#undef ENABLED_WHIRLPOOL_HMAC
|
114
|
+
|
115
|
+
#define ENABLED_CAMELLIA_CIPHER 0
|
116
|
+
#define ENABLED_SHARK_CIPHER 0
|
117
|
+
#define ENABLED_SHA384_HASH 0
|
118
|
+
#define ENABLED_SHA512_HASH 0
|
119
|
+
#define ENABLED_SHA384_HMAC 0
|
120
|
+
#define ENABLED_SHA512_HMAC 0
|
121
|
+
#define ENABLED_TIGER_HASH 0
|
122
|
+
#define ENABLED_TIGER_HMAC 0
|
123
|
+
#define ENABLED_WHIRLPOOL_HASH 0
|
124
|
+
#define ENABLED_WHIRLPOOL_HMAC 0
|
125
|
+
#endif
|
126
|
+
|
127
|
+
#endif
|
data/ext/jconstants.h
ADDED
@@ -0,0 +1,189 @@
|
|
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 __JCONSTANTS_H__
|
9
|
+
#define __JCONSTANTS_H__
|
10
|
+
|
11
|
+
using namespace CryptoPP;
|
12
|
+
|
13
|
+
// test if word64 is available for SHARK, SHA-384, SHA-512 and Tiger.
|
14
|
+
|
15
|
+
#if defined(__GNUC__) || defined(__MWERKS__) || defined(_MSC_VER) || defined(__BCPLUSPLUS__)
|
16
|
+
#define WORD64_AVAILABLE
|
17
|
+
#endif
|
18
|
+
|
19
|
+
|
20
|
+
// Cipher types used in JCipher and JStream...
|
21
|
+
|
22
|
+
enum CipherEnum {
|
23
|
+
UNKNOWN_CIPHER = -1,
|
24
|
+
|
25
|
+
// Stream ciphers...
|
26
|
+
|
27
|
+
ARC4_CIPHER,
|
28
|
+
PANAMA_LITTLE_ENDIAN_CIPHER,
|
29
|
+
PANAMA_BIG_ENDIAN_CIPHER,
|
30
|
+
MARC4_CIPHER,
|
31
|
+
SEAL_LITTLE_ENDIAN_CIPHER,
|
32
|
+
SEAL_BIG_ENDIAN_CIPHER,
|
33
|
+
|
34
|
+
// Block Ciphers...
|
35
|
+
|
36
|
+
THREEWAY_CIPHER,
|
37
|
+
AES_CIPHER,
|
38
|
+
BLOWFISH_CIPHER,
|
39
|
+
CAST128_CIPHER,
|
40
|
+
CAST256_CIPHER,
|
41
|
+
DES_CIPHER,
|
42
|
+
DES_EDE2_CIPHER,
|
43
|
+
DES_EDE3_CIPHER,
|
44
|
+
DES_XEX3_CIPHER,
|
45
|
+
DIAMOND2_CIPHER,
|
46
|
+
DIAMOND2_LITE_CIPHER,
|
47
|
+
GOST_CIPHER,
|
48
|
+
IDEA_CIPHER,
|
49
|
+
MARS_CIPHER,
|
50
|
+
RC2_CIPHER,
|
51
|
+
RC5_CIPHER,
|
52
|
+
RC6_CIPHER,
|
53
|
+
SAFER_K_CIPHER,
|
54
|
+
SAFER_SK_CIPHER,
|
55
|
+
SERPENT_CIPHER,
|
56
|
+
SKIPJACK_CIPHER,
|
57
|
+
SQUARE_CIPHER,
|
58
|
+
TEA_CIPHER,
|
59
|
+
TWOFISH_CIPHER,
|
60
|
+
SHARK_CIPHER,
|
61
|
+
|
62
|
+
// Ciphers from Crypto++ 5.2.1...
|
63
|
+
|
64
|
+
CAMELLIA_CIPHER,
|
65
|
+
SHACAL2_CIPHER
|
66
|
+
};
|
67
|
+
|
68
|
+
#define PANAMA_CIPHER PANAMA_LITTLE_ENDIAN_CIPHER
|
69
|
+
#define SEAL_CIPHER SEAL_BIG_ENDIAN_CIPHER
|
70
|
+
#define RIJNDAEL_CIPHER AES_CIPHER
|
71
|
+
|
72
|
+
// This is used to determine if we're using a stream
|
73
|
+
// cipher or a block cipher. If its <= TYPE_OF_CIPHER,
|
74
|
+
// it's a stream cipher; otherwise, it's a block cipher...
|
75
|
+
|
76
|
+
#define IS_BLOCK_CIPHER(x) (x >= THREEWAY_CIPHER && x <= SHACAL2_CIPHER)
|
77
|
+
#define IS_STREAM_CIPHER(x) (x >= ARC4_CIPHER && x <= SEAL_BIG_ENDIAN_CIPHER)
|
78
|
+
#define VALID_CIPHER(x) (x >= ARC4_CIPHER && x <= SHACAL2_CIPHER)
|
79
|
+
|
80
|
+
|
81
|
+
// Block cipher modes used in JCipher...
|
82
|
+
|
83
|
+
enum ModeEnum {
|
84
|
+
UNKNOWN_MODE = -1,
|
85
|
+
# define BLOCK_MODE_X(c, s) \
|
86
|
+
c ## _MODE,
|
87
|
+
# include "defs/block_modes.def"
|
88
|
+
};
|
89
|
+
|
90
|
+
#define VALID_MODE(x) (x > UNKNOWN_MODE && x <= OFB_MODE)
|
91
|
+
|
92
|
+
|
93
|
+
// Block cipher padding used in JCipher...
|
94
|
+
|
95
|
+
enum PaddingEnum {
|
96
|
+
UNKNOWN_PADDING = -1,
|
97
|
+
# define PADDING_X(c, s) \
|
98
|
+
c ## _PADDING = StreamTransformationFilter::c ## _PADDING,
|
99
|
+
# include "defs/paddings.def"
|
100
|
+
};
|
101
|
+
|
102
|
+
#define VALID_PADDING(x) (x > UNKNOWN_PADDING && x <= DEFAULT_PADDING)
|
103
|
+
|
104
|
+
|
105
|
+
// Hashes... and HMAC stuff, too...
|
106
|
+
|
107
|
+
enum HashEnum {
|
108
|
+
UNKNOWN_HASH = -1,
|
109
|
+
|
110
|
+
// These are checksums, not cryptographic hashes...
|
111
|
+
|
112
|
+
ADLER32_CHECKSUM,
|
113
|
+
CRC32_CHECKSUM,
|
114
|
+
|
115
|
+
// These are hashes. And message digests. ...
|
116
|
+
|
117
|
+
HAVAL_HASH,
|
118
|
+
HAVAL3_HASH,
|
119
|
+
HAVAL4_HASH,
|
120
|
+
HAVAL5_HASH,
|
121
|
+
MD2_HASH,
|
122
|
+
MD4_HASH,
|
123
|
+
MD5_HASH,
|
124
|
+
PANAMA_LITTLE_ENDIAN_HASH,
|
125
|
+
PANAMA_BIG_ENDIAN_HASH,
|
126
|
+
RIPEMD160_HASH,
|
127
|
+
SHA1_HASH,
|
128
|
+
SHA256_HASH,
|
129
|
+
SHA384_HASH,
|
130
|
+
SHA512_HASH,
|
131
|
+
TIGER_HASH,
|
132
|
+
|
133
|
+
// These are for HMAC hashes...
|
134
|
+
|
135
|
+
MD2_HMAC,
|
136
|
+
MD4_HMAC,
|
137
|
+
MD5_HMAC,
|
138
|
+
RIPEMD160_HMAC,
|
139
|
+
SHA1_HMAC,
|
140
|
+
SHA256_HMAC,
|
141
|
+
SHA384_HMAC,
|
142
|
+
SHA512_HMAC,
|
143
|
+
TIGER_HMAC,
|
144
|
+
|
145
|
+
// Newer hashes and HMACs from Crypto++ 5.2.1...
|
146
|
+
|
147
|
+
RIPEMD128_HASH,
|
148
|
+
RIPEMD256_HASH,
|
149
|
+
RIPEMD320_HASH,
|
150
|
+
WHIRLPOOL_HASH,
|
151
|
+
|
152
|
+
RIPEMD128_HMAC,
|
153
|
+
RIPEMD256_HMAC,
|
154
|
+
RIPEMD320_HMAC,
|
155
|
+
WHIRLPOOL_HMAC
|
156
|
+
};
|
157
|
+
|
158
|
+
#define PANAMA_HASH PANAMA_LITTLE_ENDIAN_HASH
|
159
|
+
#define PANAMA_HMAC PANAMA_LITTLE_ENDIAN_HMAC
|
160
|
+
|
161
|
+
// this is to figure out if we're dealing
|
162
|
+
// with a HMAC or a regular hash...
|
163
|
+
|
164
|
+
#define IS_HMAC(x) \
|
165
|
+
(((x > TIGER_HASH && x < RIPEMD128_HASH) || x >= RIPEMD128_HMAC))
|
166
|
+
#define IS_NON_HMAC(x) \
|
167
|
+
((x <= TIGER_HASH || (x >= RIPEMD128_HASH && x <= WHIRLPOOL_HASH)))
|
168
|
+
|
169
|
+
|
170
|
+
// random number generators...
|
171
|
+
|
172
|
+
enum RNGEnum {
|
173
|
+
UNKNOWN_RNG = -1,
|
174
|
+
# define RNG_X(c, s) \
|
175
|
+
c ## _RNG,
|
176
|
+
# include "defs/rngs.def"
|
177
|
+
};
|
178
|
+
|
179
|
+
#define VALID_RNG(x) (x > UNKNOWN_RNG && x <= RAND_RNG)
|
180
|
+
|
181
|
+
#ifdef NONBLOCKING_RNG_AVAILABLE
|
182
|
+
#define DEFAULT_RNG NON_BLOCKING_RNG
|
183
|
+
#elif defined(BLOCKING_RNG_AVAILABLE)
|
184
|
+
#define DEFAULT_RNG BLOCKING_RNG
|
185
|
+
#else
|
186
|
+
#define DEFAULT_RNG RAND_RNG
|
187
|
+
#endif
|
188
|
+
|
189
|
+
#endif
|
data/ext/jcrc32.h
ADDED
@@ -0,0 +1,32 @@
|
|
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 __JCRC32_H__
|
9
|
+
#define __JCRC32_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_CRC32_CHECKSUM
|
14
|
+
|
15
|
+
#include "jhash_t.h"
|
16
|
+
|
17
|
+
// Crypto++ headers...
|
18
|
+
|
19
|
+
#include "crc.h"
|
20
|
+
|
21
|
+
using namespace CryptoPP;
|
22
|
+
|
23
|
+
class JCRC32 : public JHash_Template<CRC32, CRC32_CHECKSUM>
|
24
|
+
{
|
25
|
+
public:
|
26
|
+
JCRC32(string plaintext = "") : JHash_Template<CRC32, CRC32_CHECKSUM>(plaintext) { }
|
27
|
+
|
28
|
+
static string getHashName() { return "CRC32"; }
|
29
|
+
};
|
30
|
+
|
31
|
+
#endif
|
32
|
+
#endif
|
data/ext/jdes.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.h"
|
9
|
+
|
10
|
+
#if ENABLED_DES_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JDES::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new DESEncryption((byte*) itsKey.data(), itsKeylength);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JDES::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new DESDecryption((byte*) itsKey.data(), itsKeylength);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jdes.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_H__
|
9
|
+
#define __JDES_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_DES_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 : public JCipher_Template<DES_Info, DES_CIPHER>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|
data/ext/jdes_ede2.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_ede2.h"
|
9
|
+
|
10
|
+
#if ENABLED_DES_EDE2_CIPHER
|
11
|
+
|
12
|
+
BlockCipher* JDES_EDE2::getEncryptionObject()
|
13
|
+
{
|
14
|
+
return new DES_EDE2_Encryption((byte*) itsKey.data(), itsKeylength);
|
15
|
+
}
|
16
|
+
|
17
|
+
BlockCipher* JDES_EDE2::getDecryptionObject()
|
18
|
+
{
|
19
|
+
return new DES_EDE2_Decryption((byte*) itsKey.data(), itsKeylength);
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif
|
data/ext/jdes_ede2.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_EDE2_H__
|
9
|
+
#define __JDES_EDE2_H__
|
10
|
+
|
11
|
+
#include "jconfig.h"
|
12
|
+
|
13
|
+
#if ENABLED_DES_EDE2_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_EDE2 : public JCipher_Template<DES_EDE2_Info, DES_EDE2_CIPHER>
|
24
|
+
{
|
25
|
+
protected:
|
26
|
+
BlockCipher* getEncryptionObject();
|
27
|
+
BlockCipher* getDecryptionObject();
|
28
|
+
};
|
29
|
+
|
30
|
+
#endif
|
31
|
+
#endif
|