mhash 1.0 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/README.md +97 -0
- data/ext/mhash/extconf.rb +4 -1
- data/ext/mhash/mhash.c +2 -4
- data/ext/mhash/mhash_ruby.h +6 -0
- data/ext/mhash/module_definitions.c +26 -0
- data/ext/mhash/module_definitions.h +1 -1
- data/ext/mhash/module_functions.c +254 -4
- data/ext/mhash/module_functions.h +50 -0
- data/lib/mhash.rb +1 -1
- data/mhash.gemspec +1 -1
- data/test/test_mhash.rb +71 -11
- metadata +5 -4
- data/ext/mhash/Makefile +0 -187
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# ruby-mhash [](https://travis-ci.org/TibshoOT/ruby-mhash)
|
2
|
+
|
3
|
+
Mhash wrapping library for Ruby.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
You need mhash libray installed.
|
8
|
+
|
9
|
+
### Debian/Ubuntu
|
10
|
+
|
11
|
+
$ sudo apt-get install libmhash-dev
|
12
|
+
|
13
|
+
### FreeBSD (using ports)
|
14
|
+
|
15
|
+
# cd /usr/ports/security/mhash
|
16
|
+
# make install
|
17
|
+
|
18
|
+
### Rubies
|
19
|
+
|
20
|
+
Tested with Ruby:
|
21
|
+
|
22
|
+
* 1.8.7
|
23
|
+
* 1.9.2
|
24
|
+
* 1.9.3
|
25
|
+
* 2.0.0-preview1
|
26
|
+
|
27
|
+
You have to setup rubygems.
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
gem install mhash
|
32
|
+
|
33
|
+
or for development:
|
34
|
+
|
35
|
+
git clone https://github.com/TibshoOT/ruby-mhash.git
|
36
|
+
cd ruby-mhash/etx/mhash
|
37
|
+
[edit source files]
|
38
|
+
ruby extconf.rb
|
39
|
+
make
|
40
|
+
irb -r ./mhash.so
|
41
|
+
[test it !]
|
42
|
+
|
43
|
+
|
44
|
+
## Documentation
|
45
|
+
|
46
|
+
Just require mhash library and go !
|
47
|
+
|
48
|
+
Mhash's module functions are explicit...
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
|
52
|
+
require 'mhash'
|
53
|
+
|
54
|
+
Mhash.gost("this is a test !")
|
55
|
+
Mhash.crc32("this is a test !")
|
56
|
+
Mhash.md5("this is a test !")
|
57
|
+
Mhash.sha1("this is a test !")
|
58
|
+
Mhash.haval256("this is a test !")
|
59
|
+
Mhash.ripemd160("this is a test !")
|
60
|
+
Mhash.tiger192("this is a test !")
|
61
|
+
Mhash.gost("this is a test !")
|
62
|
+
Mhash.crc32b("this is a test !")
|
63
|
+
Mhash.haval224("this is a test !")
|
64
|
+
Mhash.haval192("this is a test !")
|
65
|
+
Mhash.haval160("this is a test !")
|
66
|
+
Mhash.haval128("this is a test !")
|
67
|
+
Mhash.tiger128("this is a test !")
|
68
|
+
Mhash.tiger160("this is a test !")
|
69
|
+
Mhash.sha256("this is a test !")
|
70
|
+
Mhash.adler32("this is a test !")
|
71
|
+
Mhash.sha224("this is a test !")
|
72
|
+
Mhash.sha512("this is a test !")
|
73
|
+
Mhash.sha384("this is a test !")
|
74
|
+
Mhash.whirlpool("this is a test !")
|
75
|
+
Mhash.ripemd128("this is a test !")
|
76
|
+
Mhash.ripemd256("this is a test !")
|
77
|
+
Mhash.ripemd320("this is a test !")
|
78
|
+
Mhash.snefru128("this is a test !")
|
79
|
+
Mhash.snefru256("this is a test !")
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
At this time, these functions return byte encoded string but if you want an hexdigest, you can do this:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
|
87
|
+
require 'mhash'
|
88
|
+
|
89
|
+
hash = Mhash.gost("this is a test !").unpack("H*").first
|
90
|
+
|
91
|
+
```
|
92
|
+
|
93
|
+
In the next release of mhash gem, you will be able to get hexdigest directly.
|
94
|
+
|
95
|
+
## Want a feature ? Problem ?
|
96
|
+
|
97
|
+
Open an issue ;)
|
data/ext/mhash/extconf.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
3
|
+
have_header('ruby.h') or raise "ruby.h did't find. Did you install ruby environment development ?"
|
4
|
+
have_header('mhash.h') or raise "mhash.h did't find. Check your libmhash setup."
|
5
|
+
have_library('mhash') or raise "libmhash did't find. Install it."
|
6
|
+
|
4
7
|
create_makefile('mhash/mhash')
|
data/ext/mhash/mhash.c
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <mhash.h>
|
3
|
+
#include "mhash_ruby.h"
|
3
4
|
#include "module_definitions.h"
|
4
5
|
|
5
|
-
void Init_mhash();
|
6
|
-
static VALUE m_mhash;
|
7
|
-
|
8
6
|
void Init_mhash()
|
9
7
|
{
|
10
|
-
|
8
|
+
VALUE m_mhash;
|
11
9
|
|
12
10
|
m_mhash = rb_define_module("Mhash");
|
13
11
|
|
@@ -34,29 +34,55 @@ void mhash_define_consts(VALUE *m_mhash)
|
|
34
34
|
void mhash_define_functions(VALUE *m_mhash)
|
35
35
|
{
|
36
36
|
rb_define_module_function(*m_mhash, "digest", mhash_rb_digest, 2);
|
37
|
+
rb_define_module_function(*m_mhash, "hexdigest", mhash_rb_hexdigest, 1);
|
37
38
|
rb_define_module_function(*m_mhash, "crc32", mhash_rb_crc32, 1);
|
39
|
+
rb_define_module_function(*m_mhash, "crc32!", mhash_rb_crc32_hex, 1);
|
38
40
|
rb_define_module_function(*m_mhash, "md5", mhash_rb_md5, 1);
|
41
|
+
rb_define_module_function(*m_mhash, "md5!", mhash_rb_md5_hex, 1);
|
39
42
|
rb_define_module_function(*m_mhash, "sha1", mhash_rb_sha1, 1);
|
43
|
+
rb_define_module_function(*m_mhash, "sha1!", mhash_rb_sha1_hex, 1);
|
40
44
|
rb_define_module_function(*m_mhash, "haval256", mhash_rb_haval256, 1);
|
45
|
+
rb_define_module_function(*m_mhash, "haval256!", mhash_rb_haval256_hex, 1);
|
41
46
|
rb_define_module_function(*m_mhash, "ripemd160", mhash_rb_ripemd160, 1);
|
47
|
+
rb_define_module_function(*m_mhash, "ripemd160!", mhash_rb_ripemd160_hex, 1);
|
42
48
|
rb_define_module_function(*m_mhash, "tiger192", mhash_rb_tiger192, 1);
|
49
|
+
rb_define_module_function(*m_mhash, "tiger192!", mhash_rb_tiger192_hex, 1);
|
43
50
|
rb_define_module_function(*m_mhash, "gost", mhash_rb_gost, 1);
|
51
|
+
rb_define_module_function(*m_mhash, "gost!", mhash_rb_gost_hex, 1);
|
44
52
|
rb_define_module_function(*m_mhash, "crc32b", mhash_rb_crc32b, 1);
|
53
|
+
rb_define_module_function(*m_mhash, "crc32b!", mhash_rb_crc32b_hex, 1);
|
45
54
|
rb_define_module_function(*m_mhash, "haval224", mhash_rb_haval224, 1);
|
55
|
+
rb_define_module_function(*m_mhash, "haval224!", mhash_rb_haval224_hex, 1);
|
46
56
|
rb_define_module_function(*m_mhash, "haval192", mhash_rb_haval192, 1);
|
57
|
+
rb_define_module_function(*m_mhash, "haval192!", mhash_rb_haval192_hex, 1);
|
47
58
|
rb_define_module_function(*m_mhash, "haval160", mhash_rb_haval160, 1);
|
59
|
+
rb_define_module_function(*m_mhash, "haval160!", mhash_rb_haval160_hex, 1);
|
48
60
|
rb_define_module_function(*m_mhash, "haval128", mhash_rb_haval128, 1);
|
61
|
+
rb_define_module_function(*m_mhash, "haval128!", mhash_rb_haval128_hex, 1);
|
49
62
|
rb_define_module_function(*m_mhash, "tiger128", mhash_rb_tiger128, 1);
|
63
|
+
rb_define_module_function(*m_mhash, "tiger128!", mhash_rb_tiger128_hex, 1);
|
50
64
|
rb_define_module_function(*m_mhash, "tiger160", mhash_rb_tiger160, 1);
|
65
|
+
rb_define_module_function(*m_mhash, "tiger160!", mhash_rb_tiger160_hex, 1);
|
51
66
|
rb_define_module_function(*m_mhash, "sha256", mhash_rb_sha256, 1);
|
67
|
+
rb_define_module_function(*m_mhash, "sha256!", mhash_rb_sha256_hex, 1);
|
52
68
|
rb_define_module_function(*m_mhash, "adler32", mhash_rb_adler32, 1);
|
69
|
+
rb_define_module_function(*m_mhash, "adler32!", mhash_rb_adler32_hex, 1);
|
53
70
|
rb_define_module_function(*m_mhash, "sha224", mhash_rb_sha224, 1);
|
71
|
+
rb_define_module_function(*m_mhash, "sha224!", mhash_rb_sha224_hex, 1);
|
54
72
|
rb_define_module_function(*m_mhash, "sha512", mhash_rb_sha512, 1);
|
73
|
+
rb_define_module_function(*m_mhash, "sha512!", mhash_rb_sha512_hex, 1);
|
55
74
|
rb_define_module_function(*m_mhash, "sha384", mhash_rb_sha384, 1);
|
75
|
+
rb_define_module_function(*m_mhash, "sha384!", mhash_rb_sha384_hex, 1);
|
56
76
|
rb_define_module_function(*m_mhash, "whirlpool", mhash_rb_whirlpool, 1);
|
77
|
+
rb_define_module_function(*m_mhash, "whirlpool!", mhash_rb_whirlpool_hex, 1);
|
57
78
|
rb_define_module_function(*m_mhash, "ripemd128", mhash_rb_ripemd128, 1);
|
79
|
+
rb_define_module_function(*m_mhash, "ripemd128!", mhash_rb_ripemd128_hex, 1);
|
58
80
|
rb_define_module_function(*m_mhash, "ripemd256", mhash_rb_ripemd256, 1);
|
81
|
+
rb_define_module_function(*m_mhash, "ripemd256!", mhash_rb_ripemd256_hex, 1);
|
59
82
|
rb_define_module_function(*m_mhash, "ripemd320", mhash_rb_ripemd320, 1);
|
83
|
+
rb_define_module_function(*m_mhash, "ripemd320!", mhash_rb_ripemd320_hex, 1);
|
60
84
|
rb_define_module_function(*m_mhash, "snefru128", mhash_rb_snefru128, 1);
|
85
|
+
rb_define_module_function(*m_mhash, "snefru128!", mhash_rb_snefru128_hex, 1);
|
61
86
|
rb_define_module_function(*m_mhash, "snefru256", mhash_rb_snefru256, 1);
|
87
|
+
rb_define_module_function(*m_mhash, "snefru256!", mhash_rb_snefru256_hex, 1);
|
62
88
|
}
|
@@ -10,141 +10,391 @@ VALUE mhash_rb_digest(VALUE self, VALUE hash_type, VALUE data_to_hash)
|
|
10
10
|
unsigned int size_of_hash;
|
11
11
|
char *hash;
|
12
12
|
|
13
|
-
td = mhash_init(
|
13
|
+
td = mhash_init(NUM2INT(hash_type));
|
14
14
|
if (td == MHASH_FAILED)
|
15
15
|
rb_raise(rb_eException, "Unable to init mhash - MHASH_FAILED");
|
16
16
|
mhash(td, RSTRING_PTR(data_to_hash), RSTRING_LEN(data_to_hash));
|
17
17
|
hash = mhash_end(td);
|
18
|
-
size_of_hash = mhash_get_block_size(
|
18
|
+
size_of_hash = mhash_get_block_size(NUM2INT(hash_type));
|
19
19
|
rb_str_hash = rb_str_new2("");
|
20
|
-
for (i = 0; i < size_of_hash; i++)
|
20
|
+
for (i = 0; i < size_of_hash; i++)
|
21
21
|
rb_str_hash = rb_str_cat(rb_str_hash, (const char *) &hash[i], 1);
|
22
|
-
}
|
23
22
|
free(hash);
|
24
23
|
return (rb_str_hash);
|
25
24
|
}
|
26
25
|
|
26
|
+
// This code has been reajusted from String class unpack method.
|
27
|
+
VALUE mhash_rb_hexdigest(VALUE self, VALUE data_to_hex)
|
28
|
+
{
|
29
|
+
int bits = 0;
|
30
|
+
long len, j;
|
31
|
+
VALUE hex_digest;
|
32
|
+
char *s, *t;
|
33
|
+
static const char hexdigits[] = "0123456789abcdef";
|
34
|
+
|
35
|
+
s = RSTRING_PTR(data_to_hex);
|
36
|
+
len = RSTRING_LEN(data_to_hex) * 2;
|
37
|
+
hex_digest = rb_str_new(0, len);
|
38
|
+
t = RSTRING_PTR(hex_digest);
|
39
|
+
for (j = 0; j < len; j++)
|
40
|
+
{
|
41
|
+
if (j & 1)
|
42
|
+
bits <<= 4;
|
43
|
+
else
|
44
|
+
bits = *s++;
|
45
|
+
*t++ = hexdigits[(bits >> 4) & 15];
|
46
|
+
}
|
47
|
+
return (hex_digest);
|
48
|
+
}
|
49
|
+
|
27
50
|
VALUE mhash_rb_crc32(VALUE self, VALUE data_to_hash)
|
28
51
|
{
|
29
52
|
return (mhash_rb_digest(self, INT2NUM(0), data_to_hash));
|
30
53
|
}
|
31
54
|
|
55
|
+
VALUE mhash_rb_crc32_hex(VALUE self, VALUE data_to_hash)
|
56
|
+
{
|
57
|
+
VALUE hash;
|
58
|
+
|
59
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(0),
|
60
|
+
data_to_hash));
|
61
|
+
return (hash);
|
62
|
+
}
|
63
|
+
|
64
|
+
|
32
65
|
VALUE mhash_rb_md5(VALUE self, VALUE data_to_hash)
|
33
66
|
{
|
34
67
|
return (mhash_rb_digest(self, INT2NUM(1), data_to_hash));
|
35
68
|
}
|
36
69
|
|
70
|
+
VALUE mhash_rb_md5_hex(VALUE self, VALUE data_to_hash)
|
71
|
+
{
|
72
|
+
VALUE hash;
|
73
|
+
|
74
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(1),
|
75
|
+
data_to_hash));
|
76
|
+
return (hash);
|
77
|
+
}
|
78
|
+
|
79
|
+
|
37
80
|
VALUE mhash_rb_sha1(VALUE self, VALUE data_to_hash)
|
38
81
|
{
|
39
82
|
return (mhash_rb_digest(self, INT2NUM(2), data_to_hash));
|
40
83
|
}
|
41
84
|
|
85
|
+
VALUE mhash_rb_sha1_hex(VALUE self, VALUE data_to_hash)
|
86
|
+
{
|
87
|
+
VALUE hash;
|
88
|
+
|
89
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(2),
|
90
|
+
data_to_hash));
|
91
|
+
return (hash);
|
92
|
+
}
|
93
|
+
|
94
|
+
|
42
95
|
VALUE mhash_rb_haval256(VALUE self, VALUE data_to_hash)
|
43
96
|
{
|
44
97
|
return (mhash_rb_digest(self, INT2NUM(3), data_to_hash));
|
45
98
|
}
|
46
99
|
|
100
|
+
VALUE mhash_rb_haval256_hex(VALUE self, VALUE data_to_hash)
|
101
|
+
{
|
102
|
+
VALUE hash;
|
103
|
+
|
104
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(3),
|
105
|
+
data_to_hash));
|
106
|
+
return (hash);
|
107
|
+
}
|
108
|
+
|
47
109
|
VALUE mhash_rb_ripemd160(VALUE self, VALUE data_to_hash)
|
48
110
|
{
|
49
111
|
return (mhash_rb_digest(self, INT2NUM(5), data_to_hash));
|
50
112
|
}
|
51
113
|
|
114
|
+
VALUE mhash_rb_ripemd160_hex(VALUE self, VALUE data_to_hash)
|
115
|
+
{
|
116
|
+
VALUE hash;
|
117
|
+
|
118
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(5),
|
119
|
+
data_to_hash));
|
120
|
+
return (hash);
|
121
|
+
}
|
122
|
+
|
52
123
|
VALUE mhash_rb_tiger192(VALUE self, VALUE data_to_hash)
|
53
124
|
{
|
54
125
|
return (mhash_rb_digest(self, INT2NUM(7), data_to_hash));
|
55
126
|
}
|
56
127
|
|
128
|
+
VALUE mhash_rb_tiger192_hex(VALUE self, VALUE data_to_hash)
|
129
|
+
{
|
130
|
+
VALUE hash;
|
131
|
+
|
132
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(7),
|
133
|
+
data_to_hash));
|
134
|
+
return (hash);
|
135
|
+
}
|
136
|
+
|
57
137
|
VALUE mhash_rb_gost(VALUE self, VALUE data_to_hash)
|
58
138
|
{
|
59
139
|
return (mhash_rb_digest(self, INT2NUM(8), data_to_hash));
|
60
140
|
}
|
61
141
|
|
142
|
+
VALUE mhash_rb_gost_hex(VALUE self, VALUE data_to_hash)
|
143
|
+
{
|
144
|
+
VALUE hash;
|
145
|
+
|
146
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(8),
|
147
|
+
data_to_hash));
|
148
|
+
return (hash);
|
149
|
+
}
|
150
|
+
|
62
151
|
VALUE mhash_rb_crc32b(VALUE self, VALUE data_to_hash)
|
63
152
|
{
|
64
153
|
return (mhash_rb_digest(self, INT2NUM(9), data_to_hash));
|
65
154
|
}
|
66
155
|
|
156
|
+
VALUE mhash_rb_crc32b_hex(VALUE self, VALUE data_to_hash)
|
157
|
+
{
|
158
|
+
VALUE hash;
|
159
|
+
|
160
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(9),
|
161
|
+
data_to_hash));
|
162
|
+
return (hash);
|
163
|
+
}
|
67
164
|
VALUE mhash_rb_haval224(VALUE self, VALUE data_to_hash)
|
68
165
|
{
|
69
166
|
return (mhash_rb_digest(self, INT2NUM(10), data_to_hash));
|
70
167
|
}
|
71
168
|
|
169
|
+
VALUE mhash_rb_haval224_hex(VALUE self, VALUE data_to_hash)
|
170
|
+
{
|
171
|
+
VALUE hash;
|
172
|
+
|
173
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(10),
|
174
|
+
data_to_hash));
|
175
|
+
return (hash);
|
176
|
+
}
|
177
|
+
|
72
178
|
VALUE mhash_rb_haval192(VALUE self, VALUE data_to_hash)
|
73
179
|
{
|
74
180
|
return (mhash_rb_digest(self, INT2NUM(11), data_to_hash));
|
75
181
|
}
|
76
182
|
|
183
|
+
VALUE mhash_rb_haval192_hex(VALUE self, VALUE data_to_hash)
|
184
|
+
{
|
185
|
+
VALUE hash;
|
186
|
+
|
187
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(11),
|
188
|
+
data_to_hash));
|
189
|
+
return (hash);
|
190
|
+
}
|
191
|
+
|
77
192
|
VALUE mhash_rb_haval160(VALUE self, VALUE data_to_hash)
|
78
193
|
{
|
79
194
|
return (mhash_rb_digest(self, INT2NUM(12), data_to_hash));
|
80
195
|
}
|
81
196
|
|
197
|
+
VALUE mhash_rb_haval160_hex(VALUE self, VALUE data_to_hash)
|
198
|
+
{
|
199
|
+
VALUE hash;
|
200
|
+
|
201
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(12),
|
202
|
+
data_to_hash));
|
203
|
+
return (hash);
|
204
|
+
}
|
205
|
+
|
82
206
|
VALUE mhash_rb_haval128(VALUE self, VALUE data_to_hash)
|
83
207
|
{
|
84
208
|
return (mhash_rb_digest(self, INT2NUM(13), data_to_hash));
|
85
209
|
}
|
86
210
|
|
211
|
+
VALUE mhash_rb_haval128_hex(VALUE self, VALUE data_to_hash)
|
212
|
+
{
|
213
|
+
VALUE hash;
|
214
|
+
|
215
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(13),
|
216
|
+
data_to_hash));
|
217
|
+
return (hash);
|
218
|
+
}
|
219
|
+
|
87
220
|
VALUE mhash_rb_tiger128(VALUE self, VALUE data_to_hash)
|
88
221
|
{
|
89
222
|
return (mhash_rb_digest(self, INT2NUM(14), data_to_hash));
|
90
223
|
}
|
91
224
|
|
225
|
+
VALUE mhash_rb_tiger128_hex(VALUE self, VALUE data_to_hash)
|
226
|
+
{
|
227
|
+
VALUE hash;
|
228
|
+
|
229
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(14),
|
230
|
+
data_to_hash));
|
231
|
+
return (hash);
|
232
|
+
}
|
233
|
+
|
92
234
|
VALUE mhash_rb_tiger160(VALUE self, VALUE data_to_hash)
|
93
235
|
{
|
94
236
|
return (mhash_rb_digest(self, INT2NUM(15), data_to_hash));
|
95
237
|
}
|
96
238
|
|
239
|
+
VALUE mhash_rb_tiger160_hex(VALUE self, VALUE data_to_hash)
|
240
|
+
{
|
241
|
+
VALUE hash;
|
242
|
+
|
243
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(15),
|
244
|
+
data_to_hash));
|
245
|
+
return (hash);
|
246
|
+
}
|
247
|
+
|
97
248
|
VALUE mhash_rb_sha256(VALUE self, VALUE data_to_hash)
|
98
249
|
{
|
99
250
|
return (mhash_rb_digest(self, INT2NUM(17), data_to_hash));
|
100
251
|
}
|
101
252
|
|
253
|
+
VALUE mhash_rb_sha256_hex(VALUE self, VALUE data_to_hash)
|
254
|
+
{
|
255
|
+
VALUE hash;
|
256
|
+
|
257
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(17),
|
258
|
+
data_to_hash));
|
259
|
+
return (hash);
|
260
|
+
}
|
261
|
+
|
102
262
|
VALUE mhash_rb_adler32(VALUE self, VALUE data_to_hash)
|
103
263
|
{
|
104
264
|
return (mhash_rb_digest(self, INT2NUM(18), data_to_hash));
|
105
265
|
}
|
106
266
|
|
267
|
+
VALUE mhash_rb_adler32_hex(VALUE self, VALUE data_to_hash)
|
268
|
+
{
|
269
|
+
VALUE hash;
|
270
|
+
|
271
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(18),
|
272
|
+
data_to_hash));
|
273
|
+
return (hash);
|
274
|
+
}
|
275
|
+
|
107
276
|
VALUE mhash_rb_sha224(VALUE self, VALUE data_to_hash)
|
108
277
|
{
|
109
278
|
return (mhash_rb_digest(self, INT2NUM(19), data_to_hash));
|
110
279
|
}
|
111
280
|
|
281
|
+
VALUE mhash_rb_sha224_hex(VALUE self, VALUE data_to_hash)
|
282
|
+
{
|
283
|
+
VALUE hash;
|
284
|
+
|
285
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(19),
|
286
|
+
data_to_hash));
|
287
|
+
return (hash);
|
288
|
+
}
|
289
|
+
|
112
290
|
VALUE mhash_rb_sha512(VALUE self, VALUE data_to_hash)
|
113
291
|
{
|
114
292
|
return (mhash_rb_digest(self, INT2NUM(20), data_to_hash));
|
115
293
|
}
|
116
294
|
|
295
|
+
VALUE mhash_rb_sha512_hex(VALUE self, VALUE data_to_hash)
|
296
|
+
{
|
297
|
+
VALUE hash;
|
298
|
+
|
299
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(20),
|
300
|
+
data_to_hash));
|
301
|
+
return (hash);
|
302
|
+
}
|
303
|
+
|
117
304
|
VALUE mhash_rb_sha384(VALUE self, VALUE data_to_hash)
|
118
305
|
{
|
119
306
|
return (mhash_rb_digest(self, INT2NUM(21), data_to_hash));
|
120
307
|
}
|
121
308
|
|
309
|
+
VALUE mhash_rb_sha384_hex(VALUE self, VALUE data_to_hash)
|
310
|
+
{
|
311
|
+
VALUE hash;
|
312
|
+
|
313
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(21),
|
314
|
+
data_to_hash));
|
315
|
+
return (hash);
|
316
|
+
}
|
317
|
+
|
122
318
|
VALUE mhash_rb_whirlpool(VALUE self, VALUE data_to_hash)
|
123
319
|
{
|
124
320
|
return (mhash_rb_digest(self, INT2NUM(22), data_to_hash));
|
125
321
|
}
|
126
322
|
|
323
|
+
VALUE mhash_rb_whirlpool_hex(VALUE self, VALUE data_to_hash)
|
324
|
+
{
|
325
|
+
VALUE hash;
|
326
|
+
|
327
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(22),
|
328
|
+
data_to_hash));
|
329
|
+
return (hash);
|
330
|
+
}
|
331
|
+
|
127
332
|
VALUE mhash_rb_ripemd128(VALUE self, VALUE data_to_hash)
|
128
333
|
{
|
129
334
|
return (mhash_rb_digest(self, INT2NUM(23), data_to_hash));
|
130
335
|
}
|
131
336
|
|
337
|
+
VALUE mhash_rb_ripemd128_hex(VALUE self, VALUE data_to_hash)
|
338
|
+
{
|
339
|
+
VALUE hash;
|
340
|
+
|
341
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(23),
|
342
|
+
data_to_hash));
|
343
|
+
return (hash);
|
344
|
+
}
|
345
|
+
|
132
346
|
VALUE mhash_rb_ripemd256(VALUE self, VALUE data_to_hash)
|
133
347
|
{
|
134
348
|
return (mhash_rb_digest(self, INT2NUM(24), data_to_hash));
|
135
349
|
}
|
136
350
|
|
351
|
+
VALUE mhash_rb_ripemd256_hex(VALUE self, VALUE data_to_hash)
|
352
|
+
{
|
353
|
+
VALUE hash;
|
354
|
+
|
355
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(24),
|
356
|
+
data_to_hash));
|
357
|
+
return (hash);
|
358
|
+
}
|
359
|
+
|
137
360
|
VALUE mhash_rb_ripemd320(VALUE self, VALUE data_to_hash)
|
138
361
|
{
|
139
362
|
return (mhash_rb_digest(self, INT2NUM(25), data_to_hash));
|
140
363
|
}
|
141
364
|
|
365
|
+
VALUE mhash_rb_ripemd320_hex(VALUE self, VALUE data_to_hash)
|
366
|
+
{
|
367
|
+
VALUE hash;
|
368
|
+
|
369
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(25),
|
370
|
+
data_to_hash));
|
371
|
+
return (hash);
|
372
|
+
}
|
373
|
+
|
142
374
|
VALUE mhash_rb_snefru128(VALUE self, VALUE data_to_hash)
|
143
375
|
{
|
144
376
|
return (mhash_rb_digest(self, INT2NUM(26), data_to_hash));
|
145
377
|
}
|
146
378
|
|
379
|
+
VALUE mhash_rb_snefru128_hex(VALUE self, VALUE data_to_hash)
|
380
|
+
{
|
381
|
+
VALUE hash;
|
382
|
+
|
383
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(26),
|
384
|
+
data_to_hash));
|
385
|
+
return (hash);
|
386
|
+
}
|
387
|
+
|
147
388
|
VALUE mhash_rb_snefru256(VALUE self, VALUE data_to_hash)
|
148
389
|
{
|
149
390
|
return (mhash_rb_digest(self, INT2NUM(27), data_to_hash));
|
150
391
|
}
|
392
|
+
|
393
|
+
VALUE mhash_rb_snefru256_hex(VALUE self, VALUE data_to_hash)
|
394
|
+
{
|
395
|
+
VALUE hash;
|
396
|
+
|
397
|
+
hash = mhash_rb_hexdigest(self, mhash_rb_digest(self, INT2NUM(27),
|
398
|
+
data_to_hash));
|
399
|
+
return (hash);
|
400
|
+
}
|
@@ -2,31 +2,81 @@
|
|
2
2
|
#define __MHASH_FUNCTIONS__
|
3
3
|
|
4
4
|
VALUE mhash_rb_digest(VALUE self, VALUE hash_type, VALUE data_to_hash);
|
5
|
+
VALUE mhash_rb_hexdigest(VALUE self, VALUE data_to_hex);
|
5
6
|
|
6
7
|
VALUE mhash_rb_crc32(VALUE self, VALUE data_to_hash);
|
8
|
+
VALUE mhash_rb_crc32_hex(VALUE self, VALUE data_to_hash);
|
9
|
+
|
7
10
|
VALUE mhash_rb_md5(VALUE self, VALUE data_to_hash);
|
11
|
+
VALUE mhash_rb_md5_hex(VALUE self, VALUE data_to_hash);
|
12
|
+
|
8
13
|
VALUE mhash_rb_sha1(VALUE self, VALUE data_to_hash);
|
14
|
+
VALUE mhash_rb_sha1_hex(VALUE self, VALUE data_to_hash);
|
15
|
+
|
9
16
|
VALUE mhash_rb_haval256(VALUE self, VALUE data_to_hash);
|
17
|
+
VALUE mhash_rb_haval256_hex(VALUE self, VALUE data_to_hash);
|
18
|
+
|
10
19
|
VALUE mhash_rb_ripemd160(VALUE self, VALUE data_to_hash);
|
20
|
+
VALUE mhash_rb_ripemd160_hex(VALUE self, VALUE data_to_hash);
|
21
|
+
|
11
22
|
VALUE mhash_rb_tiger192(VALUE self, VALUE data_to_hash);
|
23
|
+
VALUE mhash_rb_tiger192_hex(VALUE self, VALUE data_to_hash);
|
24
|
+
|
12
25
|
VALUE mhash_rb_gost(VALUE self, VALUE data_to_hash);
|
26
|
+
VALUE mhash_rb_gost_hex(VALUE self, VALUE data_to_hash);
|
27
|
+
|
13
28
|
VALUE mhash_rb_crc32b(VALUE self, VALUE data_to_hash);
|
29
|
+
VALUE mhash_rb_crc32b_hex(VALUE self, VALUE data_to_hash);
|
30
|
+
|
14
31
|
VALUE mhash_rb_haval224(VALUE self, VALUE data_to_hash);
|
32
|
+
VALUE mhash_rb_haval224_hex(VALUE self, VALUE data_to_hash);
|
33
|
+
|
15
34
|
VALUE mhash_rb_haval192(VALUE self, VALUE data_to_hash);
|
35
|
+
VALUE mhash_rb_haval192_hex(VALUE self, VALUE data_to_hash);
|
36
|
+
|
16
37
|
VALUE mhash_rb_haval160(VALUE self, VALUE data_to_hash);
|
38
|
+
VALUE mhash_rb_haval160_hex(VALUE self, VALUE data_to_hash);
|
39
|
+
|
17
40
|
VALUE mhash_rb_haval128(VALUE self, VALUE data_to_hash);
|
41
|
+
VALUE mhash_rb_haval128_hex(VALUE self, VALUE data_to_hash);
|
42
|
+
|
18
43
|
VALUE mhash_rb_tiger128(VALUE self, VALUE data_to_hash);
|
44
|
+
VALUE mhash_rb_tiger128_hex(VALUE self, VALUE data_to_hash);
|
45
|
+
|
19
46
|
VALUE mhash_rb_tiger160(VALUE self, VALUE data_to_hash);
|
47
|
+
VALUE mhash_rb_tiger160_hex(VALUE self, VALUE data_to_hash);
|
48
|
+
|
20
49
|
VALUE mhash_rb_sha256(VALUE self, VALUE data_to_hash);
|
50
|
+
VALUE mhash_rb_sha256_hex(VALUE self, VALUE data_to_hash);
|
51
|
+
|
21
52
|
VALUE mhash_rb_adler32(VALUE self, VALUE data_to_hash);
|
53
|
+
VALUE mhash_rb_adler32_hex(VALUE self, VALUE data_to_hash);
|
54
|
+
|
22
55
|
VALUE mhash_rb_sha224(VALUE self, VALUE data_to_hash);
|
56
|
+
VALUE mhash_rb_sha224_hex(VALUE self, VALUE data_to_hash);
|
57
|
+
|
23
58
|
VALUE mhash_rb_sha512(VALUE self, VALUE data_to_hash);
|
59
|
+
VALUE mhash_rb_sha512_hex(VALUE self, VALUE data_to_hash);
|
60
|
+
|
24
61
|
VALUE mhash_rb_sha384(VALUE self, VALUE data_to_hash);
|
62
|
+
VALUE mhash_rb_sha384_hex(VALUE self, VALUE data_to_hash);
|
63
|
+
|
25
64
|
VALUE mhash_rb_whirlpool(VALUE self, VALUE data_to_hash);
|
65
|
+
VALUE mhash_rb_whirlpool_hex(VALUE self, VALUE data_to_hash);
|
66
|
+
|
26
67
|
VALUE mhash_rb_ripemd128(VALUE self, VALUE data_to_hash);
|
68
|
+
VALUE mhash_rb_ripemd128_hex(VALUE self, VALUE data_to_hash);
|
69
|
+
|
27
70
|
VALUE mhash_rb_ripemd256(VALUE self, VALUE data_to_hash);
|
71
|
+
VALUE mhash_rb_ripemd256_hex(VALUE self, VALUE data_to_hash);
|
72
|
+
|
28
73
|
VALUE mhash_rb_ripemd320(VALUE self, VALUE data_to_hash);
|
74
|
+
VALUE mhash_rb_ripemd320_hex(VALUE self, VALUE data_to_hash);
|
75
|
+
|
29
76
|
VALUE mhash_rb_snefru128(VALUE self, VALUE data_to_hash);
|
77
|
+
VALUE mhash_rb_snefru128_hex(VALUE self, VALUE data_to_hash);
|
78
|
+
|
30
79
|
VALUE mhash_rb_snefru256(VALUE self, VALUE data_to_hash);
|
80
|
+
VALUE mhash_rb_snefru256_hex(VALUE self, VALUE data_to_hash);
|
31
81
|
|
32
82
|
#endif
|
data/lib/mhash.rb
CHANGED
data/mhash.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.files = `git ls-files`.split("\n")
|
11
11
|
gem.extensions = ["ext/mhash/extconf.rb"]
|
12
12
|
gem.require_paths = ["lib", "ext"]
|
13
|
-
gem.version = "1.
|
13
|
+
gem.version = "1.1"
|
14
14
|
gem.extra_rdoc_files = ["LICENSE.txt"]
|
15
15
|
gem.licenses = ["BSD"]
|
16
16
|
end
|
data/test/test_mhash.rb
CHANGED
@@ -7,64 +7,124 @@ class TestMhash < Test::Unit::TestCase
|
|
7
7
|
@data = "hello\n\n"
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
hash = Mhash.
|
10
|
+
def test_gost_hash_unpack
|
11
|
+
hash = Mhash.gost(@data)
|
12
12
|
valid_digest = 'a2c0810ccbb997eb2e029e7e4186535ef4efae43fdcb49afb4933303f649f8db'
|
13
13
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def test_gost_hash_hex
|
17
|
+
hash = Mhash.gost!(@data)
|
18
|
+
valid_digest = 'a2c0810ccbb997eb2e029e7e4186535ef4efae43fdcb49afb4933303f649f8db'
|
19
|
+
assert_equal(valid_digest, hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_tiger192_hash_unpack
|
17
23
|
hash = Mhash.tiger192(@data)
|
18
24
|
valid_digest = '3655e96f537401e1c5ac4197ac22594e6d0a740c664e7263'
|
19
25
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
20
26
|
end
|
21
27
|
|
22
|
-
def
|
28
|
+
def test_tiger192_hash_hex
|
29
|
+
hash = Mhash.tiger192!(@data)
|
30
|
+
valid_digest = '3655e96f537401e1c5ac4197ac22594e6d0a740c664e7263'
|
31
|
+
assert_equal(valid_digest, hash)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_sha1_hash_unpack
|
23
35
|
hash = Mhash.sha1(@data)
|
24
36
|
valid_digest = '4588019fd3d2567f303815db6adfe489b2ee5f92'
|
25
37
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
26
38
|
end
|
27
39
|
|
28
|
-
def
|
40
|
+
def test_sha1_hash_hex
|
41
|
+
hash = Mhash.sha1!(@data)
|
42
|
+
valid_digest = '4588019fd3d2567f303815db6adfe489b2ee5f92'
|
43
|
+
assert_equal(valid_digest, hash)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_sha256_hash_unpack
|
29
47
|
hash = Mhash.sha256(@data)
|
30
48
|
valid_digest = '50adea61fa4e77ab111b814716097abfd05f83a207b47eb4529bbd4f54e111e0'
|
31
49
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
32
50
|
end
|
33
51
|
|
34
|
-
def
|
52
|
+
def test_sha256_hash_hex
|
53
|
+
hash = Mhash.sha256!(@data)
|
54
|
+
valid_digest = '50adea61fa4e77ab111b814716097abfd05f83a207b47eb4529bbd4f54e111e0'
|
55
|
+
assert_equal(valid_digest, hash)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_md5_hash_unpack
|
35
59
|
hash = Mhash.md5(@data)
|
36
60
|
valid_digest = '14e273e6f416c4b90a071f59ac01206a'
|
37
61
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
38
62
|
end
|
39
63
|
|
40
|
-
def
|
64
|
+
def test_md5_hash_hex
|
65
|
+
hash = Mhash.md5!(@data)
|
66
|
+
valid_digest = '14e273e6f416c4b90a071f59ac01206a'
|
67
|
+
assert_equal(valid_digest, hash)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_whirlpool_hash_unpack
|
41
71
|
hash = Mhash.whirlpool(@data)
|
42
72
|
valid_digest = 'adc277e898e7164962c1674c0c3984169534630428364dd43fc7e4e3e7222b6ccf7b7c4656f972f392d5580797b70125780ac860cb84de6f55ed043277d545d3'
|
43
73
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
44
74
|
end
|
45
75
|
|
46
|
-
def
|
76
|
+
def test_whirlpool_hash_hex
|
77
|
+
hash = Mhash.whirlpool!(@data)
|
78
|
+
valid_digest = 'adc277e898e7164962c1674c0c3984169534630428364dd43fc7e4e3e7222b6ccf7b7c4656f972f392d5580797b70125780ac860cb84de6f55ed043277d545d3'
|
79
|
+
assert_equal(valid_digest, hash)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_ripemd160_hash_unpack
|
47
83
|
hash = Mhash.ripemd160(@data)
|
48
84
|
valid_digest = '52985141506d19e443281ad5c6e058871bb2f765'
|
49
85
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
50
86
|
end
|
51
87
|
|
52
|
-
def
|
88
|
+
def test_ripemd160_hash_hex
|
89
|
+
hash = Mhash.ripemd160!(@data)
|
90
|
+
valid_digest = '52985141506d19e443281ad5c6e058871bb2f765'
|
91
|
+
assert_equal(valid_digest, hash)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_haval256_hash_unpack
|
53
95
|
hash = Mhash.haval256(@data)
|
54
96
|
valid_digest = '1b3aa948d5d867964d72b9320a648050725e2daac5898c2d9f09512b99e5f72f'
|
55
97
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
56
98
|
end
|
57
99
|
|
58
|
-
def
|
100
|
+
def test_haval256_hash_hex
|
101
|
+
hash = Mhash.haval256!(@data)
|
102
|
+
valid_digest = '1b3aa948d5d867964d72b9320a648050725e2daac5898c2d9f09512b99e5f72f'
|
103
|
+
assert_equal(valid_digest, hash)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_adler32_hash_unpack
|
59
107
|
hash = Mhash.adler32(@data)
|
60
108
|
valid_digest = '2902740a'
|
61
109
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
62
110
|
end
|
63
111
|
|
64
|
-
def
|
112
|
+
def test_adler32_hash_hex
|
113
|
+
hash = Mhash.adler32!(@data)
|
114
|
+
valid_digest = '2902740a'
|
115
|
+
assert_equal(valid_digest, hash)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_snefru256_hash_unpack
|
65
119
|
hash = Mhash.snefru256(@data)
|
66
120
|
valid_digest = 'f33eb2a3152af27e719474e8888da43c53b1ea7a629796eb7a67ecc539fc29a8'
|
67
121
|
assert_equal(valid_digest, hash.unpack("H*").first)
|
68
122
|
end
|
69
123
|
|
124
|
+
def test_snefru256_hash_hex
|
125
|
+
hash = Mhash.snefru256!(@data)
|
126
|
+
valid_digest = 'f33eb2a3152af27e719474e8888da43c53b1ea7a629796eb7a67ecc539fc29a8'
|
127
|
+
assert_equal(valid_digest, hash)
|
128
|
+
end
|
129
|
+
|
70
130
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mhash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Mhash library extension for Ruby
|
15
15
|
email:
|
@@ -24,10 +24,11 @@ files:
|
|
24
24
|
- .travis.yml
|
25
25
|
- Gemfile
|
26
26
|
- LICENSE.txt
|
27
|
+
- README.md
|
27
28
|
- Rakefile
|
28
|
-
- ext/mhash/Makefile
|
29
29
|
- ext/mhash/extconf.rb
|
30
30
|
- ext/mhash/mhash.c
|
31
|
+
- ext/mhash/mhash_ruby.h
|
31
32
|
- ext/mhash/module_definitions.c
|
32
33
|
- ext/mhash/module_definitions.h
|
33
34
|
- ext/mhash/module_functions.c
|
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
58
|
version: '0'
|
58
59
|
requirements: []
|
59
60
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.23
|
61
62
|
signing_key:
|
62
63
|
specification_version: 3
|
63
64
|
summary: Mhash library extension for Ruby
|
data/ext/mhash/Makefile
DELETED
@@ -1,187 +0,0 @@
|
|
1
|
-
|
2
|
-
SHELL = /bin/sh
|
3
|
-
|
4
|
-
#### Start of system configuration section. ####
|
5
|
-
|
6
|
-
srcdir = .
|
7
|
-
topdir = /home/tibshoot/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1
|
8
|
-
hdrdir = /home/tibshoot/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1
|
9
|
-
arch_hdrdir = /home/tibshoot/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/$(arch)
|
10
|
-
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
11
|
-
prefix = $(DESTDIR)/home/tibshoot/.rvm/rubies/ruby-1.9.2-p320
|
12
|
-
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
13
|
-
exec_prefix = $(prefix)
|
14
|
-
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
15
|
-
sitehdrdir = $(rubyhdrdir)/site_ruby
|
16
|
-
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
|
17
|
-
vendordir = $(rubylibprefix)/vendor_ruby
|
18
|
-
sitedir = $(rubylibprefix)/site_ruby
|
19
|
-
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
20
|
-
mandir = $(datarootdir)/man
|
21
|
-
localedir = $(datarootdir)/locale
|
22
|
-
libdir = $(exec_prefix)/lib
|
23
|
-
psdir = $(docdir)
|
24
|
-
pdfdir = $(docdir)
|
25
|
-
dvidir = $(docdir)
|
26
|
-
htmldir = $(docdir)
|
27
|
-
infodir = $(datarootdir)/info
|
28
|
-
docdir = $(datarootdir)/doc/$(PACKAGE)
|
29
|
-
oldincludedir = $(DESTDIR)/usr/include
|
30
|
-
includedir = $(prefix)/include
|
31
|
-
localstatedir = $(prefix)/var
|
32
|
-
sharedstatedir = $(prefix)/com
|
33
|
-
sysconfdir = $(prefix)/etc
|
34
|
-
datadir = $(datarootdir)
|
35
|
-
datarootdir = $(prefix)/share
|
36
|
-
libexecdir = $(exec_prefix)/libexec
|
37
|
-
sbindir = $(exec_prefix)/sbin
|
38
|
-
bindir = $(exec_prefix)/bin
|
39
|
-
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
40
|
-
archdir = $(rubylibdir)/$(arch)
|
41
|
-
sitelibdir = $(sitedir)/$(ruby_version)
|
42
|
-
sitearchdir = $(sitelibdir)/$(sitearch)
|
43
|
-
vendorlibdir = $(vendordir)/$(ruby_version)
|
44
|
-
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
45
|
-
|
46
|
-
CC = gcc
|
47
|
-
CXX = g++
|
48
|
-
LIBRUBY = $(LIBRUBY_SO)
|
49
|
-
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
50
|
-
LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
|
51
|
-
LIBRUBYARG_STATIC = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
|
52
|
-
OUTFLAG = -o
|
53
|
-
COUTFLAG = -o
|
54
|
-
|
55
|
-
RUBY_EXTCONF_H =
|
56
|
-
cflags = $(optflags) $(debugflags) $(warnflags)
|
57
|
-
optflags = -O3
|
58
|
-
debugflags = -ggdb
|
59
|
-
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long
|
60
|
-
CFLAGS = -fPIC $(cflags) -fPIC
|
61
|
-
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
62
|
-
DEFS =
|
63
|
-
CPPFLAGS = -I/home/tibshoot/.rvm/usr/include $(DEFS) $(cppflags)
|
64
|
-
CXXFLAGS = $(CFLAGS) $(cxxflags)
|
65
|
-
ldflags = -L. -rdynamic -Wl,-export-dynamic
|
66
|
-
dldflags =
|
67
|
-
ARCH_FLAG =
|
68
|
-
DLDFLAGS = $(ldflags) $(dldflags)
|
69
|
-
LDSHARED = $(CC) -shared
|
70
|
-
LDSHAREDXX = $(CXX) -shared
|
71
|
-
AR = ar
|
72
|
-
EXEEXT =
|
73
|
-
|
74
|
-
RUBY_BASE_NAME = ruby
|
75
|
-
RUBY_INSTALL_NAME = ruby
|
76
|
-
RUBY_SO_NAME = ruby
|
77
|
-
arch = x86_64-linux
|
78
|
-
sitearch = $(arch)
|
79
|
-
ruby_version = 1.9.1
|
80
|
-
ruby = /home/tibshoot/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
|
81
|
-
RUBY = $(ruby)
|
82
|
-
RM = rm -f
|
83
|
-
RM_RF = $(RUBY) -run -e rm -- -rf
|
84
|
-
RMDIRS = $(RUBY) -run -e rmdir -- -p
|
85
|
-
MAKEDIRS = /bin/mkdir -p
|
86
|
-
INSTALL = /usr/bin/install -c
|
87
|
-
INSTALL_PROG = $(INSTALL) -m 0755
|
88
|
-
INSTALL_DATA = $(INSTALL) -m 644
|
89
|
-
COPY = cp
|
90
|
-
|
91
|
-
#### End of system configuration section. ####
|
92
|
-
|
93
|
-
preload =
|
94
|
-
|
95
|
-
libpath = . $(libdir) /home/tibshoot/.rvm/usr/lib
|
96
|
-
LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir) -L/home/tibshoot/.rvm/usr/lib -Wl,-R/home/tibshoot/.rvm/usr/lib
|
97
|
-
DEFFILE =
|
98
|
-
|
99
|
-
CLEANFILES = mkmf.log
|
100
|
-
DISTCLEANFILES =
|
101
|
-
DISTCLEANDIRS =
|
102
|
-
|
103
|
-
extout =
|
104
|
-
extout_prefix =
|
105
|
-
target_prefix = /mhash
|
106
|
-
LOCAL_LIBS =
|
107
|
-
LIBS = $(LIBRUBYARG_SHARED) -lmhash -lpthread -lrt -ldl -lcrypt -lm -lc
|
108
|
-
SRCS = mhash.c module_definitions.c module_functions.c
|
109
|
-
OBJS = mhash.o module_definitions.o module_functions.o
|
110
|
-
TARGET = mhash
|
111
|
-
DLLIB = $(TARGET).so
|
112
|
-
EXTSTATIC =
|
113
|
-
STATIC_LIB =
|
114
|
-
|
115
|
-
BINDIR = $(bindir)
|
116
|
-
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
117
|
-
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
118
|
-
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
119
|
-
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
120
|
-
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
121
|
-
|
122
|
-
TARGET_SO = $(DLLIB)
|
123
|
-
CLEANLIBS = $(TARGET).so
|
124
|
-
CLEANOBJS = *.o *.bak
|
125
|
-
|
126
|
-
all: $(DLLIB)
|
127
|
-
static: $(STATIC_LIB)
|
128
|
-
.PHONY: all install static install-so install-rb
|
129
|
-
.PHONY: clean clean-so clean-rb
|
130
|
-
|
131
|
-
clean-rb-default::
|
132
|
-
clean-rb::
|
133
|
-
clean-so::
|
134
|
-
clean: clean-so clean-rb-default clean-rb
|
135
|
-
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
136
|
-
|
137
|
-
distclean-rb-default::
|
138
|
-
distclean-rb::
|
139
|
-
distclean-so::
|
140
|
-
distclean: clean distclean-so distclean-rb-default distclean-rb
|
141
|
-
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
142
|
-
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
143
|
-
@-$(RMDIRS) $(DISTCLEANDIRS)
|
144
|
-
|
145
|
-
realclean: distclean
|
146
|
-
install: install-so install-rb
|
147
|
-
|
148
|
-
install-so: $(RUBYARCHDIR)
|
149
|
-
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
150
|
-
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
151
|
-
@-$(MAKEDIRS) $(@D)
|
152
|
-
$(INSTALL_PROG) $(DLLIB) $(@D)
|
153
|
-
install-rb: pre-install-rb install-rb-default
|
154
|
-
install-rb-default: pre-install-rb-default
|
155
|
-
pre-install-rb: Makefile
|
156
|
-
pre-install-rb-default: Makefile
|
157
|
-
$(RUBYARCHDIR):
|
158
|
-
$(MAKEDIRS) $@
|
159
|
-
|
160
|
-
site-install: site-install-so site-install-rb
|
161
|
-
site-install-so: install-so
|
162
|
-
site-install-rb: install-rb
|
163
|
-
|
164
|
-
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
165
|
-
|
166
|
-
.cc.o:
|
167
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
168
|
-
|
169
|
-
.cxx.o:
|
170
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
171
|
-
|
172
|
-
.cpp.o:
|
173
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
174
|
-
|
175
|
-
.C.o:
|
176
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
177
|
-
|
178
|
-
.c.o:
|
179
|
-
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
180
|
-
|
181
|
-
$(DLLIB): $(OBJS) Makefile
|
182
|
-
@-$(RM) $(@)
|
183
|
-
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
|