@@ -25,32 +25,50 @@ static const rb_digest_metadata_t sha##bitlen = { \
25
25
FOREACH_BITLEN (DEFINE_ALGO_METADATA )
26
26
27
27
/*
28
+ * Document-class: Digest::SHA256 < Digest::Base
29
+ *
28
30
* Classes for calculating message digests using the SHA-256/384/512
29
31
* Secure Hash Algorithm(s) by NIST (the US' National Institute of
30
32
* Standards and Technology), described in FIPS PUB 180-2.
33
+ *
34
+ * See SHA2.
35
+ */
36
+ /*
37
+ * Document-class: Digest::SHA384 < Digest::Base
38
+ *
39
+ * Classes for calculating message digests using the SHA-256/384/512
40
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
41
+ * Standards and Technology), described in FIPS PUB 180-2.
42
+ *
43
+ * See SHA2.
44
+ */
45
+ /*
46
+ * Document-class: Digest::SHA512 < Digest::Base
47
+ *
48
+ * Classes for calculating message digests using the SHA-256/384/512
49
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
50
+ * Standards and Technology), described in FIPS PUB 180-2.
51
+ *
52
+ * See SHA2.
31
53
*/
32
54
void
33
55
Init_sha2 (void )
34
56
{
35
- VALUE mDigest , cDigest_Base ;
57
+ VALUE mDigest , cDigest_Base , cDigest_SHA2 ;
36
58
ID id_metadata = rb_id_metadata ();
37
59
38
- #define DECLARE_ALGO_CLASS (bitlen ) \
39
- VALUE cDigest_SHA##bitlen;
40
-
41
- FOREACH_BITLEN (DECLARE_ALGO_CLASS )
42
-
43
60
#if 0
44
61
mDigest = rb_define_module ("Digest" ); /* let rdoc know */
45
62
#endif
46
63
mDigest = rb_digest_namespace ();
47
64
cDigest_Base = rb_const_get (mDigest , rb_intern_const ("Base" ));
48
65
49
- #define DEFINE_ALGO_CLASS ( bitlen ) \
50
- cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
51
- \
52
- rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
53
- rb_digest_make_metadata(&sha##bitlen ));
66
+ cDigest_SHA2 = rb_define_class_under ( mDigest , "SHA256" , cDigest_Base );
67
+ rb_ivar_set ( cDigest_SHA2 , id_metadata , rb_digest_make_metadata ( & sha256 ));
68
+
69
+ cDigest_SHA2 = rb_define_class_under ( mDigest , "SHA384" , cDigest_Base );
70
+ rb_ivar_set ( cDigest_SHA2 , id_metadata , rb_digest_make_metadata (& sha384 ));
54
71
55
- FOREACH_BITLEN (DEFINE_ALGO_CLASS )
72
+ cDigest_SHA2 = rb_define_class_under (mDigest , "SHA512" , cDigest_Base );
73
+ rb_ivar_set (cDigest_SHA2 , id_metadata , rb_digest_make_metadata (& sha512 ));
56
74
}
0 commit comments