cryptopp 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +14 -0
  4. data/Guardfile +17 -0
  5. data/MIT-LICENSE +1 -1
  6. data/Rakefile +20 -27
  7. data/VERSION +1 -0
  8. data/cryptopp.gemspec +7 -182
  9. data/ext/Rakefile +2 -2
  10. data/ext/ciphers.cpp +619 -619
  11. data/ext/cryptopp.cpp +220 -217
  12. data/ext/cryptopp_ruby_api.h +7 -7
  13. data/ext/defs/hashes.def +16 -0
  14. data/ext/defs/hmacs.def +16 -0
  15. data/ext/digests.cpp +635 -601
  16. data/ext/extconf.rb +61 -19
  17. data/ext/j3way.cpp +5 -5
  18. data/ext/j3way.h +6 -6
  19. data/ext/jadler32.h +6 -6
  20. data/ext/jaes.cpp +5 -5
  21. data/ext/jaes.h +6 -6
  22. data/ext/jarc4.cpp +5 -5
  23. data/ext/jarc4.h +6 -6
  24. data/ext/jbase.cpp +94 -94
  25. data/ext/jbase.h +49 -55
  26. data/ext/jbasiccipherinfo.h +23 -23
  27. data/ext/jblowfish.cpp +5 -5
  28. data/ext/jblowfish.h +6 -6
  29. data/ext/jcamellia.cpp +5 -7
  30. data/ext/jcamellia.h +6 -8
  31. data/ext/jcast128.cpp +5 -5
  32. data/ext/jcast128.h +6 -6
  33. data/ext/jcast256.cpp +5 -5
  34. data/ext/jcast256.h +6 -6
  35. data/ext/jcipher.cpp +62 -62
  36. data/ext/jcipher.h +24 -24
  37. data/ext/jcipher_t.h +383 -383
  38. data/ext/jconfig.h +29 -46
  39. data/ext/jconstants.h +120 -122
  40. data/ext/jcrc32.h +6 -6
  41. data/ext/jdes.cpp +5 -5
  42. data/ext/jdes.h +6 -6
  43. data/ext/jdes_ede2.cpp +5 -5
  44. data/ext/jdes_ede2.h +6 -6
  45. data/ext/jdes_ede3.cpp +5 -5
  46. data/ext/jdes_ede3.h +6 -6
  47. data/ext/jdes_xex3.cpp +5 -5
  48. data/ext/jdes_xex3.h +6 -6
  49. data/ext/jdiamond2.cpp +5 -5
  50. data/ext/jdiamond2.h +6 -6
  51. data/ext/jdiamond2lite.cpp +5 -5
  52. data/ext/jdiamond2lite.h +6 -6
  53. data/ext/jexception.h +5 -5
  54. data/ext/jgost.cpp +5 -5
  55. data/ext/jgost.h +6 -6
  56. data/ext/jhash.cpp +51 -51
  57. data/ext/jhash.h +22 -27
  58. data/ext/jhash_t.h +59 -59
  59. data/ext/jhaval.h +15 -15
  60. data/ext/jhelpers.cpp +54 -54
  61. data/ext/jhelpers.h +3 -3
  62. data/ext/jhmac.cpp +20 -20
  63. data/ext/jhmac.h +15 -15
  64. data/ext/jhmac_t.h +40 -72
  65. data/ext/jidea.cpp +5 -5
  66. data/ext/jidea.h +6 -6
  67. data/ext/jmarc4.cpp +5 -5
  68. data/ext/jmarc4.h +6 -6
  69. data/ext/jmars.cpp +5 -5
  70. data/ext/jmars.h +6 -6
  71. data/ext/jmd2.h +9 -9
  72. data/ext/jmd4.h +9 -9
  73. data/ext/jmd5.h +9 -9
  74. data/ext/jpanamacipher.cpp +7 -7
  75. data/ext/jpanamacipher.h +9 -9
  76. data/ext/jpanamahash.h +9 -9
  77. data/ext/jrc2.cpp +15 -15
  78. data/ext/jrc2.h +11 -11
  79. data/ext/jrc5.cpp +5 -5
  80. data/ext/jrc5.h +6 -6
  81. data/ext/jrc6.cpp +5 -5
  82. data/ext/jrc6.h +6 -6
  83. data/ext/jripemd160.h +28 -28
  84. data/ext/jsafer.cpp +7 -7
  85. data/ext/jsafer.h +9 -9
  86. data/ext/jseal.cpp +7 -7
  87. data/ext/jseal.h +9 -9
  88. data/ext/jserpent.cpp +5 -5
  89. data/ext/jserpent.h +6 -6
  90. data/ext/jsha.h +38 -37
  91. data/ext/jsha3.h +130 -0
  92. data/ext/jsha3_blocksizes.h +73 -0
  93. data/ext/jshacal2.cpp +5 -5
  94. data/ext/jshacal2.h +6 -6
  95. data/ext/jshark.cpp +5 -7
  96. data/ext/jshark.h +6 -8
  97. data/ext/jsink.cpp +57 -57
  98. data/ext/jsink.h +127 -123
  99. data/ext/jskipjack.cpp +5 -5
  100. data/ext/jskipjack.h +6 -6
  101. data/ext/jsquare.cpp +5 -5
  102. data/ext/jsquare.h +6 -6
  103. data/ext/jstream.cpp +3 -3
  104. data/ext/jstream.h +3 -3
  105. data/ext/jstream_t.h +74 -126
  106. data/ext/jtea.cpp +5 -5
  107. data/ext/jtea.h +6 -6
  108. data/ext/jtiger.h +9 -11
  109. data/ext/jtwofish.cpp +5 -5
  110. data/ext/jtwofish.h +6 -6
  111. data/ext/jwhirlpool.h +9 -11
  112. data/ext/utils.cpp +3 -3
  113. data/extras/parser_c.rb +102 -102
  114. data/test/ciphers_test.rb +24 -30
  115. data/test/data/ciphers/3desval.yml +13 -0
  116. data/test/data/ciphers/3wayval.yml +17 -0
  117. data/test/data/ciphers/arc4.yml +22 -0
  118. data/test/data/ciphers/blowfish.yml +9 -0
  119. data/test/data/ciphers/camellia.yml +21 -0
  120. data/test/data/ciphers/cast128v.yml +13 -0
  121. data/test/data/ciphers/cast256v.yml +13 -0
  122. data/test/data/ciphers/descert.yml +723 -0
  123. data/test/data/ciphers/diamond.yml +31 -0
  124. data/test/data/ciphers/gostval.yml +33 -0
  125. data/test/data/ciphers/ideaval.yml +45 -0
  126. data/test/data/ciphers/marsval.yml +37 -0
  127. data/test/data/ciphers/panamac.yml +11 -0
  128. data/test/data/ciphers/rc2val.yml +49 -0
  129. data/test/data/ciphers/rc5val.yml +26 -0
  130. data/test/data/ciphers/rc6val.yml +25 -0
  131. data/test/data/ciphers/rijndael.yml +37 -0
  132. data/test/data/ciphers/saferval.yml +77 -0
  133. data/test/data/ciphers/seal.yml +6 -0
  134. data/test/data/ciphers/serpentv.yml +37 -0
  135. data/test/data/ciphers/shacal2.yml +21 -0
  136. data/test/data/ciphers/sharkval.yml +29 -0
  137. data/test/data/ciphers/skipjack.yml +5 -0
  138. data/test/data/ciphers/squareva.yml +33 -0
  139. data/test/data/ciphers/twofishv.yml +37 -0
  140. data/test/data/digests/adler32.yml +19 -0
  141. data/test/data/digests/crc32.yml +25 -0
  142. data/test/data/digests/haval.yml +7 -0
  143. data/test/data/digests/havalcer.yml +1 -0
  144. data/test/data/digests/md2.yml +22 -0
  145. data/test/data/digests/md4.yml +22 -0
  146. data/test/data/digests/md5.yml +22 -0
  147. data/test/data/digests/panamah.yml +13 -0
  148. data/test/data/digests/ripemd.yml +97 -0
  149. data/test/data/digests/sha.yml +25 -0
  150. data/test/data/digests/sha3.yml +23 -0
  151. data/test/data/digests/tiger.yml +30 -0
  152. data/test/data/digests/whirlpool.yml +25 -0
  153. data/test/data/hmacs/hmac.yml +14 -0
  154. data/test/digests_test.rb +17 -23
  155. data/test/hmacs_test.rb +25 -31
  156. data/test/test_helper.rb +31 -37
  157. metadata +70 -82
  158. data/test/data/ciphers/3desval.dat +0 -7
  159. data/test/data/ciphers/3wayval.dat +0 -6
  160. data/test/data/ciphers/arc4.dat +0 -8
  161. data/test/data/ciphers/blowfish.dat +0 -5
  162. data/test/data/ciphers/camellia.dat +0 -7
  163. data/test/data/ciphers/cast128v.dat +0 -5
  164. data/test/data/ciphers/cast256v.dat +0 -5
  165. data/test/data/ciphers/descert.dat +0 -198
  166. data/test/data/ciphers/diamond.dat +0 -9
  167. data/test/data/ciphers/gostval.dat +0 -10
  168. data/test/data/ciphers/ideaval.dat +0 -13
  169. data/test/data/ciphers/marsval.dat +0 -11
  170. data/test/data/ciphers/panamac.dat +0 -7
  171. data/test/data/ciphers/rc2val.dat +0 -10
  172. data/test/data/ciphers/rc5val.dat +0 -7
  173. data/test/data/ciphers/rc6val.dat +0 -8
  174. data/test/data/ciphers/rijndael.dat +0 -11
  175. data/test/data/ciphers/saferval.dat +0 -27
  176. data/test/data/ciphers/seal.dat +0 -3
  177. data/test/data/ciphers/serpentv.dat +0 -11
  178. data/test/data/ciphers/shacal2.dat +0 -7
  179. data/test/data/ciphers/sharkval.dat +0 -9
  180. data/test/data/ciphers/skipjack.dat +0 -3
  181. data/test/data/ciphers/squareva.dat +0 -10
  182. data/test/data/ciphers/twofishv.dat +0 -11
  183. data/test/data/digests/adler32.dat +0 -8
  184. data/test/data/digests/crc32.dat +0 -10
  185. data/test/data/digests/haval.dat +0 -4
  186. data/test/data/digests/havalcer.dat +0 -23
  187. data/test/data/digests/md2.dat +0 -9
  188. data/test/data/digests/md4.dat +0 -9
  189. data/test/data/digests/md5.dat +0 -9
  190. data/test/data/digests/panamah.dat +0 -8
  191. data/test/data/digests/ripemd.dat +0 -43
  192. data/test/data/digests/sha.dat +0 -19
  193. data/test/data/digests/tiger.dat +0 -11
  194. data/test/data/digests/whirlpool.dat +0 -13
  195. data/test/data/hmacs/hmac.dat +0 -6
@@ -1,8 +1,8 @@
1
1
 
2
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
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 "ruby.h"
@@ -26,19 +26,19 @@ VALUE rb_cCryptoPP_Digest;
26
26
  VALUE rb_cCryptoPP_Digest_HMAC;
27
27
 
28
28
  #define CIPHER_ALGORITHM_X(klass, r, c, s) \
29
- VALUE rb_cCryptoPP_Cipher_ ## r ;
29
+ VALUE rb_cCryptoPP_Cipher_ ## r ;
30
30
  #include "defs/ciphers.def"
31
31
 
32
32
  #define CHECKSUM_ALGORITHM_X(klass, r, c, s) \
33
- VALUE rb_cCryptoPP_Digest_ ## r ;
33
+ VALUE rb_cCryptoPP_Digest_ ## r ;
34
34
  #include "defs/checksums.def"
35
35
 
36
36
  #define HASH_ALGORITHM_X(klass, r, c, s) \
37
- VALUE rb_cCryptoPP_Digest_ ## r ;
37
+ VALUE rb_cCryptoPP_Digest_ ## r ;
38
38
  #include "defs/hashes.def"
39
39
 
40
40
  #define HMAC_ALGORITHM_X(klass, r, c, s) \
41
- VALUE rb_cCryptoPP_Digest_HMAC_ ## r ;
41
+ VALUE rb_cCryptoPP_Digest_HMAC_ ## r ;
42
42
  #include "defs/hmacs.def"
43
43
 
44
44
  /* Marking function for garbage collector. */
@@ -49,7 +49,7 @@ void cipher_mark(JBase *c)
49
49
  /* Free up memory. */
50
50
  void cipher_free(JBase *c)
51
51
  {
52
- delete c;
52
+ delete c;
53
53
  }
54
54
 
55
55
  /* Marking function for garbage collector. */
@@ -60,226 +60,229 @@ void hash_mark (JHash *c)
60
60
  /* Free up memory. */
61
61
  void hash_free (JHash *c)
62
62
  {
63
- delete c;
63
+ delete c;
64
64
  }
65
65
 
66
66
 
67
67
  #define CRYPTOPP_VALUE_FUNC(f) \
68
- RUBY_METHOD_FUNC(f)
68
+ RUBY_METHOD_FUNC(f)
69
69
  #define CRYPTOPP_DEFINE_CONST(klass, n, c) \
70
- rb_define_const(klass, n, INT2NUM(c));
70
+ rb_define_const(klass, n, INT2NUM(c));
71
71
  #define CRYPTOPP_MODULE_METHOD(m, n, f, a) \
72
- rb_define_module_function(m, n, CRYPTOPP_VALUE_FUNC(f), a);
72
+ rb_define_module_function(m, n, CRYPTOPP_VALUE_FUNC(f), a);
73
73
  #define CRYPTOPP_CLASS_METHOD(c, n, f, a) \
74
- rb_define_method(rb_cCryptoPP_ ## c, n, CRYPTOPP_VALUE_FUNC(f), a);
74
+ rb_define_method(rb_cCryptoPP_ ## c, n, CRYPTOPP_VALUE_FUNC(f), a);
75
75
  #define CRYPTOPP_MODULE_METHOD_ALIAS(m, n, o) \
76
- rb_define_alias(rb_singleton_class(m), n, o);
76
+ rb_define_alias(rb_singleton_class(m), n, o);
77
77
  #define CRYPTOPP_CLASS_METHOD_ALIAS(c, n, o) \
78
- rb_define_alias(rb_cCryptoPP_ ## c, n, o);
78
+ rb_define_alias(rb_cCryptoPP_ ## c, n, o);
79
79
 
80
80
  /* The extension initialization function. */
81
81
  extern "C" void Init_cryptopp()
82
82
  {
83
- /**
84
- * This is the main CryptoPP module. All of the various Cipher, Digest
85
- * and HMAC classes are found here.
86
- *
87
- * The CryptoPP module contains a handful of module methods that can be
88
- * used to create new ciphers, digests and HMACs and provide information
89
- * on the environment and configuration CryptoPP is running with.
90
- */
91
- rb_mCryptoPP = rb_define_module("CryptoPP");
92
-
93
- /**
94
- * Exception class.
95
- */
96
- rb_eCryptoPP_Error = rb_define_class_under(rb_mCryptoPP, "CryptoPPError", rb_eStandardError);
97
-
98
- /**
99
- * The base cipher class. This class is not meant to be used directly. It
100
- * merely serves as the base class for all CryptoPP ciphers.
101
- *
102
- * Ciphers can be created either by using the
103
- * <tt>CryptoPP#cipher_factory</tt> factory method or by instantiating
104
- * the classes directly. For instance, the following are equivalent:
105
- *
106
- * cipher = CryptoPP.cipher_factory(:aes)
107
- * cipher = CryptoPP::AES.new
108
- *
109
- * Options include:
110
- *
111
- * * <tt>:plaintext</tt> and <tt>:plaintext_hex</tt> - set the plaintext. You
112
- * can only use one at a time.
113
- * * <tt>:ciphertext</tt> and <tt>:ciphertext_hex</tt> - set the ciphertext.
114
- * You can only use one at a time.
115
- * * <tt>:key</tt> and <tt>:key_hex</tt> - set the key. You can only use one
116
- * at a time.
117
- * * <tt>:key_length</tt> - set the length of the key. Normally this is done
118
- * automatically, but you can force a different key length if necessary.
119
- * * <tt>:effective_key_length</tt> - sets the effective key length on RC2
120
- * ciphers.
121
- * * <tt>:rounds</tt> - sets the number of rounds a cipher performs on
122
- * block ciphers that support them.
123
- * * <tt>:rng</tt> - sets the random number generator to be used for things
124
- * like creating initialization vectors and such. Not all operating
125
- * systems and environments will support all RNGs. You can check which
126
- * ones are supported with <tt>CryptoPP#rng_available?</tt>. Possible
127
- * values are :blocking, :non_blocking and :rand.
128
- *
129
- * All of these options have their equivalent setter and getter methods
130
- * if you need to modify them after initialization.
131
- */
132
- rb_cCryptoPP_Cipher = rb_define_class_under(rb_mCryptoPP, "Cipher", rb_cObject);
133
-
134
- /**
135
- * The base Digest class. This class is not meant to be used directly. It
136
- * merely serves as the base class for all CryptoPP Digests and HMACs.
137
- */
138
- rb_cCryptoPP_Digest = rb_define_class_under(rb_mCryptoPP, "Digest", rb_cObject);
139
-
140
- /**
141
- * The base HMAC class. This class is not meant to be used directly. It
142
- * merely serves as the base class for all CryptoPP HMACs.
143
- */
144
- rb_cCryptoPP_Digest_HMAC = rb_define_class_under(rb_mCryptoPP, "HMAC", rb_cCryptoPP_Digest);
145
-
146
- rb_undef_alloc_func(rb_cCryptoPP_Cipher);
147
- rb_undef_alloc_func(rb_cCryptoPP_Digest);
148
- rb_undef_alloc_func(rb_cCryptoPP_Digest_HMAC);
149
-
150
- rb_define_const(rb_mCryptoPP, "VERSION", rb_str_new2("0.0.2"));
151
- rb_define_const(rb_mCryptoPP, "CRYPTOPP_VERSION", INT2NUM(CRYPTOPP_VERSION));
152
-
153
- # define CIPHER_ALGORITHM_X(klass, r, c, s) \
154
- rb_cCryptoPP_Cipher_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Cipher); \
155
- rb_define_singleton_method((rb_cCryptoPP_Cipher_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_cipher_ ## r ##_new), -1);
156
- # include "defs/ciphers.def"
157
-
158
- # define CHECKSUM_ALGORITHM_X(klass, r, c, s) \
159
- rb_cCryptoPP_Digest_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Digest); \
160
- rb_define_singleton_method((rb_cCryptoPP_Digest_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_digest_ ## r ##_new), -1);
161
- # include "defs/checksums.def"
162
-
163
- # define HASH_ALGORITHM_X(klass, r, c, s) \
164
- rb_cCryptoPP_Digest_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Digest); \
165
- rb_define_singleton_method((rb_cCryptoPP_Digest_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_digest_ ## r ##_new), -1);
166
- # include "defs/hashes.def"
167
-
168
- # define HMAC_ALGORITHM_X(klass, r, c, s) \
169
- rb_cCryptoPP_Digest_HMAC_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Digest_HMAC); \
170
- rb_define_singleton_method((rb_cCryptoPP_Digest_HMAC_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_digest_hmac_ ## r ##_new), -1);
171
- # include "defs/hmacs.def"
172
-
173
- rb_define_module_function(rb_mCryptoPP, "cipher_list", RUBY_METHOD_FUNC(rb_module_cipher_list), 0); /* in ciphers.cpp */
174
- rb_define_module_function(rb_mCryptoPP, "cipher_name", RUBY_METHOD_FUNC(rb_module_cipher_name), 1); /* in ciphers.cpp */
175
- rb_define_module_function(rb_mCryptoPP, "block_mode_name", RUBY_METHOD_FUNC(rb_module_block_mode_name), 1); /* in ciphers.cpp */
176
- rb_define_module_function(rb_mCryptoPP, "padding_name", RUBY_METHOD_FUNC(rb_module_padding_name), 1); /* in ciphers.cpp */
177
- rb_define_module_function(rb_mCryptoPP, "rng_name", RUBY_METHOD_FUNC(rb_module_rng_name), 1); /* in ciphers.cpp */
178
- rb_define_module_function(rb_mCryptoPP, "cipher_enabled?", RUBY_METHOD_FUNC(rb_module_cipher_enabled), 1); /* in ciphers.cpp */
179
- rb_define_module_function(rb_mCryptoPP, "rng_available?", RUBY_METHOD_FUNC(rb_module_rng_available), 1); /* in ciphers.cpp */
180
-
181
- rb_define_module_function(rb_mCryptoPP, "cipher_factory", RUBY_METHOD_FUNC(rb_module_cipher_factory), -1); /* in ciphers.cpp */
182
- rb_define_module_function(rb_mCryptoPP, "digest_factory", RUBY_METHOD_FUNC(rb_module_digest_factory), -1); /* in digests.cpp */
183
- rb_define_module_function(rb_mCryptoPP, "hmac_factory", RUBY_METHOD_FUNC(rb_module_hmac_factory), -1); /* in digests.cpp */
184
-
185
- rb_define_module_function(rb_mCryptoPP, "digest_enabled?", RUBY_METHOD_FUNC(rb_module_digest_enabled), 1); /* in digests.cpp */
186
- rb_define_module_function(rb_mCryptoPP, "digest_name", RUBY_METHOD_FUNC(rb_module_digest_name), 1); /* in digests.cpp */
187
- rb_define_module_function(rb_mCryptoPP, "digest_list", RUBY_METHOD_FUNC(rb_module_digest_list), 0); /* in digests.cpp */
188
-
189
- rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hash_enabled?", "digest_enabled?");
190
- rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hash_name", "digest_name");
191
- rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hash_list", "digest_list");
192
-
193
- rb_define_module_function(rb_mCryptoPP, "digest", RUBY_METHOD_FUNC(rb_module_digest), -1); /* in digests.cpp */
194
- rb_define_module_function(rb_mCryptoPP, "digest_hex", RUBY_METHOD_FUNC(rb_module_digest_hex), -1); /* in digests.cpp */
195
-
196
- rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hexdigest", "digest_hex");
197
-
198
- rb_define_module_function(rb_mCryptoPP, "digest_io", RUBY_METHOD_FUNC(rb_module_digest_io), -1); /* in digests.cpp */
199
- rb_define_module_function(rb_mCryptoPP, "digest_io_hex", RUBY_METHOD_FUNC(rb_module_digest_io_hex), -1); /* in digests.cpp */
200
-
201
- rb_define_module_function(rb_mCryptoPP, "digest_hmac", RUBY_METHOD_FUNC(rb_module_hmac_digest), -1); /* in digests.cpp */
202
- rb_define_module_function(rb_mCryptoPP, "digest_hmac_hex", RUBY_METHOD_FUNC(rb_module_hmac_digest_hex), -1); /* in digests.cpp */
203
- rb_define_module_function(rb_mCryptoPP, "hmac_list", RUBY_METHOD_FUNC(rb_module_hmac_list), 0); /* in digests.cpp */
204
-
205
- rb_define_method(rb_cCryptoPP_Cipher, "rand_iv", RUBY_METHOD_FUNC(rb_cipher_rand_iv), 1); /* in ciphers.cpp */
206
- rb_define_method(rb_cCryptoPP_Cipher, "iv=", RUBY_METHOD_FUNC(rb_cipher_iv_eq), 1); /* in ciphers.cpp */
207
- rb_define_method(rb_cCryptoPP_Cipher, "iv_hex=", RUBY_METHOD_FUNC(rb_cipher_iv_hex_eq), 1); /* in ciphers.cpp */
208
- rb_define_method(rb_cCryptoPP_Cipher, "iv", RUBY_METHOD_FUNC(rb_cipher_iv), 0); /* in ciphers.cpp */
209
- rb_define_method(rb_cCryptoPP_Cipher, "iv_hex", RUBY_METHOD_FUNC(rb_cipher_iv_hex), 0); /* in ciphers.cpp */
210
- rb_define_method(rb_cCryptoPP_Cipher, "block_mode=", RUBY_METHOD_FUNC(rb_cipher_block_mode_eq), 1); /* in ciphers.cpp */
211
- rb_define_method(rb_cCryptoPP_Cipher, "block_mode", RUBY_METHOD_FUNC(rb_cipher_block_mode), 0); /* in ciphers.cpp */
212
- rb_define_method(rb_cCryptoPP_Cipher, "padding=", RUBY_METHOD_FUNC(rb_cipher_padding_eq), 1); /* in ciphers.cpp */
213
- rb_define_method(rb_cCryptoPP_Cipher, "padding", RUBY_METHOD_FUNC(rb_cipher_padding), 0); /* in ciphers.cpp */
214
- rb_define_method(rb_cCryptoPP_Cipher, "rng=", RUBY_METHOD_FUNC(rb_cipher_rng_eq), 1); /* in ciphers.cpp */
215
- rb_define_method(rb_cCryptoPP_Cipher, "rng", RUBY_METHOD_FUNC(rb_cipher_rng), 0); /* in ciphers.cpp */
216
- rb_define_method(rb_cCryptoPP_Cipher, "plaintext=", RUBY_METHOD_FUNC(rb_cipher_plaintext_eq), 1); /* in ciphers.cpp */
217
- rb_define_method(rb_cCryptoPP_Cipher, "plaintext_hex=", RUBY_METHOD_FUNC(rb_cipher_plaintext_hex_eq), 1); /* in ciphers.cpp */
218
- rb_define_method(rb_cCryptoPP_Cipher, "plaintext", RUBY_METHOD_FUNC(rb_cipher_plaintext), 0); /* in ciphers.cpp */
219
- rb_define_method(rb_cCryptoPP_Cipher, "plaintext_hex", RUBY_METHOD_FUNC(rb_cipher_plaintext_hex), 0); /* in ciphers.cpp */
220
- rb_define_method(rb_cCryptoPP_Cipher, "ciphertext=", RUBY_METHOD_FUNC(rb_cipher_ciphertext_eq), 1); /* in ciphers.cpp */
221
- rb_define_method(rb_cCryptoPP_Cipher, "ciphertext_hex=", RUBY_METHOD_FUNC(rb_cipher_ciphertext_hex_eq), 1); /* in ciphers.cpp */
222
- rb_define_method(rb_cCryptoPP_Cipher, "ciphertext", RUBY_METHOD_FUNC(rb_cipher_ciphertext), 0); /* in ciphers.cpp */
223
- rb_define_method(rb_cCryptoPP_Cipher, "ciphertext_hex", RUBY_METHOD_FUNC(rb_cipher_ciphertext_hex), 0); /* in ciphers.cpp */
224
- rb_define_method(rb_cCryptoPP_Cipher, "key=", RUBY_METHOD_FUNC(rb_cipher_key_eq), 1); /* in ciphers.cpp */
225
- rb_define_method(rb_cCryptoPP_Cipher, "key_hex=", RUBY_METHOD_FUNC(rb_cipher_key_hex_eq), 1); /* in ciphers.cpp */
226
- rb_define_method(rb_cCryptoPP_Cipher, "key", RUBY_METHOD_FUNC(rb_cipher_key), 0); /* in ciphers.cpp */
227
- rb_define_method(rb_cCryptoPP_Cipher, "key_hex", RUBY_METHOD_FUNC(rb_cipher_key_hex), 0); /* in ciphers.cpp */
228
- rb_define_method(rb_cCryptoPP_Cipher, "key_length=", RUBY_METHOD_FUNC(rb_cipher_key_length_eq), 1); /* in ciphers.cpp */
229
- rb_define_method(rb_cCryptoPP_Cipher, "key_length", RUBY_METHOD_FUNC(rb_cipher_key_length), 0); /* in ciphers.cpp */
230
- rb_define_method(rb_cCryptoPP_Cipher, "default_key_length", RUBY_METHOD_FUNC(rb_cipher_default_key_length), 0); /* in ciphers.cpp */
231
- rb_define_method(rb_cCryptoPP_Cipher, "max_key_length", RUBY_METHOD_FUNC(rb_cipher_max_key_length), 0); /* in ciphers.cpp */
232
- rb_define_method(rb_cCryptoPP_Cipher, "min_key_length", RUBY_METHOD_FUNC(rb_cipher_min_key_length), 0); /* in ciphers.cpp */
233
- rb_define_method(rb_cCryptoPP_Cipher, "mult_key_length", RUBY_METHOD_FUNC(rb_cipher_mult_key_length), 0); /* in ciphers.cpp */
234
- rb_define_method(rb_cCryptoPP_Cipher, "valid_key_length", RUBY_METHOD_FUNC(rb_cipher_valid_key_length), 1); /* in ciphers.cpp */
235
- # if ENABLED_RC2_CIPHER
236
- rb_define_method(rb_cCryptoPP_Cipher_RC2, "effective_key_length=", RUBY_METHOD_FUNC(rb_cipher_effective_key_length_eq), 1); /* in ciphers.cpp */
237
- rb_define_method(rb_cCryptoPP_Cipher_RC2, "effective_key_length", RUBY_METHOD_FUNC(rb_cipher_effective_key_length), 0); /* in ciphers.cpp */
238
- # endif
239
- rb_define_method(rb_cCryptoPP_Cipher, "block_size", RUBY_METHOD_FUNC(rb_cipher_block_size), 1); /* in ciphers.cpp */
240
- rb_define_method(rb_cCryptoPP_Cipher, "rounds=", RUBY_METHOD_FUNC(rb_cipher_rounds_eq), 1); /* in ciphers.cpp */
241
- rb_define_method(rb_cCryptoPP_Cipher, "rounds", RUBY_METHOD_FUNC(rb_cipher_rounds), 0); /* in ciphers.cpp */
242
- rb_define_method(rb_cCryptoPP_Cipher, "algorithm_name", RUBY_METHOD_FUNC(rb_cipher_algorithm_name), 0); /* in ciphers.cpp */
243
- rb_define_method(rb_cCryptoPP_Cipher, "block_mode_name", RUBY_METHOD_FUNC(rb_cipher_block_mode_name), 0); /* in ciphers.cpp */
244
- rb_define_method(rb_cCryptoPP_Cipher, "padding_name", RUBY_METHOD_FUNC(rb_cipher_padding_name), 0); /* in ciphers.cpp */
245
- rb_define_method(rb_cCryptoPP_Cipher, "rng_name", RUBY_METHOD_FUNC(rb_cipher_rng_name), 0); /* in ciphers.cpp */
246
- rb_define_method(rb_cCryptoPP_Cipher, "cipher_type", RUBY_METHOD_FUNC(rb_cipher_cipher_type), 0); /* in ciphers.cpp */
247
- rb_define_method(rb_cCryptoPP_Cipher, "encrypt", RUBY_METHOD_FUNC(rb_cipher_encrypt), 0); /* in ciphers.cpp */
248
- rb_define_method(rb_cCryptoPP_Cipher, "encrypt_hex", RUBY_METHOD_FUNC(rb_cipher_encrypt_hex), 0); /* in ciphers.cpp */
249
- rb_define_method(rb_cCryptoPP_Cipher, "decrypt", RUBY_METHOD_FUNC(rb_cipher_decrypt), 0); /* in ciphers.cpp */
250
- rb_define_method(rb_cCryptoPP_Cipher, "decrypt_hex", RUBY_METHOD_FUNC(rb_cipher_decrypt_hex), 0); /* in ciphers.cpp */
251
- rb_define_method(rb_cCryptoPP_Cipher, "encrypt_io", RUBY_METHOD_FUNC(rb_cipher_encrypt_io), 2); /* in ciphers.cpp */
252
- rb_define_method(rb_cCryptoPP_Cipher, "decrypt_io", RUBY_METHOD_FUNC(rb_cipher_decrypt_io), 2); /* in ciphers.cpp */
253
-
254
- rb_define_method(rb_cCryptoPP_Digest, "digest", RUBY_METHOD_FUNC(rb_digest_digest), 0); /* in digests.cpp */
255
- rb_define_method(rb_cCryptoPP_Digest, "digest_hex", RUBY_METHOD_FUNC(rb_digest_digest_hex), 0); /* in digests.cpp */
256
- rb_define_method(rb_cCryptoPP_Digest, "digest=", RUBY_METHOD_FUNC(rb_digest_digest_eq), 1); /* in digests.cpp */
257
- rb_define_method(rb_cCryptoPP_Digest, "digest_hex=", RUBY_METHOD_FUNC(rb_digest_digest_hex_eq), 1); /* in digests.cpp */
258
- rb_define_method(rb_cCryptoPP_Digest, "plaintext", RUBY_METHOD_FUNC(rb_digest_plaintext), 0); /* in digests.cpp */
259
- rb_define_method(rb_cCryptoPP_Digest, "plaintext=", RUBY_METHOD_FUNC(rb_digest_plaintext_eq), 1); /* in digests.cpp */
260
- rb_define_method(rb_cCryptoPP_Digest, "plaintext_hex", RUBY_METHOD_FUNC(rb_digest_plaintext_hex), 0); /* in digests.cpp */
261
- rb_define_method(rb_cCryptoPP_Digest, "plaintext_hex=", RUBY_METHOD_FUNC(rb_digest_plaintext_hex_eq), 1); /* in digests.cpp */
262
- rb_define_method(rb_cCryptoPP_Digest, "calculate", RUBY_METHOD_FUNC(rb_digest_calculate), 0); /* in digests.cpp */
263
- rb_define_method(rb_cCryptoPP_Digest, "calculate_hex", RUBY_METHOD_FUNC(rb_digest_calculate_hex), 0); /* in digests.cpp */
264
- rb_define_method(rb_cCryptoPP_Digest, "digest_io", RUBY_METHOD_FUNC(rb_digest_digest_io), 1); /* in digests.cpp */
265
- rb_define_method(rb_cCryptoPP_Digest, "digest_io_hex", RUBY_METHOD_FUNC(rb_digest_digest_io_hex), 1); /* in digests.cpp */
266
- rb_define_method(rb_cCryptoPP_Digest, "update", RUBY_METHOD_FUNC(rb_digest_update), 1); /* in digests.cpp */
267
- rb_define_method(rb_cCryptoPP_Digest, "to_s", RUBY_METHOD_FUNC(rb_digest_digest_hex), 0); /* in digests.cpp */
268
- rb_define_method(rb_cCryptoPP_Digest, "inspect", RUBY_METHOD_FUNC(rb_digest_inspect), 0); /* in digests.cpp */
269
- rb_define_method(rb_cCryptoPP_Digest, "==", RUBY_METHOD_FUNC(rb_digest_equals), 1); /* in digests.cpp */
270
- rb_define_method(rb_cCryptoPP_Digest, "algorithm_name", RUBY_METHOD_FUNC(rb_digest_algorithm_name), 0); /* in digests.cpp */
271
- rb_define_method(rb_cCryptoPP_Digest, "clear", RUBY_METHOD_FUNC(rb_digest_clear), 0); /* in digests.cpp */
272
- rb_define_method(rb_cCryptoPP_Digest, "validate", RUBY_METHOD_FUNC(rb_digest_validate), 0); /* in digests.cpp */
273
-
274
- rb_define_alias(rb_cCryptoPP_Digest, "hexdigest", "digest_hex");
275
- rb_define_alias(rb_cCryptoPP_Digest, "hexdigest=", "digest_hex=");
276
- rb_define_alias(rb_cCryptoPP_Digest, "<<", "update");
277
- rb_define_alias(rb_cCryptoPP_Digest, "valid?", "validate");
278
-
279
- rb_define_method(rb_cCryptoPP_Digest_HMAC, "key=", RUBY_METHOD_FUNC(rb_digest_hmac_key_eq), 1); /* in digests.cpp */
280
- rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_hex=", RUBY_METHOD_FUNC(rb_digest_hmac_key_hex_eq), 1); /* in digests.cpp */
281
- rb_define_method(rb_cCryptoPP_Digest_HMAC, "key", RUBY_METHOD_FUNC(rb_digest_hmac_key), 0); /* in digests.cpp */
282
- rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_hex", RUBY_METHOD_FUNC(rb_digest_hmac_key_hex), 0); /* in digests.cpp */
283
- rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_length=", RUBY_METHOD_FUNC(rb_digest_hmac_key_length_eq), 1); /* in digests.cpp */
284
- rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_length", RUBY_METHOD_FUNC(rb_digest_hmac_key_length), 0); /* in digests.cpp */
83
+ /**
84
+ * This is the main CryptoPP module. All of the various Cipher, Digest
85
+ * and HMAC classes are found here.
86
+ *
87
+ * The CryptoPP module contains a handful of module methods that can be
88
+ * used to create new ciphers, digests and HMACs and provide information
89
+ * on the environment and configuration CryptoPP is running with.
90
+ */
91
+ rb_mCryptoPP = rb_define_module("CryptoPP");
92
+
93
+ /**
94
+ * Exception class.
95
+ */
96
+ rb_eCryptoPP_Error = rb_define_class_under(rb_mCryptoPP, "CryptoPPError", rb_eStandardError);
97
+
98
+ /**
99
+ * The base cipher class. This class is not meant to be used directly. It
100
+ * merely serves as the base class for all CryptoPP ciphers.
101
+ *
102
+ * Ciphers can be created either by using the
103
+ * <tt>CryptoPP#cipher_factory</tt> factory method or by instantiating
104
+ * the classes directly. For instance, the following are equivalent:
105
+ *
106
+ * cipher = CryptoPP.cipher_factory(:aes)
107
+ * cipher = CryptoPP::AES.new
108
+ *
109
+ * Options include:
110
+ *
111
+ * * <tt>:plaintext</tt> and <tt>:plaintext_hex</tt> - set the plaintext. You
112
+ * can only use one at a time.
113
+ * * <tt>:ciphertext</tt> and <tt>:ciphertext_hex</tt> - set the ciphertext.
114
+ * You can only use one at a time.
115
+ * * <tt>:key</tt> and <tt>:key_hex</tt> - set the key. You can only use one
116
+ * at a time.
117
+ * * <tt>:key_length</tt> - set the length of the key. Normally this is done
118
+ * automatically, but you can force a different key length if necessary.
119
+ * * <tt>:effective_key_length</tt> - sets the effective key length on RC2
120
+ * ciphers.
121
+ * * <tt>:rounds</tt> - sets the number of rounds a cipher performs on
122
+ * block ciphers that support them.
123
+ * * <tt>:rng</tt> - sets the random number generator to be used for things
124
+ * like creating initialization vectors and such. Not all operating
125
+ * systems and environments will support all RNGs. You can check which
126
+ * ones are supported with <tt>CryptoPP#rng_available?</tt>. Possible
127
+ * values are :blocking, :non_blocking and :rand.
128
+ *
129
+ * All of these options have their equivalent setter and getter methods
130
+ * if you need to modify them after initialization.
131
+ */
132
+ rb_cCryptoPP_Cipher = rb_define_class_under(rb_mCryptoPP, "Cipher", rb_cObject);
133
+
134
+ /**
135
+ * The base Digest class. This class is not meant to be used directly. It
136
+ * merely serves as the base class for all CryptoPP Digests and HMACs.
137
+ */
138
+ rb_cCryptoPP_Digest = rb_define_class_under(rb_mCryptoPP, "Digest", rb_cObject);
139
+
140
+ /**
141
+ * The base HMAC class. This class is not meant to be used directly. It
142
+ * merely serves as the base class for all CryptoPP HMACs.
143
+ */
144
+ rb_cCryptoPP_Digest_HMAC = rb_define_class_under(rb_mCryptoPP, "HMAC", rb_cCryptoPP_Digest);
145
+
146
+ rb_undef_alloc_func(rb_cCryptoPP_Cipher);
147
+ rb_undef_alloc_func(rb_cCryptoPP_Digest);
148
+ rb_undef_alloc_func(rb_cCryptoPP_Digest_HMAC);
149
+
150
+ # define XCRYPTOPP_EXT_VERSION(s) #s
151
+ # define CRYPTOPP_EXT_VERSION(s) XCRYPTOPP_EXT_VERSION(s)
152
+
153
+ rb_define_const(rb_mCryptoPP, "VERSION", rb_str_new2(CRYPTOPP_EXT_VERSION(EXT_VERSION_CODE)));
154
+ rb_define_const(rb_mCryptoPP, "CRYPTOPP_VERSION", INT2NUM(CRYPTOPP_VERSION));
155
+
156
+ # define CIPHER_ALGORITHM_X(klass, r, c, s) \
157
+ rb_cCryptoPP_Cipher_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Cipher); \
158
+ rb_define_singleton_method((rb_cCryptoPP_Cipher_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_cipher_ ## r ##_new), -1);
159
+ # include "defs/ciphers.def"
160
+
161
+ # define CHECKSUM_ALGORITHM_X(klass, r, c, s) \
162
+ rb_cCryptoPP_Digest_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Digest); \
163
+ rb_define_singleton_method((rb_cCryptoPP_Digest_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_digest_ ## r ##_new), -1);
164
+ # include "defs/checksums.def"
165
+
166
+ # define HASH_ALGORITHM_X(klass, r, c, s) \
167
+ rb_cCryptoPP_Digest_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Digest); \
168
+ rb_define_singleton_method((rb_cCryptoPP_Digest_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_digest_ ## r ##_new), -1);
169
+ # include "defs/hashes.def"
170
+
171
+ # define HMAC_ALGORITHM_X(klass, r, c, s) \
172
+ rb_cCryptoPP_Digest_HMAC_ ## r = rb_define_class_under(rb_mCryptoPP, # klass, rb_cCryptoPP_Digest_HMAC); \
173
+ rb_define_singleton_method((rb_cCryptoPP_Digest_HMAC_ ## r), "new", CRYPTOPP_VALUE_FUNC(rb_digest_hmac_ ## r ##_new), -1);
174
+ # include "defs/hmacs.def"
175
+
176
+ rb_define_module_function(rb_mCryptoPP, "cipher_list", RUBY_METHOD_FUNC(rb_module_cipher_list), 0); /* in ciphers.cpp */
177
+ rb_define_module_function(rb_mCryptoPP, "cipher_name", RUBY_METHOD_FUNC(rb_module_cipher_name), 1); /* in ciphers.cpp */
178
+ rb_define_module_function(rb_mCryptoPP, "block_mode_name", RUBY_METHOD_FUNC(rb_module_block_mode_name), 1); /* in ciphers.cpp */
179
+ rb_define_module_function(rb_mCryptoPP, "padding_name", RUBY_METHOD_FUNC(rb_module_padding_name), 1); /* in ciphers.cpp */
180
+ rb_define_module_function(rb_mCryptoPP, "rng_name", RUBY_METHOD_FUNC(rb_module_rng_name), 1); /* in ciphers.cpp */
181
+ rb_define_module_function(rb_mCryptoPP, "cipher_enabled?", RUBY_METHOD_FUNC(rb_module_cipher_enabled), 1); /* in ciphers.cpp */
182
+ rb_define_module_function(rb_mCryptoPP, "rng_available?", RUBY_METHOD_FUNC(rb_module_rng_available), 1); /* in ciphers.cpp */
183
+
184
+ rb_define_module_function(rb_mCryptoPP, "cipher_factory", RUBY_METHOD_FUNC(rb_module_cipher_factory), -1); /* in ciphers.cpp */
185
+ rb_define_module_function(rb_mCryptoPP, "digest_factory", RUBY_METHOD_FUNC(rb_module_digest_factory), -1); /* in digests.cpp */
186
+ rb_define_module_function(rb_mCryptoPP, "hmac_factory", RUBY_METHOD_FUNC(rb_module_hmac_factory), -1); /* in digests.cpp */
187
+
188
+ rb_define_module_function(rb_mCryptoPP, "digest_enabled?", RUBY_METHOD_FUNC(rb_module_digest_enabled), 1); /* in digests.cpp */
189
+ rb_define_module_function(rb_mCryptoPP, "digest_name", RUBY_METHOD_FUNC(rb_module_digest_name), 1); /* in digests.cpp */
190
+ rb_define_module_function(rb_mCryptoPP, "digest_list", RUBY_METHOD_FUNC(rb_module_digest_list), 0); /* in digests.cpp */
191
+
192
+ rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hash_enabled?", "digest_enabled?");
193
+ rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hash_name", "digest_name");
194
+ rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hash_list", "digest_list");
195
+
196
+ rb_define_module_function(rb_mCryptoPP, "digest", RUBY_METHOD_FUNC(rb_module_digest), -1); /* in digests.cpp */
197
+ rb_define_module_function(rb_mCryptoPP, "digest_hex", RUBY_METHOD_FUNC(rb_module_digest_hex), -1); /* in digests.cpp */
198
+
199
+ rb_define_alias(rb_singleton_class(rb_mCryptoPP), "hexdigest", "digest_hex");
200
+
201
+ rb_define_module_function(rb_mCryptoPP, "digest_io", RUBY_METHOD_FUNC(rb_module_digest_io), -1); /* in digests.cpp */
202
+ rb_define_module_function(rb_mCryptoPP, "digest_io_hex", RUBY_METHOD_FUNC(rb_module_digest_io_hex), -1); /* in digests.cpp */
203
+
204
+ rb_define_module_function(rb_mCryptoPP, "digest_hmac", RUBY_METHOD_FUNC(rb_module_hmac_digest), -1); /* in digests.cpp */
205
+ rb_define_module_function(rb_mCryptoPP, "digest_hmac_hex", RUBY_METHOD_FUNC(rb_module_hmac_digest_hex), -1); /* in digests.cpp */
206
+ rb_define_module_function(rb_mCryptoPP, "hmac_list", RUBY_METHOD_FUNC(rb_module_hmac_list), 0); /* in digests.cpp */
207
+
208
+ rb_define_method(rb_cCryptoPP_Cipher, "rand_iv", RUBY_METHOD_FUNC(rb_cipher_rand_iv), 1); /* in ciphers.cpp */
209
+ rb_define_method(rb_cCryptoPP_Cipher, "iv=", RUBY_METHOD_FUNC(rb_cipher_iv_eq), 1); /* in ciphers.cpp */
210
+ rb_define_method(rb_cCryptoPP_Cipher, "iv_hex=", RUBY_METHOD_FUNC(rb_cipher_iv_hex_eq), 1); /* in ciphers.cpp */
211
+ rb_define_method(rb_cCryptoPP_Cipher, "iv", RUBY_METHOD_FUNC(rb_cipher_iv), 0); /* in ciphers.cpp */
212
+ rb_define_method(rb_cCryptoPP_Cipher, "iv_hex", RUBY_METHOD_FUNC(rb_cipher_iv_hex), 0); /* in ciphers.cpp */
213
+ rb_define_method(rb_cCryptoPP_Cipher, "block_mode=", RUBY_METHOD_FUNC(rb_cipher_block_mode_eq), 1); /* in ciphers.cpp */
214
+ rb_define_method(rb_cCryptoPP_Cipher, "block_mode", RUBY_METHOD_FUNC(rb_cipher_block_mode), 0); /* in ciphers.cpp */
215
+ rb_define_method(rb_cCryptoPP_Cipher, "padding=", RUBY_METHOD_FUNC(rb_cipher_padding_eq), 1); /* in ciphers.cpp */
216
+ rb_define_method(rb_cCryptoPP_Cipher, "padding", RUBY_METHOD_FUNC(rb_cipher_padding), 0); /* in ciphers.cpp */
217
+ rb_define_method(rb_cCryptoPP_Cipher, "rng=", RUBY_METHOD_FUNC(rb_cipher_rng_eq), 1); /* in ciphers.cpp */
218
+ rb_define_method(rb_cCryptoPP_Cipher, "rng", RUBY_METHOD_FUNC(rb_cipher_rng), 0); /* in ciphers.cpp */
219
+ rb_define_method(rb_cCryptoPP_Cipher, "plaintext=", RUBY_METHOD_FUNC(rb_cipher_plaintext_eq), 1); /* in ciphers.cpp */
220
+ rb_define_method(rb_cCryptoPP_Cipher, "plaintext_hex=", RUBY_METHOD_FUNC(rb_cipher_plaintext_hex_eq), 1); /* in ciphers.cpp */
221
+ rb_define_method(rb_cCryptoPP_Cipher, "plaintext", RUBY_METHOD_FUNC(rb_cipher_plaintext), 0); /* in ciphers.cpp */
222
+ rb_define_method(rb_cCryptoPP_Cipher, "plaintext_hex", RUBY_METHOD_FUNC(rb_cipher_plaintext_hex), 0); /* in ciphers.cpp */
223
+ rb_define_method(rb_cCryptoPP_Cipher, "ciphertext=", RUBY_METHOD_FUNC(rb_cipher_ciphertext_eq), 1); /* in ciphers.cpp */
224
+ rb_define_method(rb_cCryptoPP_Cipher, "ciphertext_hex=", RUBY_METHOD_FUNC(rb_cipher_ciphertext_hex_eq), 1); /* in ciphers.cpp */
225
+ rb_define_method(rb_cCryptoPP_Cipher, "ciphertext", RUBY_METHOD_FUNC(rb_cipher_ciphertext), 0); /* in ciphers.cpp */
226
+ rb_define_method(rb_cCryptoPP_Cipher, "ciphertext_hex", RUBY_METHOD_FUNC(rb_cipher_ciphertext_hex), 0); /* in ciphers.cpp */
227
+ rb_define_method(rb_cCryptoPP_Cipher, "key=", RUBY_METHOD_FUNC(rb_cipher_key_eq), 1); /* in ciphers.cpp */
228
+ rb_define_method(rb_cCryptoPP_Cipher, "key_hex=", RUBY_METHOD_FUNC(rb_cipher_key_hex_eq), 1); /* in ciphers.cpp */
229
+ rb_define_method(rb_cCryptoPP_Cipher, "key", RUBY_METHOD_FUNC(rb_cipher_key), 0); /* in ciphers.cpp */
230
+ rb_define_method(rb_cCryptoPP_Cipher, "key_hex", RUBY_METHOD_FUNC(rb_cipher_key_hex), 0); /* in ciphers.cpp */
231
+ rb_define_method(rb_cCryptoPP_Cipher, "key_length=", RUBY_METHOD_FUNC(rb_cipher_key_length_eq), 1); /* in ciphers.cpp */
232
+ rb_define_method(rb_cCryptoPP_Cipher, "key_length", RUBY_METHOD_FUNC(rb_cipher_key_length), 0); /* in ciphers.cpp */
233
+ rb_define_method(rb_cCryptoPP_Cipher, "default_key_length", RUBY_METHOD_FUNC(rb_cipher_default_key_length), 0); /* in ciphers.cpp */
234
+ rb_define_method(rb_cCryptoPP_Cipher, "max_key_length", RUBY_METHOD_FUNC(rb_cipher_max_key_length), 0); /* in ciphers.cpp */
235
+ rb_define_method(rb_cCryptoPP_Cipher, "min_key_length", RUBY_METHOD_FUNC(rb_cipher_min_key_length), 0); /* in ciphers.cpp */
236
+ rb_define_method(rb_cCryptoPP_Cipher, "mult_key_length", RUBY_METHOD_FUNC(rb_cipher_mult_key_length), 0); /* in ciphers.cpp */
237
+ rb_define_method(rb_cCryptoPP_Cipher, "valid_key_length", RUBY_METHOD_FUNC(rb_cipher_valid_key_length), 1); /* in ciphers.cpp */
238
+ # if ENABLED_RC2_CIPHER
239
+ rb_define_method(rb_cCryptoPP_Cipher_RC2, "effective_key_length=", RUBY_METHOD_FUNC(rb_cipher_effective_key_length_eq), 1); /* in ciphers.cpp */
240
+ rb_define_method(rb_cCryptoPP_Cipher_RC2, "effective_key_length", RUBY_METHOD_FUNC(rb_cipher_effective_key_length), 0); /* in ciphers.cpp */
241
+ # endif
242
+ rb_define_method(rb_cCryptoPP_Cipher, "block_size", RUBY_METHOD_FUNC(rb_cipher_block_size), 1); /* in ciphers.cpp */
243
+ rb_define_method(rb_cCryptoPP_Cipher, "rounds=", RUBY_METHOD_FUNC(rb_cipher_rounds_eq), 1); /* in ciphers.cpp */
244
+ rb_define_method(rb_cCryptoPP_Cipher, "rounds", RUBY_METHOD_FUNC(rb_cipher_rounds), 0); /* in ciphers.cpp */
245
+ rb_define_method(rb_cCryptoPP_Cipher, "algorithm_name", RUBY_METHOD_FUNC(rb_cipher_algorithm_name), 0); /* in ciphers.cpp */
246
+ rb_define_method(rb_cCryptoPP_Cipher, "block_mode_name", RUBY_METHOD_FUNC(rb_cipher_block_mode_name), 0); /* in ciphers.cpp */
247
+ rb_define_method(rb_cCryptoPP_Cipher, "padding_name", RUBY_METHOD_FUNC(rb_cipher_padding_name), 0); /* in ciphers.cpp */
248
+ rb_define_method(rb_cCryptoPP_Cipher, "rng_name", RUBY_METHOD_FUNC(rb_cipher_rng_name), 0); /* in ciphers.cpp */
249
+ rb_define_method(rb_cCryptoPP_Cipher, "cipher_type", RUBY_METHOD_FUNC(rb_cipher_cipher_type), 0); /* in ciphers.cpp */
250
+ rb_define_method(rb_cCryptoPP_Cipher, "encrypt", RUBY_METHOD_FUNC(rb_cipher_encrypt), 0); /* in ciphers.cpp */
251
+ rb_define_method(rb_cCryptoPP_Cipher, "encrypt_hex", RUBY_METHOD_FUNC(rb_cipher_encrypt_hex), 0); /* in ciphers.cpp */
252
+ rb_define_method(rb_cCryptoPP_Cipher, "decrypt", RUBY_METHOD_FUNC(rb_cipher_decrypt), 0); /* in ciphers.cpp */
253
+ rb_define_method(rb_cCryptoPP_Cipher, "decrypt_hex", RUBY_METHOD_FUNC(rb_cipher_decrypt_hex), 0); /* in ciphers.cpp */
254
+ rb_define_method(rb_cCryptoPP_Cipher, "encrypt_io", RUBY_METHOD_FUNC(rb_cipher_encrypt_io), 2); /* in ciphers.cpp */
255
+ rb_define_method(rb_cCryptoPP_Cipher, "decrypt_io", RUBY_METHOD_FUNC(rb_cipher_decrypt_io), 2); /* in ciphers.cpp */
256
+
257
+ rb_define_method(rb_cCryptoPP_Digest, "digest", RUBY_METHOD_FUNC(rb_digest_digest), 0); /* in digests.cpp */
258
+ rb_define_method(rb_cCryptoPP_Digest, "digest_hex", RUBY_METHOD_FUNC(rb_digest_digest_hex), 0); /* in digests.cpp */
259
+ rb_define_method(rb_cCryptoPP_Digest, "digest=", RUBY_METHOD_FUNC(rb_digest_digest_eq), 1); /* in digests.cpp */
260
+ rb_define_method(rb_cCryptoPP_Digest, "digest_hex=", RUBY_METHOD_FUNC(rb_digest_digest_hex_eq), 1); /* in digests.cpp */
261
+ rb_define_method(rb_cCryptoPP_Digest, "plaintext", RUBY_METHOD_FUNC(rb_digest_plaintext), 0); /* in digests.cpp */
262
+ rb_define_method(rb_cCryptoPP_Digest, "plaintext=", RUBY_METHOD_FUNC(rb_digest_plaintext_eq), 1); /* in digests.cpp */
263
+ rb_define_method(rb_cCryptoPP_Digest, "plaintext_hex", RUBY_METHOD_FUNC(rb_digest_plaintext_hex), 0); /* in digests.cpp */
264
+ rb_define_method(rb_cCryptoPP_Digest, "plaintext_hex=", RUBY_METHOD_FUNC(rb_digest_plaintext_hex_eq), 1); /* in digests.cpp */
265
+ rb_define_method(rb_cCryptoPP_Digest, "calculate", RUBY_METHOD_FUNC(rb_digest_calculate), 0); /* in digests.cpp */
266
+ rb_define_method(rb_cCryptoPP_Digest, "calculate_hex", RUBY_METHOD_FUNC(rb_digest_calculate_hex), 0); /* in digests.cpp */
267
+ rb_define_method(rb_cCryptoPP_Digest, "digest_io", RUBY_METHOD_FUNC(rb_digest_digest_io), 1); /* in digests.cpp */
268
+ rb_define_method(rb_cCryptoPP_Digest, "digest_io_hex", RUBY_METHOD_FUNC(rb_digest_digest_io_hex), 1); /* in digests.cpp */
269
+ rb_define_method(rb_cCryptoPP_Digest, "update", RUBY_METHOD_FUNC(rb_digest_update), 1); /* in digests.cpp */
270
+ rb_define_method(rb_cCryptoPP_Digest, "to_s", RUBY_METHOD_FUNC(rb_digest_digest_hex), 0); /* in digests.cpp */
271
+ rb_define_method(rb_cCryptoPP_Digest, "inspect", RUBY_METHOD_FUNC(rb_digest_inspect), 0); /* in digests.cpp */
272
+ rb_define_method(rb_cCryptoPP_Digest, "==", RUBY_METHOD_FUNC(rb_digest_equals), 1); /* in digests.cpp */
273
+ rb_define_method(rb_cCryptoPP_Digest, "algorithm_name", RUBY_METHOD_FUNC(rb_digest_algorithm_name), 0); /* in digests.cpp */
274
+ rb_define_method(rb_cCryptoPP_Digest, "clear", RUBY_METHOD_FUNC(rb_digest_clear), 0); /* in digests.cpp */
275
+ rb_define_method(rb_cCryptoPP_Digest, "validate", RUBY_METHOD_FUNC(rb_digest_validate), 0); /* in digests.cpp */
276
+
277
+ rb_define_alias(rb_cCryptoPP_Digest, "hexdigest", "digest_hex");
278
+ rb_define_alias(rb_cCryptoPP_Digest, "hexdigest=", "digest_hex=");
279
+ rb_define_alias(rb_cCryptoPP_Digest, "<<", "update");
280
+ rb_define_alias(rb_cCryptoPP_Digest, "valid?", "validate");
281
+
282
+ rb_define_method(rb_cCryptoPP_Digest_HMAC, "key=", RUBY_METHOD_FUNC(rb_digest_hmac_key_eq), 1); /* in digests.cpp */
283
+ rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_hex=", RUBY_METHOD_FUNC(rb_digest_hmac_key_hex_eq), 1); /* in digests.cpp */
284
+ rb_define_method(rb_cCryptoPP_Digest_HMAC, "key", RUBY_METHOD_FUNC(rb_digest_hmac_key), 0); /* in digests.cpp */
285
+ rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_hex", RUBY_METHOD_FUNC(rb_digest_hmac_key_hex), 0); /* in digests.cpp */
286
+ rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_length=", RUBY_METHOD_FUNC(rb_digest_hmac_key_length_eq), 1); /* in digests.cpp */
287
+ rb_define_method(rb_cCryptoPP_Digest_HMAC, "key_length", RUBY_METHOD_FUNC(rb_digest_hmac_key_length), 0); /* in digests.cpp */
285
288
  }